Search in sources :

Example 1 with ActivityController

use of org.robolectric.android.controller.ActivityController in project collect by opendatakit.

the class FormMapActivityTest method locationChange_zoomsToCurrentLocation_ifTheViewportWasNotPreviouslyUpdated.

@Test
public void locationChange_zoomsToCurrentLocation_ifTheViewportWasNotPreviouslyUpdated() {
    // The @Before block set up a map with points. Reset everything for this test.
    map.resetState();
    instancesRepository.deleteAll();
    Intent intent = new Intent();
    intent.putExtra(FormMapActivity.EXTRA_FORM_ID, form.getDbId());
    ActivityController controller = CollectHelpers.buildThemedActivity(FormMapActivity.class, intent);
    controller.setup();
    assertThat(map.getZoomCount(), is(0));
    map.onLocationChanged(currentLocation);
    assertThat(map.getZoomCount(), is(1));
    assertThat(map.getLatestZoomPoint(), is(currentLocation));
    assertThat(map.wasLatestZoomCallAnimated(), is(true));
}
Also used : ActivityController(org.robolectric.android.controller.ActivityController) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with ActivityController

use of org.robolectric.android.controller.ActivityController in project collect by opendatakit.

the class FormMapActivityTest method startingFormMap_doesNotZoom_ifThereAreNoInstanceMarkers_andLocationIsUnavailable.

@Test
public void startingFormMap_doesNotZoom_ifThereAreNoInstanceMarkers_andLocationIsUnavailable() {
    // The @Before block set up a map with points. Reset everything for this test.
    map.resetState();
    instancesRepository.deleteAll();
    Intent intent = new Intent();
    intent.putExtra(FormMapActivity.EXTRA_FORM_ID, form.getDbId());
    ActivityController controller = CollectHelpers.buildThemedActivity(FormMapActivity.class, intent);
    controller.setup();
    assertThat(map.getZoomCount(), is(0));
}
Also used : ActivityController(org.robolectric.android.controller.ActivityController) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with ActivityController

use of org.robolectric.android.controller.ActivityController in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FallbackHomeActivityTest method wallpaperColorsChangedListener_ensured_removed.

@Test
@Config(shadows = ShadowWallpaperManager.class)
public void wallpaperColorsChangedListener_ensured_removed() {
    // onCreate adds the first color listener by WallpaperManager returning null colors
    ActivityController controller = mController.setup();
    ShadowWallpaperManager shadowManager = Shadow.extract(RuntimeEnvironment.application.getSystemService(WallpaperManager.class));
    assertThat(shadowManager.size()).isEqualTo(1);
    // Assert onDestroy will remove the original listener
    controller.destroy();
    assertThat(shadowManager.size()).isEqualTo(0);
}
Also used : ActivityController(org.robolectric.android.controller.ActivityController) WallpaperManager(android.app.WallpaperManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 4 with ActivityController

use of org.robolectric.android.controller.ActivityController in project iterable-android-sdk by Iterable.

the class IterableInAppManagerTest method testIfDialogFragmentExistAfterRotation.

@Test
public void testIfDialogFragmentExistAfterRotation() throws Exception {
    ActivityController controller = Robolectric.buildActivity(FragmentActivity.class).create().start().resume();
    FragmentActivity activity = (FragmentActivity) controller.get();
    assertTrue(IterableInAppDisplayer.showIterableFragmentNotificationHTML(activity, "", "", null, 0.0, new Rect(), true, new IterableInAppMessage.InAppBgColor(null, 0.0f), false, IterableInAppLocation.IN_APP));
    shadowOf(getMainLooper()).idle();
    controller.configurationChange();
    assertEquals(1, activity.getSupportFragmentManager().getFragments().size());
    ShadowDialog.getLatestDialog().dismiss();
    controller.pause().stop().destroy();
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) Rect(android.graphics.Rect) ActivityController(org.robolectric.android.controller.ActivityController) Test(org.junit.Test)

Example 5 with ActivityController

use of org.robolectric.android.controller.ActivityController in project android_packages_apps_Settings by omnirom.

the class FallbackHomeActivityTest method wallpaperColorsChangedListener_ensured_removed.

@Test
@Config(shadows = ShadowWallpaperManager.class)
public void wallpaperColorsChangedListener_ensured_removed() {
    // onCreate adds the first color listener by WallpaperManager returning null colors
    ActivityController controller = mController.setup();
    ShadowWallpaperManager shadowManager = Shadow.extract(RuntimeEnvironment.application.getSystemService(WallpaperManager.class));
    assertThat(shadowManager.size()).isEqualTo(1);
    // Assert onDestroy will remove the original listener
    controller.destroy();
    assertThat(shadowManager.size()).isEqualTo(0);
}
Also used : ActivityController(org.robolectric.android.controller.ActivityController) WallpaperManager(android.app.WallpaperManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Test (org.junit.Test)5 ActivityController (org.robolectric.android.controller.ActivityController)5 WallpaperManager (android.app.WallpaperManager)2 Intent (android.content.Intent)2 Config (org.robolectric.annotation.Config)2 Rect (android.graphics.Rect)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1