Java 类org.robolectric.util.FragmentTestUtil 实例源码

项目:lmis-moz-mobile    文件:SimpleDialogFragmentTest.java   
@Test
public void shouldSetCallBack() {
    SimpleDialogFragment fragment = SimpleDialogFragment.newInstance(
            "title",
            "message",
            "btn_positive",
            "btn_negative",
            "onBackPressed");

    SimpleDialogFragment.MsgDialogCallBack dialogCallBack = mock(SimpleDialogFragment.MsgDialogCallBack.class);
    fragment.setCallBackListener(dialogCallBack);
    FragmentTestUtil.startFragment(fragment);

    Dialog dialog = fragment.getDialog();
    (((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE)).performClick();
    verify(dialogCallBack).positiveClick(anyString());
}
项目:RxLifeCycle    文件:RxFragmentLifecycleTest.java   
private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
    Fragment fragment = (Fragment) provider;
    FragmentTestUtil.startFragment(fragment);

    TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();

    fragment.onAttach(null);
    fragment.onCreate(null);
    fragment.onViewCreated(null, null);
    fragment.onStart();
    fragment.onResume();
    fragment.onPause();
    fragment.onStop();
    fragment.onDestroyView();
    fragment.onDestroy();
    fragment.onDetach();

    testObserver.assertValues(
        FragmentEvent.ATTACH,
        FragmentEvent.CREATE,
        FragmentEvent.CREATE_VIEW,
        FragmentEvent.START,
        FragmentEvent.RESUME,
        FragmentEvent.PAUSE,
        FragmentEvent.STOP,
        FragmentEvent.DESTROY_VIEW,
        FragmentEvent.DESTROY,
        FragmentEvent.DETACH
    );
}
项目:lmis-moz-mobile    文件:KitStockCardListFragmentTest.java   
@Before
public void setUp() throws Exception {
    mockStockCardPresenter = mock(StockCardPresenter.class);
    RoboGuice.overrideApplicationInjector(RuntimeEnvironment.application, new AbstractModule() {
        @Override
        protected void configure() {
            bind(StockCardPresenter.class).toInstance(mockStockCardPresenter);
        }
    });
    fragment = new KitStockCardListFragment();
    FragmentTestUtil.startFragment(fragment);
}
项目:lmis-moz-mobile    文件:SyncDateBottomSheetTest.java   
@Before
public void setUp() throws Exception {
    presenter = mock(SyncErrorsPresenter.class);
    RoboGuice.overrideApplicationInjector(RuntimeEnvironment.application, new AbstractModule() {
        @Override
        protected void configure() {
            bind(SyncErrorsPresenter.class).toInstance(presenter);
        }
    });

    fragment = new SyncDateBottomSheet();
    fragment.setArguments(SyncDateBottomSheet.getArgumentsToMe(1, 1));
    FragmentTestUtil.startFragment(fragment);
}
项目:openwebnet-android    文件:GatewayEditTextPreferenceTest.java   
private void setupDialog() {
    when(utilityService.isBlankText(any(TextView.class))).thenCallRealMethod();
    when(utilityService.sanitizedText(any(TextView.class))).thenCallRealMethod();

    SettingsFragment settingsFragment = new SettingsFragment();
    FragmentTestUtil.startVisibleFragment(settingsFragment);
    assertNotNull("fragment is null", settingsFragment);
    PreferenceScreen preferenceScreen = settingsFragment.getPreferenceScreen();
    initGatewayEditTextPreference(preferenceScreen);

    // TODO
    //gatewayEditTextPreference.onClick();
    assertTrue("should be visible", gatewayEditTextPreference.getDialog().isShowing());
}
项目:android-uploader    文件:SettingsActivityTest.java   
private PreferenceFragment setUpPreferenceFragment(Class<? extends PreferenceFragment> clazz) {
    PreferenceFragment instance;
    try {
         instance = clazz.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
    FragmentTestUtil.startVisibleFragment(instance);
    return instance;
}
项目:open    文件:MapFragmentTest.java   
@Test
public void showProgress_shouldDisableMap() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    mapFragment.getView().findViewById(R.id.map).setClickable(true);
    mapFragment.showProgress();
    assertThat(mapFragment.getView().findViewById(R.id.map)).isNotClickable();
}
项目:open    文件:MapFragmentTest.java   
@Test
public void hideProgress_shouldHideProgressView() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    mapFragment.showProgress();
    mapFragment.hideProgress();
    assertThat(mapFragment.getView().findViewById(R.id.progress)).isNotVisible();
}
项目:open    文件:MapFragmentTest.java   
@Test
public void hideProgress_shouldEnableMap() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    mapFragment.getView().findViewById(R.id.map).setClickable(false);
    mapFragment.hideProgress();
    assertThat(mapFragment.getView().findViewById(R.id.map)).isClickable();
}
项目:open    文件:MapFragmentTest.java   
@Test
public void findMe_shouldNotResetZoomAndPointNorthAfterMapPositionEvent() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    mapFragment.findMe();
    MapPosition mapPosition = new MapPosition();
    mapPosition.setZoomLevel(10);
    activity.getMap().events.fire(Map.POSITION_EVENT, mapPosition);
    mapFragment.findMe();
    assertThat(mapFragment.mapController.getZoomLevel()).isEqualTo(10);
}
项目:CAS2016    文件:RosieFragmentTest.java   
private TestFragment startFragment() {
  TestFragment testFragment = new TestFragment();
  FragmentTestUtil.startFragment(testFragment, FakeActivity.class);
  return testFragment;
}
项目:open    文件:MapFragmentTest.java   
@Test
public void showProgress_shouldShowProgressView() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    mapFragment.showProgress();
    assertThat(mapFragment.getView().findViewById(R.id.progress)).isVisible();
}
项目:open    文件:MapFragmentTest.java   
@Test
public void onActivityCreated_shouldDoStylesheetDownload() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    Mockito.verify(styleDownLoader).download();
}
项目:open    文件:RouteFragmentTest.java   
private void loadAceHotelMockRoute() {
    fragment.success(new Route(MOCK_ACE_HOTEL));
    FragmentTestUtil.startFragment(fragment);
    fragment.onResume();
}