use of org.robolectric.shadows.ShadowActivity in project prebid-mobile-android by prebid.
the class AutoDetectedOpenRtbTest method setup.
@Before
public void setup() {
mActivity = Robolectric.buildActivity(Activity.class).create().get();
ShadowActivity shadowActivity = shadowOf(mActivity);
shadowActivity.grantPermissions("android.permission.ACCESS_FINE_LOCATION");
LocationManager locationManager = (LocationManager) mActivity.getSystemService(Context.LOCATION_SERVICE);
ShadowLocationManager shadowLocationManager = shadowOf(locationManager);
Location location = new Location("");
location.setLatitude(1);
location.setLongitude(1);
shadowLocationManager.setLastKnownLocation("gps", location);
ShadowTelephonyManager shadowTelephonyManager = shadowOf((TelephonyManager) mActivity.getSystemService(Context.TELEPHONY_SERVICE));
shadowTelephonyManager.setNetworkOperatorName("carrier");
shadowTelephonyManager.setNetworkOperator("carrier");
ManagersResolver.getInstance().prepare(mActivity);
mParamBuilderArray = new ArrayList<>();
mOriginalAdRequestInput = new AdRequestInput();
mOriginalOpenRtbParams = new BidRequest();
}
use of org.robolectric.shadows.ShadowActivity in project prebid-mobile-android by prebid.
the class MraidCalendarEventTest method testCreateCalendarEvent.
@Test
public void testCreateCalendarEvent() {
BaseJSInterface mockJs = mock(BaseJSInterface.class);
MraidCalendarEvent event = new MraidCalendarEvent(mockJs);
event.createCalendarEvent(mCalendarParameters);
ShadowActivity shadowActivity = shadowOf(mTestActivity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertFalse("somecrap.calendar/event".equals(startedIntent.getType()));
assertEquals("vnd.android.cursor.item/event", startedIntent.getType());
assertFalse("fail.event.type".equals(startedIntent.getType()));
assertEquals("", startedIntent.getExtras().get(CalendarContract.Events.TITLE));
assertTrue(startedIntent.getExtras().get(CalendarContract.Events.DESCRIPTION).equals("mayanApocalypse/End of world"));
}
use of org.robolectric.shadows.ShadowActivity in project prebid-mobile-android by prebid.
the class BaseJSInterfaceTest method whenGetLocationAndLocationAvailable_ReturnLocationJson.
@Test
public void whenGetLocationAndLocationAvailable_ReturnLocationJson() throws JSONException {
ShadowActivity shadowActivity = shadowOf(mTestActivity);
shadowActivity.grantPermissions("android.permission.ACCESS_FINE_LOCATION");
LocationManager locationManager = (LocationManager) mTestActivity.getSystemService(Context.LOCATION_SERVICE);
ShadowLocationManager shadowLocationManager = shadowOf(locationManager);
Location location = new Location("");
location.setLatitude(1.0);
location.setLongitude(2.0);
location.setAccuracy(3F);
location.setTime(System.currentTimeMillis() - 4000);
shadowLocationManager.setLastKnownLocation("gps", location);
ManagersResolver.getInstance().dispose();
ManagersResolver.getInstance().prepare(mTestActivity);
JSONObject locationJson = new JSONObject();
locationJson.put(LOCATION_LAT, 1.0);
locationJson.put(LOCATION_LON, 2.0);
locationJson.put(LOCATION_TYPE, 1);
locationJson.put(LOCATION_ACCURACY, 3F);
locationJson.put(LOCATION_LASTFIX, (long) 4);
assertEquals(locationJson.toString(), mSpyBaseJSInterface.getLocation());
}
use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by crdroidandroid.
the class ChooseLockSettingsHelperTest method testLaunchConfirmationActivityWithExternalAndChallenge.
@Test
public void testLaunchConfirmationActivityWithExternalAndChallenge() {
final int userId = UserHandle.myUserId();
final int request = 100;
final long challenge = 10000L;
final Activity activity = Robolectric.setupActivity(Activity.class);
ChooseLockSettingsHelper helper = getChooseLockSettingsHelper(activity);
helper.launchConfirmationActivityWithExternalAndChallenge(// request
request, "title", "header", "description", // external
true, challenge, userId);
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertEquals(new ComponentName("com.android.settings", ConfirmLockPattern.InternalActivity.class.getName()), startedIntent.getComponent());
assertFalse(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_RETURN_CREDENTIALS, false));
assertTrue(startedIntent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false));
assertEquals(challenge, startedIntent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L));
assertEquals(true, (startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
assertEquals(true, startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, false));
assertEquals(true, startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
assertEquals(true, startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, false));
assertEquals(true, startedIntent.getBooleanExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, false));
}
use of org.robolectric.shadows.ShadowActivity in project android_packages_apps_Settings by crdroidandroid.
the class FingerprintEnrollFindSensorTest method clickSkip_shouldReturnResultSkip.
@Test
public void clickSkip_shouldReturnResultSkip() {
Button skipButton = mActivity.findViewById(R.id.skip_button);
skipButton.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
assertThat(shadowActivity.getResultCode()).named("result code").isEqualTo(FingerprintEnrollBase.RESULT_SKIP);
}
Aggregations