package com.example.activity;

import android.app.Activity;
import android.content.Intent;
import android.widget.ListView;
import com.example.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowListView;

import static org.assertj.core.api.Assertions.assertThat;
import static org.robolectric.Robolectric.shadowOf;

@RunWith(RobolectricTestRunner.class)
public class MainActivityTest {
  private Activity subject;

  @Before
  public void setUp() throws Exception {
    subject = Robolectric.setupActivity(MainActivity.class);
  }

  @Test
  public void itHasAllThePeopleOfTheWestWing() throws Exception {
    ListView listView = (ListView) subject.findViewById(R.id.list_view);
    shadowOf(listView).populateItems();

    assertThat(listView.getChildCount()).isEqualTo(MainActivity.westWingers.size());
  }

  @Test
  public void whenIClickOnAPersonIAmTakenToTheirPage() {
    ListView listView = (ListView) subject.findViewById(R.id.list_view);
    ShadowListView shadowListView = shadowOf(listView);
    shadowListView.populateItems();

    shadowListView.performHapticFeedback(0);

    Intent nextStartedActivity = shadowOf(subject).getNextStartedActivity();
    assertThat(nextStartedActivity.getComponent()).isEqualTo(PeopleActivity.class);
  }
}

@@ -116,16 +116,48 @@
 stView;%0A
+import android.widget.TextView;%0A
 import c
@@ -170,16 +170,16 @@
 mple.R;%0A
-
 import o
@@ -736,55 +736,39 @@
 d it
-HasAllThePeopleOfTheWestWing() throws Exception
+PopulatesEachViewWithTheNames()
  %7B%0A 
@@ -965,16 +965,230 @@
 ize());%0A
+    for (int i = 0; i %3C listView.getChildCount(); i++) %7B%0A      TextView childAt = (TextView) listView.getChildAt(i);%0A      assertThat(childAt.getText().toString()).isEqualTo(MainActivity.westWingers.get(i));%0A    %7D%0A
   %7D%0A%0A  @
@@ -1445,20 +1445,15 @@
 form
-HapticFeedba
+ItemCli
 ck(0

add text validation