@Test public void onViewCreated_shouldPopulateAdapter() { Clubs clubs = ModelBuilder.getClubs(4, "Club Name"); mockRestService.addResponse(clubs, true); SupportFragmentTestUtil.startFragment(fragment); assertThat(fragment.adapter.getItemCount()).isEqualTo(4); }
@Before public void setUp() { mActivityController = Robolectric.buildActivity(MainActivity.class).create().start().resume(); mActivity = mActivityController.get(); sut = WordDetailsTranslationFragment.newInstance(TestHelper.createWord(), 1); SupportFragmentTestUtil.startVisibleFragment(sut); }
@Test public void pullToRefresh_refetchesClubs() { SupportFragmentTestUtil.startFragment(fragment); assertThat(fragment.adapter.getItemCount()).isEqualTo(0); Clubs clubs = ModelBuilder.getClubs(4, "Club Name"); mockRestService.addResponse(clubs, true); fragment.onRefresh(); assertThat(fragment.adapter.getItemCount()).isEqualTo(4); }
public void testFragmentsStart() { fragment = new MainActivity.PlaceholderFragment().newInstance(1); assertNotNull("f is null", fragment); SupportFragmentTestUtil.startVisibleFragment(fragment); textView = (TextView) fragment.getView().findViewById(R.id.section_label); assertEquals("Fragment 1", textView.getText().toString()); fragment = new MainActivity.PlaceholderFragment().newInstance(2); assertNotNull("f is null", fragment); SupportFragmentTestUtil.startVisibleFragment(fragment); textView = (TextView) fragment.getView().findViewById(R.id.section_label); assertEquals("Fragment 2", textView.getText().toString()); fragment = new MainActivity.PlaceholderFragment().newInstance(3); assertNotNull("f is null", fragment); SupportFragmentTestUtil.startVisibleFragment(fragment); textView = (TextView) fragment.getView().findViewById(R.id.section_label); assertEquals("Fragment 3", textView.getText().toString()); }