Java Code Examples for org.robolectric.shadows.support.v4.SupportFragmentTestUtil#startFragment()
The following examples show how to use
org.robolectric.shadows.support.v4.SupportFragmentTestUtil#startFragment() .
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: MvvmDialogFragmentTest.java From android-mvvm with Apache License 2.0 | 6 votes |
@Test public void testRemoveOnPropertyChangedCallbacksOnActivityDestroy() { final Observable.OnPropertyChangedCallback firstCallback = mock(Observable.OnPropertyChangedCallback.class); final Observable.OnPropertyChangedCallback secondCallback = mock(Observable.OnPropertyChangedCallback.class); fragment.setViewModel(fragment.createViewModel()); fragment.addOnPropertyChangedCallback(firstCallback); fragment.addOnPropertyChangedCallback(secondCallback); SupportFragmentTestUtil.startFragment(fragment); fragment.onDestroy(); verify(fragment.getViewModel()).removeOnPropertyChangedCallback(firstCallback); verify(fragment.getViewModel()).removeOnPropertyChangedCallback(secondCallback); }
Example 2
Source File: DeviceListFragmentTest.java From openwebnet-android with MIT License | 6 votes |
private void setupFragment(int environment) { List<EnvironmentModel> environments = Lists.newArrayList( newEnvironmentModel(123, "A-environment"), newEnvironmentModel(environment, "B-environment"), newEnvironmentModel(10, "C-environment"), newEnvironmentModel(789, "D-environment")); when(environmentService.findAll()).thenReturn(Observable.just(environments)); DeviceListFragment fragment = new DeviceListFragment(); Bundle args = new Bundle(); args.putInt(ARG_ENVIRONMENT, environment); fragment.setArguments(args); SupportFragmentTestUtil.startFragment(fragment); assertNotNull("should not be null", fragment); }
Example 3
Source File: MvvmFragmentTest.java From android-mvvm with Apache License 2.0 | 5 votes |
@Test public void testOnSaveInstanceStateDelegated() { SupportFragmentTestUtil.startFragment(fragment); final Bundle testBundle = new Bundle(); fragment.onSaveInstanceState(testBundle); verify(fragment.getMvvmDelegate()).onSaveInstanceState(testBundle); }
Example 4
Source File: MvvmFragmentTest.java From android-mvvm with Apache License 2.0 | 5 votes |
@Test public void testRemoveOnPropertyChangedCallbacksOnActivityDestroy() { final Observable.OnPropertyChangedCallback firstCallback = mock(Observable.OnPropertyChangedCallback.class); final Observable.OnPropertyChangedCallback secondCallback = mock(Observable.OnPropertyChangedCallback.class); fragment.setViewModel(fragment.createViewModel()); fragment.addOnPropertyChangedCallback(firstCallback); fragment.addOnPropertyChangedCallback(secondCallback); SupportFragmentTestUtil.startFragment(fragment); fragment.onDestroy(); verify(fragment.getViewModel()).removeOnPropertyChangedCallback(firstCallback); verify(fragment.getViewModel()).removeOnPropertyChangedCallback(secondCallback); }
Example 5
Source File: MvvmDialogFragmentTest.java From android-mvvm with Apache License 2.0 | 5 votes |
@Test public void testOnSaveInstanceStateDelegated() { SupportFragmentTestUtil.startFragment(fragment); final Bundle testBundle = new Bundle(); fragment.onSaveInstanceState(testBundle); verify(fragment.getMvvmDelegate()).onSaveInstanceState(testBundle); }
Example 6
Source File: MvvmFragmentTest.java From android-mvvm with Apache License 2.0 | 4 votes |
@Test public void testStartMethodsDelegated() { SupportFragmentTestUtil.startFragment(fragment); verify(fragment.getMvvmDelegate()).onCreate(null); verify(fragment.getMvvmDelegate()).onResume(); }
Example 7
Source File: MvvmFragmentTest.java From android-mvvm with Apache License 2.0 | 4 votes |
@Test public void testOnPauseDelegated() { SupportFragmentTestUtil.startFragment(fragment); fragment.onPause(); verify(fragment.getMvvmDelegate()).onPause(); }
Example 8
Source File: MvvmFragmentTest.java From android-mvvm with Apache License 2.0 | 4 votes |
@Test public void testOnDestroyDelegated() { SupportFragmentTestUtil.startFragment(fragment); fragment.onDestroy(); verify(fragment.getMvvmDelegate()).onDestroy(); }
Example 9
Source File: MvvmDialogFragmentTest.java From android-mvvm with Apache License 2.0 | 4 votes |
@Test public void testStartMethodsDelegated() { SupportFragmentTestUtil.startFragment(fragment); verify(fragment.getMvvmDelegate()).onCreate(null); verify(fragment.getMvvmDelegate()).onResume(); }
Example 10
Source File: MvvmDialogFragmentTest.java From android-mvvm with Apache License 2.0 | 4 votes |
@Test public void testOnPauseDelegated() { SupportFragmentTestUtil.startFragment(fragment); fragment.onPause(); verify(fragment.getMvvmDelegate()).onPause(); }
Example 11
Source File: MvvmDialogFragmentTest.java From android-mvvm with Apache License 2.0 | 4 votes |
@Test public void testOnDestroyDelegated() { SupportFragmentTestUtil.startFragment(fragment); fragment.onDestroy(); verify(fragment.getMvvmDelegate()).onDestroy(); }