diff --git a/src/main/java/nyc/c4q/AbstractAwesomeClass.java b/src/main/java/nyc/c4q/AbstractAwesomeClass.java
index e3f9c21..0683caa 100644
--- a/src/main/java/nyc/c4q/AbstractAwesomeClass.java
+++ b/src/main/java/nyc/c4q/AbstractAwesomeClass.java
@@ -7,7 +7,7 @@ public abstract class AbstractAwesomeClass implements AwesomeInterface {
@Override
public int getData() {
- return 0;
+ return 5;
}
@Override
diff --git a/src/main/java/nyc/c4q/InitialActivity.java b/src/main/java/nyc/c4q/InitialActivity.java
index 2213b83..d445780 100644
--- a/src/main/java/nyc/c4q/InitialActivity.java
+++ b/src/main/java/nyc/c4q/InitialActivity.java
@@ -15,15 +15,15 @@ public class InitialActivity extends Activity {
public SharedPreferences preferences = null;
public final static String TAG = "C4QTAG";
- public void loadState(){
+ public void loadState() {
Log.d(TAG, "loadState()");
counter = preferences.getInt("counter", 0);
- Log.d(TAG, "loadState(): counter=="+counter);
+ Log.d(TAG, "loadState(): counter==" + counter);
}
- public void saveState(){
+ public void saveState() {
Log.d(TAG, "saveState()");
- Log.d(TAG, "saveState(): counter=="+counter);
+ Log.d(TAG, "saveState(): counter==" + counter);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("counter", counter);
editor.commit();
@@ -34,5 +34,17 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);
+
+ final Button buttonPlus = (Button) findViewById(R.id.buttonPlus);
+ final TextView tvCounter = (TextView) findViewById(R.id.tvCounter);
+
+ buttonPlus.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ counter=+1;
+ tvCounter.setText(counter+"");
+ }
+ });
+
}
}
+
diff --git a/src/main/java/nyc/c4q/SubFunClass.java b/src/main/java/nyc/c4q/SubFunClass.java
index ef94dce..322f878 100644
--- a/src/main/java/nyc/c4q/SubFunClass.java
+++ b/src/main/java/nyc/c4q/SubFunClass.java
@@ -3,7 +3,18 @@
/**
* Created by amyquispe on 5/19/15.
*/
-public class SubFunClass {
- public SubFunClass(){
+public class SubFunClass extends SuperFunClass implements AwesomeInterface{
+ public SubFunClass (){
+
+ }
+
+ @Override
+ public int getData() {
+ return 0;
+ }
+
+ @Override
+ public void setData(int someData) {
+
}
}
diff --git a/src/main/res/layout/activity_initial.xml b/src/main/res/layout/activity_initial.xml
index 49e22b0..1e6a516 100644
--- a/src/main/res/layout/activity_initial.xml
+++ b/src/main/res/layout/activity_initial.xml
@@ -1,18 +1,69 @@
-
-
-
+ android:orientation="vertical"
+ tools:context="nyc.c4q.InitialActivity">
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:text="Empty" />
+
\ No newline at end of file
diff --git a/src/main/res/layout/activity_tile.xml b/src/main/res/layout/activity_tile.xml
index 4e36a11..7730993 100644
--- a/src/main/res/layout/activity_tile.xml
+++ b/src/main/res/layout/activity_tile.xml
@@ -1,15 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_height="0dp"
+ android:background="#FFFFFF" />
+
+
+
+
diff --git a/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java b/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java
index bae0f78..18f3341 100644
--- a/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java
+++ b/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java
@@ -3,6 +3,7 @@
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.location.GpsStatus;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
@@ -103,172 +104,177 @@ public void test02ButtonPlusShouldIncreaseTvCounter() throws Exception {
assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
- assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
- for (int i=1; i<10; i++){
- buttonPlus.callOnClick();
- assertEquals(i, Integer.parseInt((String) tvCounter.getText()));
- }
- }
+
+ assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
+ for (int i = 1; i < 10; i++) {
+ buttonPlus.callOnClick();
+ assertEquals(i, Integer.parseInt((String) tvCounter.getText()));
+ }
+ }
@Test
public void test03ButtonMinusShouldDecreaseTvCounter() throws Exception {
InitialActivity activity = Robolectric.buildActivity(InitialActivity.class).setup().get();
- Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
- TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
+ final Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
+ final TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
- assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
- for (int i=-1; i>-10; i--){
- buttonMinus.callOnClick();
- assertEquals(i, Integer.parseInt((String) tvCounter.getText()));
- }
+ buttonMinus.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
+ for (int i = -1; i > -10; i--) {
+ buttonMinus.callOnClick();
+ assertEquals(i, Integer.parseInt((String) tvCounter.getText()));
+ }
+ }
+ });
}
- @Test
- public void test04ButtonPlusAndButtonMinusShouldWork() throws Exception {
- InitialActivity activity = Robolectric.buildActivity(InitialActivity.class).setup().get();
- Button buttonPlus = (Button) Helpers.findViewByIdString(activity, "buttonPlus");
- Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
- TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
-
- assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
- assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
- assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
-
- Random r = new Random(3680);
-
- assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
- int internalCount = 0;
- for (int i=0; i<10000; i++){
- if (r.nextBoolean()){
- internalCount++;
- buttonPlus.callOnClick();
- }
- else {
- internalCount--;
- buttonMinus.callOnClick();
+ @Test
+ public void test04ButtonPlusAndButtonMinusShouldWork() throws Exception {
+ InitialActivity activity = Robolectric.buildActivity(InitialActivity.class).setup().get();
+ final Button buttonPlus = (Button) Helpers.findViewByIdString(activity, "buttonPlus");
+ final Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
+ final TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
+
+ assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
+ assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
+ assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
+
+ Random r = new Random(3680);
+
+ assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
+ int internalCount = 0;
+ for (int i = 0; i < 10000; i++) {
+ if (r.nextBoolean()) {
+ internalCount++;
+ buttonPlus.callOnClick();
+ } else {
+ internalCount--;
+ buttonMinus.callOnClick();
+ }
+ assertEquals(internalCount, Integer.parseInt((String) tvCounter.getText()));
}
- assertEquals(internalCount, Integer.parseInt((String) tvCounter.getText()));
}
- }
- @Test
- public void test05TvCounterStateShouldBeSavedThroughActivityLifeCycle(){
- // use InitialActivity.saveState() and InitialActivity.loadState() methods
- ActivityController controller = Robolectric.buildActivity(InitialActivity.class).setup();
- InitialActivity activity = controller.get();
- Button buttonPlus = (Button) Helpers.findViewByIdString(activity, "buttonPlus");
- Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
- TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
- assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
- assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
- assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
+ @Test
+ public void test05TvCounterStateShouldBeSavedThroughActivityLifeCycle() {
+ // use InitialActivity.saveState() and InitialActivity.loadState() methods
+ ActivityController controller = Robolectric.buildActivity(InitialActivity.class).setup();
+ InitialActivity activity = controller.get();
+ Button buttonPlus = (Button) Helpers.findViewByIdString(activity, "buttonPlus");
+ Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
+ TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
+
+ assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
+ assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
+ assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
- assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
- buttonPlus.callOnClick();
- assertEquals(1, Integer.parseInt((String) tvCounter.getText()));
- buttonPlus.callOnClick();
- assertEquals(2, Integer.parseInt((String) tvCounter.getText()));
- buttonMinus.callOnClick();
- assertEquals(1, Integer.parseInt((String) tvCounter.getText()));
+ assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
+ buttonPlus.callOnClick();
+ assertEquals(1, Integer.parseInt((String) tvCounter.getText()));
+ buttonPlus.callOnClick();
+ assertEquals(2, Integer.parseInt((String) tvCounter.getText()));
+ buttonMinus.callOnClick();
+ assertEquals(1, Integer.parseInt((String) tvCounter.getText()));
- controller.pause().stop().destroy();
- controller = Robolectric.buildActivity(InitialActivity.class).setup();
- activity = controller.get();
- tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
+ controller.pause().stop().destroy();
+ controller = Robolectric.buildActivity(InitialActivity.class).setup();
+ activity = controller.get();
+ tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
- assertEquals(1, Integer.parseInt((String) tvCounter.getText()));
+ assertEquals(1, Integer.parseInt((String) tvCounter.getText()));
- }
+ }
- @Test
- public void test06ClickButtonToStartIntentForTileActivity() throws Exception {
- InitialActivity activity = Robolectric.buildActivity(InitialActivity.class).setup().get();
- Button buttonTileActivity = (Button) Helpers.findViewByIdString(activity, "buttonTileActivity");
- assertNotNull("Button(@+id/buttonTileActivity) should not be null", buttonTileActivity);
- buttonTileActivity.callOnClick();
+ @Test
+ public void test06ClickButtonToStartIntentForTileActivity() throws Exception {
+ InitialActivity activity = Robolectric.buildActivity(InitialActivity.class).setup().get();
+ Button buttonTileActivity = (Button) Helpers.findViewByIdString(activity, "buttonTileActivity");
+ assertNotNull("Button(@+id/buttonTileActivity) should not be null", buttonTileActivity);
+ buttonTileActivity.callOnClick();
- ShadowApplication sa = Robolectric.shadowOf(activity.getApplication());
- Intent nextStartedActivity = sa.getNextStartedActivity();
+ ShadowApplication sa = Robolectric.shadowOf(activity.getApplication());
+ Intent nextStartedActivity = sa.getNextStartedActivity();
- assertNotNull("Intent(nyc.c4q/nyc.c4q.TileActivity) is not queued up", nextStartedActivity);
- assertEquals("nyc.c4q/nyc.c4q.TileActivity", nextStartedActivity.getComponent().flattenToString());
- }
+ assertNotNull("Intent(nyc.c4q/nyc.c4q.TileActivity) is not queued up", nextStartedActivity);
+ assertEquals("nyc.c4q/nyc.c4q.TileActivity", nextStartedActivity.getComponent().flattenToString());
+ }
- @Test
- public void test07FixTileActivityLayout() throws Exception {
- TileActivity ta = Robolectric.buildActivity(TileActivity.class).setup().get();
- LinearLayout taLayout = (LinearLayout) ta.findViewById(R.id.activity_tile);
-
- assertTrue("LinearLayout(@+id/activity_tile) should have a horizontal orientation",
- taLayout.getOrientation() == LinearLayout.HORIZONTAL);
-
- assertTrue("LinearLayout(@+id/activity_tile)[0] should be a LinearLayout", taLayout.getChildAt(0) instanceof LinearLayout);
- LinearLayout leftSide = (LinearLayout) taLayout.getChildAt(0);
- assertTrue("LinearLayout(@+id/activity_tile)[0] should have R.id.leftSide", Helpers.getResourceId(leftSide).equals("leftSide"));
- assertTrue("LinearLayout(@+id/activity_tile)[0] should be equal to LinearLayout(@+id/leftSide)", leftSide == Helpers.findViewByIdString(ta, "leftSide"));
- assertTrue("LinearLayout(@+id/activity_tile)[0] should have a vertical orientation",
- leftSide.getOrientation() == LinearLayout.VERTICAL);
- assertEquals("View(@+id/leftSide) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) leftSide.getLayoutParams()).weight, 0.01);
-
- assertTrue("LinearLayout(@+id/activity_tile)[1] should be a LinearLayout", taLayout.getChildAt(1) instanceof LinearLayout);
- LinearLayout rightSide = (LinearLayout) taLayout.getChildAt(1);
- assertTrue("LinearLayout(@+id/activity_tile)[1] should have R.id.rightSide", Helpers.getResourceId(rightSide).equals("rightSide"));
- assertTrue("LinearLayout(@+id/activity_tile)[1] should be equal to LinearLayout(@+id/rightSide)", rightSide == Helpers.findViewByIdString(ta, "rightSide"));
- assertTrue("LinearLayout(@+id/activity_tile)[1] should have a vertical orientation",
- rightSide.getOrientation() == LinearLayout.VERTICAL);
- assertEquals("View(@+id/rightSide) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) rightSide.getLayoutParams()).weight, 0.01);
-
-
- View redView = leftSide.getChildAt(0);
- assertTrue("LinearLayout(@+id/leftSide)[0] should have R.id.redView", Helpers.getResourceId(redView).equals("redView"));
- assertTrue("LinearLayout(@+id/leftSide)[0] should be equal to View(@+id/redView)", redView == Helpers.findViewByIdString(ta, "redView"));
- Drawable redViewBackground = redView.getBackground();
- assertThat(redViewBackground, instanceOf(ColorDrawable.class));
- assertEquals(0xffff0000, ((ColorDrawable) redViewBackground).getColor());
-
- View greenView = leftSide.getChildAt(1);
- assertTrue("LinearLayout(@+id/leftSide)[1] should have R.id.greenView", Helpers.getResourceId(greenView).equals("greenView"));
- assertTrue("LinearLayout(@+id/leftSide)[1] should be equal to View(@+id/greenView)", greenView == Helpers.findViewByIdString(ta, "greenView"));
- Drawable greenViewBackground = greenView.getBackground();
- assertThat(greenViewBackground, instanceOf(ColorDrawable.class));
- assertEquals(0xff00ff00, ((ColorDrawable) greenViewBackground).getColor());
-
- View yellowView = rightSide.getChildAt(0);
- assertTrue("LinearLayout(@+id/rightSide)[0] should have R.id.yellowView", Helpers.getResourceId(yellowView).equals("yellowView"));
- assertTrue("LinearLayout(@+id/rightSide)[0] should be equal to View(@+id/yellowView)", yellowView == Helpers.findViewByIdString(ta, "yellowView"));
- Drawable yellowViewBackground = yellowView.getBackground();
- assertThat(yellowViewBackground, instanceOf(ColorDrawable.class));
- assertEquals(0xffffff00, ((ColorDrawable) yellowViewBackground).getColor());
-
- View whiteView = rightSide.getChildAt(1);
- assertTrue("LinearLayout(@+id/rightSide)[1] should have R.id.whiteView", Helpers.getResourceId(whiteView).equals("whiteView"));
- assertTrue("LinearLayout(@+id/rightSide)[1] should be equal to View(@+id/whiteView)", whiteView == Helpers.findViewByIdString(ta, "whiteView"));
- Drawable whiteViewBackground = whiteView.getBackground();
- assertThat(whiteViewBackground, instanceOf(ColorDrawable.class));
- assertEquals(0xffffffff, ((ColorDrawable) whiteViewBackground).getColor());
-
- View blueView = rightSide.getChildAt(2);
- assertTrue("LinearLayout(@+id/rightSide)[2] should have R.id.blueView", Helpers.getResourceId(blueView).equals("blueView"));
- assertTrue("LinearLayout(@+id/rightSide)[2] should be equal to View(@+id/blueView)", blueView == Helpers.findViewByIdString(ta, "blueView"));
- Drawable blueViewBackground = blueView.getBackground();
- assertThat(blueViewBackground, instanceOf(ColorDrawable.class));
- assertEquals(0xff0000ff, ((ColorDrawable) blueViewBackground).getColor());
-
- assertEquals("View(@+id/redView) should have layout_weight='40'", 40, ((LinearLayout.LayoutParams) redView.getLayoutParams()).weight, 0.01);
- assertEquals("View(@+id/greenView) should have layout_weight='60'", 60, ((LinearLayout.LayoutParams) greenView.getLayoutParams()).weight, 0.01);
- assertEquals("View(@+id/yellowView) should have layout_weight='33'", 33, ((LinearLayout.LayoutParams) yellowView.getLayoutParams()).weight, 0.01);
- assertEquals("View(@+id/whiteView) should have layout_weight='44'", 44, ((LinearLayout.LayoutParams) whiteView.getLayoutParams()).weight, 0.01);
- assertEquals("View(@+id/blueView) should have layout_weight='22'", 22, ((LinearLayout.LayoutParams) blueView.getLayoutParams()).weight, 0.01);
-
- assertEquals("View(@+id/redView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) redView.getLayoutParams()).height);
- assertEquals("View(@+id/greenView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) greenView.getLayoutParams()).height);
- assertEquals("View(@+id/yellowView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) yellowView.getLayoutParams()).height);
- assertEquals("View(@+id/whiteView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) whiteView.getLayoutParams()).height);
- assertEquals("View(@+id/blueView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) blueView.getLayoutParams()).height);
+ @Test
+ public void test07FixTileActivityLayout() throws Exception {
+ TileActivity ta = Robolectric.buildActivity(TileActivity.class).setup().get();
+ LinearLayout taLayout = (LinearLayout) ta.findViewById(R.id.activity_tile);
+
+ assertTrue("LinearLayout(@+id/activity_tile) should have a horizontal orientation",
+ taLayout.getOrientation() == LinearLayout.HORIZONTAL);
+
+ assertTrue("LinearLayout(@+id/activity_tile)[0] should be a LinearLayout", taLayout.getChildAt(0) instanceof LinearLayout);
+ LinearLayout leftSide = (LinearLayout) taLayout.getChildAt(0);
+ assertTrue("LinearLayout(@+id/activity_tile)[0] should have R.id.leftSide", Helpers.getResourceId(leftSide).equals("leftSide"));
+ assertTrue("LinearLayout(@+id/activity_tile)[0] should be equal to LinearLayout(@+id/leftSide)", leftSide == Helpers.findViewByIdString(ta, "leftSide"));
+ assertTrue("LinearLayout(@+id/activity_tile)[0] should have a vertical orientation",
+ leftSide.getOrientation() == LinearLayout.VERTICAL);
+ assertEquals("View(@+id/leftSide) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) leftSide.getLayoutParams()).weight, 0.01);
+
+ assertTrue("LinearLayout(@+id/activity_tile)[1] should be a LinearLayout", taLayout.getChildAt(1) instanceof LinearLayout);
+ LinearLayout rightSide = (LinearLayout) taLayout.getChildAt(1);
+ assertTrue("LinearLayout(@+id/activity_tile)[1] should have R.id.rightSide", Helpers.getResourceId(rightSide).equals("rightSide"));
+ assertTrue("LinearLayout(@+id/activity_tile)[1] should be equal to LinearLayout(@+id/rightSide)", rightSide == Helpers.findViewByIdString(ta, "rightSide"));
+ assertTrue("LinearLayout(@+id/activity_tile)[1] should have a vertical orientation",
+ rightSide.getOrientation() == LinearLayout.VERTICAL);
+ assertEquals("View(@+id/rightSide) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) rightSide.getLayoutParams()).weight, 0.01);
+
+
+ View redView = leftSide.getChildAt(0);
+ assertTrue("LinearLayout(@+id/leftSide)[0] should have R.id.redView", Helpers.getResourceId(redView).equals("redView"));
+ assertTrue("LinearLayout(@+id/leftSide)[0] should be equal to View(@+id/redView)", redView == Helpers.findViewByIdString(ta, "redView"));
+ Drawable redViewBackground = redView.getBackground();
+ assertThat(redViewBackground, instanceOf(ColorDrawable.class));
+ assertEquals(0xffff0000, ((ColorDrawable) redViewBackground).getColor());
+
+ View greenView = leftSide.getChildAt(1);
+ assertTrue("LinearLayout(@+id/leftSide)[1] should have R.id.greenView", Helpers.getResourceId(greenView).equals("greenView"));
+ assertTrue("LinearLayout(@+id/leftSide)[1] should be equal to View(@+id/greenView)", greenView == Helpers.findViewByIdString(ta, "greenView"));
+ Drawable greenViewBackground = greenView.getBackground();
+ assertThat(greenViewBackground, instanceOf(ColorDrawable.class));
+ assertEquals(0xff00ff00, ((ColorDrawable) greenViewBackground).getColor());
+
+ View yellowView = rightSide.getChildAt(0);
+ assertTrue("LinearLayout(@+id/rightSide)[0] should have R.id.yellowView", Helpers.getResourceId(yellowView).equals("yellowView"));
+ assertTrue("LinearLayout(@+id/rightSide)[0] should be equal to View(@+id/yellowView)", yellowView == Helpers.findViewByIdString(ta, "yellowView"));
+ Drawable yellowViewBackground = yellowView.getBackground();
+ assertThat(yellowViewBackground, instanceOf(ColorDrawable.class));
+ assertEquals(0xffffff00, ((ColorDrawable) yellowViewBackground).getColor());
+
+ View whiteView = rightSide.getChildAt(1);
+ assertTrue("LinearLayout(@+id/rightSide)[1] should have R.id.whiteView", Helpers.getResourceId(whiteView).equals("whiteView"));
+ assertTrue("LinearLayout(@+id/rightSide)[1] should be equal to View(@+id/whiteView)", whiteView == Helpers.findViewByIdString(ta, "whiteView"));
+ Drawable whiteViewBackground = whiteView.getBackground();
+ assertThat(whiteViewBackground, instanceOf(ColorDrawable.class));
+ assertEquals(0xffffffff, ((ColorDrawable) whiteViewBackground).getColor());
+
+ View blueView = rightSide.getChildAt(2);
+ assertTrue("LinearLayout(@+id/rightSide)[2] should have R.id.blueView", Helpers.getResourceId(blueView).equals("blueView"));
+ assertTrue("LinearLayout(@+id/rightSide)[2] should be equal to View(@+id/blueView)", blueView == Helpers.findViewByIdString(ta, "blueView"));
+ Drawable blueViewBackground = blueView.getBackground();
+ assertThat(blueViewBackground, instanceOf(ColorDrawable.class));
+ assertEquals(0xff0000ff, ((ColorDrawable) blueViewBackground).getColor());
+
+ assertEquals("View(@+id/redView) should have layout_weight='40'", 40, ((LinearLayout.LayoutParams) redView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/greenView) should have layout_weight='60'", 60, ((LinearLayout.LayoutParams) greenView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/yellowView) should have layout_weight='33'", 33, ((LinearLayout.LayoutParams) yellowView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/whiteView) should have layout_weight='44'", 44, ((LinearLayout.LayoutParams) whiteView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/blueView) should have layout_weight='22'", 22, ((LinearLayout.LayoutParams) blueView.getLayoutParams()).weight, 0.01);
+
+ assertEquals("View(@+id/redView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) redView.getLayoutParams()).height);
+ assertEquals("View(@+id/greenView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) greenView.getLayoutParams()).height);
+ assertEquals("View(@+id/yellowView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) yellowView.getLayoutParams()).height);
+ assertEquals("View(@+id/whiteView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) whiteView.getLayoutParams()).height);
+ assertEquals("View(@+id/blueView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) blueView.getLayoutParams()).height);
- }
-}
+ }
+ }
\ No newline at end of file