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

The following examples show how to use org.robolectric.android.controller.ActivityController#recreate() . 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: GuidanceSpeedLimitViewTest.java    From msdkui-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataIsNotLostWhileRecreatingActivity() {
    final GuidanceSpeedData data = new GuidanceSpeedData(VELOCITY, SPEED_LIMIT);
    final ActivityController<FragmentActivity> activityController = getActivityController();

    // when data is not null
    mGuidanceSpeedLimitView.setCurrentSpeedData(data);
    assertNotNull(mGuidanceSpeedLimitView.getCurrentSpeedData());
    mGuidanceSpeedLimitView.setId(1);
    activityController.get().setContentView(mGuidanceSpeedLimitView);
    activityController.recreate();
    assertNotNull(mGuidanceSpeedLimitView.getCurrentSpeedData());

    // when data is null
    mGuidanceSpeedLimitView.setCurrentSpeedData(null);
    assertNull(mGuidanceSpeedLimitView.getCurrentSpeedData());
    mGuidanceSpeedLimitView.setId(1);
    activityController.recreate();
    assertNull(mGuidanceSpeedLimitView.getCurrentSpeedData());
}
 
Example 2
Source File: GuidanceSpeedViewTest.java    From msdkui-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testDataIsNotLostWhileRecreatingActivity() {
    final GuidanceSpeedData data = new GuidanceSpeedData(VELOCITY, SPEED_LIMIT);
    final ActivityController<FragmentActivity> activityController = getActivityController();

    // when data is not null
    mCurrentGuidanceSpeedView.setCurrentSpeedData(data);
    assertNotNull(mCurrentGuidanceSpeedView.getCurrentSpeedData());
    mCurrentGuidanceSpeedView.setId(1);
    activityController.get().setContentView(mCurrentGuidanceSpeedView);
    activityController.recreate();
    assertNotNull(mCurrentGuidanceSpeedView.getCurrentSpeedData());

    // when data is null
    mCurrentGuidanceSpeedView.setCurrentSpeedData(null);
    assertNull(mCurrentGuidanceSpeedView.getCurrentSpeedData());
    mCurrentGuidanceSpeedView.setId(1);
    activityController.recreate();
    assertNull(mCurrentGuidanceSpeedView.getCurrentSpeedData());
}
 
Example 3
Source File: GuidanceStreetLabelViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataIsNotLostWhileRecreatingActivity() {
    mGuidanceStreetLabelView.setCurrentStreetData(createData(STREET_NAME, COLOR));
    assertNotNull(mGuidanceStreetLabelView.getGuidanceCurrentStreetData());
    final ActivityController<FragmentActivity> activityController = getActivityController();
    mGuidanceStreetLabelView.setId(1);
    activityController.get().setContentView(mGuidanceStreetLabelView);
    activityController.recreate();
    assertNotNull(mGuidanceStreetLabelView.getGuidanceCurrentStreetData());
}
 
Example 4
Source File: GuidanceManeuverViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataIsNotLostWhileRecreatingActivity() {
    mGuidanceManeuverView.setViewState(new GuidanceManeuverView.State(createData(mIconId, mDistance, mInfo1, mInfo2)));
    assertNotNull(mGuidanceManeuverView.getManeuverData());
    final ActivityController<FragmentActivity> activityController = getActivityController();
    mGuidanceManeuverView.setId(1);
    activityController.get().setContentView(mGuidanceManeuverView);
    activityController.recreate();
    assertNotNull(mGuidanceManeuverView.getManeuverData());
}
 
Example 5
Source File: GuidanceEstimatedArrivalViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataIsNotLostWhileRecreatingActivity() {
    final GuidanceEstimatedArrivalViewData data = new GuidanceEstimatedArrivalViewData(ETA_DATE, DISTANCE, DURATION);
    final ActivityController<FragmentActivity> activityController = getActivityController();

    // when data is not null
    mEstimatedArrivalView.setEstimatedArrivalData(data);
    assertNotNull(mEstimatedArrivalView.getEstimatedArrivalData());
    mEstimatedArrivalView.setId(1);
    activityController.get().setContentView(mEstimatedArrivalView);
    activityController.recreate();
    assertNotNull(mEstimatedArrivalView.getEstimatedArrivalData());
}
 
Example 6
Source File: GuidanceNextManeuverViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataIsNotLostWhileRecreatingActivity() {
    mGuidanceNextManeuverView.setNextManeuverData(createData(mIconId, mDistance, mStreetName));
    assertNotNull(mGuidanceNextManeuverView.getNextManeuverData());
    final ActivityController<FragmentActivity> activityController = getActivityController();
    mGuidanceNextManeuverView.setId(1);
    activityController.get().setContentView(mGuidanceNextManeuverView);
    activityController.recreate();
    assertNotNull(mGuidanceNextManeuverView.getNextManeuverData());
}