org.robolectric.util.FragmentTestUtil Java Examples

The following examples show how to use org.robolectric.util.FragmentTestUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GatewayEditTextPreferenceTest.java    From openwebnet-android with MIT License 5 votes vote down vote up
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());
}
 
Example #2
Source File: RxFragmentLifecycleTest.java    From RxLifecycle with Apache License 2.0 5 votes vote down vote up
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
    );
}
 
Example #3
Source File: MapFragmentTest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
@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();
}
 
Example #4
Source File: MapFragmentTest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void hideProgress_shouldHideProgressView() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    mapFragment.showProgress();
    mapFragment.hideProgress();
    assertThat(mapFragment.getView().findViewById(R.id.progress)).isNotVisible();
}
 
Example #5
Source File: MapFragmentTest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
@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();
}
 
Example #6
Source File: MapFragmentTest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: PolicyManagementFragmentTest.java    From android-testdpc with Apache License 2.0 4 votes vote down vote up
private void relaunchWithTaskMode(int lockTaskModeState) {
  shadowOf(mContext.getSystemService(ActivityManager.class))
      .setLockTaskModeState(lockTaskModeState);
  FragmentTestUtil.startFragment(mPolicyFragment);
}
 
Example #8
Source File: MapFragmentTest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void showProgress_shouldShowProgressView() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    mapFragment.showProgress();
    assertThat(mapFragment.getView().findViewById(R.id.progress)).isVisible();
}
 
Example #9
Source File: MapFragmentTest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void onActivityCreated_shouldDoStylesheetDownload() throws Exception {
    FragmentTestUtil.startFragment(mapFragment);
    Mockito.verify(styleDownLoader).download();
}
 
Example #10
Source File: RouteFragmentTest.java    From open with GNU General Public License v3.0 4 votes vote down vote up
private void loadAceHotelMockRoute() {
    fragment.success(new Route(MOCK_ACE_HOTEL));
    FragmentTestUtil.startFragment(fragment);
    fragment.onResume();
}