org.robolectric.annotation.LooperMode Java Examples

The following examples show how to use org.robolectric.annotation.LooperMode. 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: NavigationSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnCreate() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create();
    TestActivity activity = controller.get();
    SceneDelegate sceneDelegate = NavigationSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    NavigationScene navigationScene = sceneDelegate.getNavigationScene();
    assertNotNull(navigationScene);

    assertEquals(State.NONE, navigationScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.ACTIVITY_CREATED, navigationScene.getState());

    controller.start();
    assertEquals(State.STARTED, navigationScene.getState());
    controller.resume();
    assertEquals(State.RESUMED, navigationScene.getState());
    controller.pause();
    assertEquals(State.STARTED, navigationScene.getState());
    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, navigationScene.getState());
    controller.destroy();
    assertEquals(State.NONE, navigationScene.getState());
}
 
Example #2
Source File: NavigationSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnStart() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start();
    TestActivity activity = controller.get();
    SceneDelegate sceneDelegate = NavigationSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    NavigationScene navigationScene = sceneDelegate.getNavigationScene();
    assertNotNull(navigationScene);

    assertEquals(State.NONE, navigationScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.STARTED, navigationScene.getState());

    controller.resume();
    assertEquals(State.RESUMED, navigationScene.getState());
    controller.pause();
    assertEquals(State.STARTED, navigationScene.getState());
    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, navigationScene.getState());
    controller.destroy();
    assertEquals(State.NONE, navigationScene.getState());
}
 
Example #3
Source File: NavigationSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnResume() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume();
    TestActivity activity = controller.get();
    SceneDelegate sceneDelegate = NavigationSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    NavigationScene navigationScene = sceneDelegate.getNavigationScene();
    assertNotNull(navigationScene);

    assertEquals(State.NONE, navigationScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.RESUMED, navigationScene.getState());

    controller.pause();
    assertEquals(State.STARTED, navigationScene.getState());
    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, navigationScene.getState());
    controller.destroy();
    assertEquals(State.NONE, navigationScene.getState());
}
 
Example #4
Source File: NavigationSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnPause() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume().pause();
    TestActivity activity = controller.get();
    SceneDelegate sceneDelegate = NavigationSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    NavigationScene navigationScene = sceneDelegate.getNavigationScene();
    assertNotNull(navigationScene);

    assertEquals(State.NONE, navigationScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.STARTED, navigationScene.getState());

    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, navigationScene.getState());
    controller.destroy();
    assertEquals(State.NONE, navigationScene.getState());
}
 
Example #5
Source File: GroupSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnCreate() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create();
    TestActivity activity = controller.get();
    GroupSceneDelegate sceneDelegate = GroupSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    GroupScene groupScene = sceneDelegate.getGroupScene();
    assertNotNull(groupScene);

    assertEquals(State.NONE, groupScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.ACTIVITY_CREATED, groupScene.getState());

    controller.start();
    assertEquals(State.STARTED, groupScene.getState());
    controller.resume();
    assertEquals(State.RESUMED, groupScene.getState());
    controller.pause();
    assertEquals(State.STARTED, groupScene.getState());
    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, groupScene.getState());
    controller.destroy();
    assertEquals(State.NONE, groupScene.getState());
}
 
Example #6
Source File: GroupSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnStart() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start();
    TestActivity activity = controller.get();
    GroupSceneDelegate sceneDelegate = GroupSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    GroupScene groupScene = sceneDelegate.getGroupScene();
    assertNotNull(groupScene);

    assertEquals(State.NONE, groupScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.STARTED, groupScene.getState());

    controller.resume();
    assertEquals(State.RESUMED, groupScene.getState());
    controller.pause();
    assertEquals(State.STARTED, groupScene.getState());
    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, groupScene.getState());
    controller.destroy();
    assertEquals(State.NONE, groupScene.getState());
}
 
Example #7
Source File: GroupSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnResume() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume();
    TestActivity activity = controller.get();
    GroupSceneDelegate sceneDelegate = GroupSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    GroupScene groupScene = sceneDelegate.getGroupScene();
    assertNotNull(groupScene);

    assertEquals(State.NONE, groupScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.RESUMED, groupScene.getState());

    controller.pause();
    assertEquals(State.STARTED, groupScene.getState());
    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, groupScene.getState());
    controller.destroy();
    assertEquals(State.NONE, groupScene.getState());
}
 
Example #8
Source File: GroupSceneUtilityTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnPause() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume().pause();
    TestActivity activity = controller.get();
    GroupSceneDelegate sceneDelegate = GroupSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    GroupScene groupScene = sceneDelegate.getGroupScene();
    assertNotNull(groupScene);

    assertEquals(State.NONE, groupScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.STARTED, groupScene.getState());

    controller.stop();
    assertEquals(State.ACTIVITY_CREATED, groupScene.getState());
    controller.destroy();
    assertEquals(State.NONE, groupScene.getState());
}
 
Example #9
Source File: NavigationSceneUtilityTests.java    From scene with Apache License 2.0 5 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnStop() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume().pause().stop();
    TestActivity activity = controller.get();
    SceneDelegate sceneDelegate = NavigationSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    NavigationScene navigationScene = sceneDelegate.getNavigationScene();
    assertNotNull(navigationScene);

    assertEquals(State.NONE, navigationScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.ACTIVITY_CREATED, navigationScene.getState());
    controller.destroy();
    assertEquals(State.NONE, navigationScene.getState());
}
 
Example #10
Source File: NavigationSceneUtilityTests.java    From scene with Apache License 2.0 5 votes vote down vote up
@Config(minSdk = Build.VERSION_CODES.JELLY_BEAN_MR1, maxSdk = Build.VERSION_CODES.P)
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnDestroy() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume().pause().stop().destroy();
    TestActivity activity = controller.get();
    SceneDelegate sceneDelegate = NavigationSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    NavigationScene navigationScene = sceneDelegate.getNavigationScene();
    assertNotNull(navigationScene);

    assertEquals(State.NONE, navigationScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.NONE, navigationScene.getState());
}
 
Example #11
Source File: GroupSceneUtilityTests.java    From scene with Apache License 2.0 5 votes vote down vote up
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnStop() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume().pause().stop();
    TestActivity activity = controller.get();
    GroupSceneDelegate sceneDelegate = GroupSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    GroupScene groupScene = sceneDelegate.getGroupScene();
    assertNotNull(groupScene);

    assertEquals(State.NONE, groupScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.ACTIVITY_CREATED, groupScene.getState());
    controller.destroy();
    assertEquals(State.NONE, groupScene.getState());
}
 
Example #12
Source File: GroupSceneUtilityTests.java    From scene with Apache License 2.0 5 votes vote down vote up
@Config(minSdk = Build.VERSION_CODES.JELLY_BEAN_MR1, maxSdk = Build.VERSION_CODES.P)
@LooperMode(PAUSED)
@Test
public void testNotImmediateSetupInActivityOnDestroy() {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume().pause().stop().destroy();
    TestActivity activity = controller.get();
    GroupSceneDelegate sceneDelegate = GroupSceneUtility.setupWithActivity(activity, TestScene.class).immediate(false).build();
    GroupScene groupScene = sceneDelegate.getGroupScene();
    assertNotNull(groupScene);

    assertEquals(State.NONE, groupScene.getState());
    shadowOf(getMainLooper()).idle();//execute Handler posted task
    assertEquals(State.NONE, groupScene.getState());
}