Java Code Examples for org.robolectric.android.controller.ActivityController#restart()

The following examples show how to use org.robolectric.android.controller.ActivityController#restart() . 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: TransactionViewActivityTest.java    From budget-watch with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void startAsEditNoReceiptCheckValueWithLocale() throws IOException
{
    ActivityController activityController = setupActivity("budget", "", false, true);
    Activity activity = (Activity)activityController.get();

    for(String locale : ImmutableList.of(
            "en",  // 100.10
            "nl")) // 100,10
    {
        System.out.println("Using locale: " + locale);
        Locale.setDefault(new Locale(locale));

        activityController.pause();
        activityController.restart();
        activityController.resume();

        EditText value = (EditText)activity.findViewById(R.id.valueEdit);

        assertEquals("100.10", value.getText().toString());
    }
}
 
Example 2
Source File: TestActivityTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void testActivityLifecycle() {
    ActivityController<TestActivity> activityController =
            Robolectric.buildActivity(TestActivity.class);
    TestActivity testActivity = activityController.get();
    Assert.assertNull(testActivity.getLifeCycleStatus());

    activityController.create();
    Assert.assertEquals("onCreate", testActivity.getLifeCycleStatus());

    activityController.start();
    Assert.assertEquals("onStart", testActivity.getLifeCycleStatus());

    activityController.resume();
    Assert.assertEquals("onResume", testActivity.getLifeCycleStatus());

    activityController.pause();
    Assert.assertEquals("onPause", testActivity.getLifeCycleStatus());

    activityController.stop();
    Assert.assertEquals("onStop", testActivity.getLifeCycleStatus());

    activityController.restart();
    Assert.assertEquals("onStart", testActivity.getLifeCycleStatus());

    activityController.destroy();
    Assert.assertEquals("onDestroy", testActivity.getLifeCycleStatus());
}