androidx.test.core.app.ApplicationProvider Java Examples

The following examples show how to use androidx.test.core.app.ApplicationProvider. 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: FirebaseSegmentationRegistrarTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Ignore
@Test
public void getFirebaseInstallationsInstance() {
  FirebaseApp defaultApp =
      FirebaseApp.initializeApp(
          ApplicationProvider.getApplicationContext(),
          new FirebaseOptions.Builder().setApplicationId("1:123456789:android:abcdef").build());

  FirebaseApp anotherApp =
      FirebaseApp.initializeApp(
          ApplicationProvider.getApplicationContext(),
          new FirebaseOptions.Builder().setApplicationId("1:987654321:android:abcdef").build(),
          "firebase_app_1");

  FirebaseSegmentation defaultSegmentation = FirebaseSegmentation.getInstance();
  assertNotNull(defaultSegmentation);

  FirebaseSegmentation anotherSegmentation = FirebaseSegmentation.getInstance(anotherApp);
  assertNotNull(anotherSegmentation);
}
 
Example #2
Source File: GodEyeConfigTest.java    From AndroidGodEye with Apache License 2.0 6 votes vote down vote up
@Test
public void fromAssets() {
    Application originApplication = ApplicationProvider.getApplicationContext();
    Application application = Mockito.spy(originApplication);
    Application godeyeApplication = GodEye.instance().getApplication();
    GodEye.instance().internalInit(application);
    AssetManager assetManager = Mockito.spy(application.getAssets());
    Mockito.doReturn(assetManager).when(application).getAssets();
    try {
        Mockito.doAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                Object[] args = invocation.getArguments();
                Object object = this.getClass().getClassLoader().getResourceAsStream(String.valueOf(args[0]));
                return object;
            }
        }).when(assetManager).open(Mockito.anyString());
    } catch (IOException e) {
        fail();
    }
    GodEyeConfig config = GodEyeConfig.fromAssets("install.config");
    assertConfig(config);
    GodEye.instance().internalInit(godeyeApplication);
}
 
Example #3
Source File: FragmentsSelectTest.java    From itag with GNU General Public License v3.0 6 votes vote down vote up
@Before
public void setupActivity() {
    Application application = ApplicationProvider.getApplicationContext();
    ShadowApplication shadowApplication = shadowOf(application);
    shadowApplication.grantPermissions(Manifest.permission.ACCESS_FINE_LOCATION);
    Intent intent = new Intent(application, ITagsService.class);
    ITagsService iTagsService = new ITagsService();
    shadowApplication.setComponentNameAndServiceForBindServiceForIntent(
            intent,
            new ComponentName(ITagApplication.class.getPackage().getName(),ITagsService.class.getName()),
            iTagsService.onBind(null)
    );
    mockBluetoothManager = Mockito.mock(BluetoothManager.class);
    ShadowContextImpl shadowContext = Shadow.extract(application.getBaseContext());
    shadowContext.setSystemService(Context.BLUETOOTH_SERVICE, mockBluetoothManager);
}
 
Example #4
Source File: DemoListItemComponentTest.java    From litho with Apache License 2.0 6 votes vote down vote up
@Test
public void testComponentOnSyntheticEventClick() {
  final Class activityClassToLaunch = PlaygroundActivity.class;
  final Component component =
      DemoListItemComponent.create(mComponentsRule.getContext())
          .model(new DemoListActivity.DemoListDataModel("My Component", activityClassToLaunch))
          .currentIndices(null)
          .build();

  // Here, we make use of Litho's internal event infrastructure and manually dispatch the event.
  final ComponentContext componentContext =
      withComponentScope(mComponentsRule.getContext(), component);
  component.dispatchOnEvent(DemoListItemComponent.onClick(componentContext), new ClickEvent());

  final Intent nextIntent =
      shadowOf(ApplicationProvider.<Application>getApplicationContext()).getNextStartedActivity();
  assertThat(nextIntent.getComponent().getClassName()).isSameAs(activityClassToLaunch.getName());
}
 
Example #5
Source File: LocationsGPSUpdaterNoPermissionTest.java    From itag with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void locationsGPSUpdater_shouldEmitPermissionRequestAndonRequestResultFalse() {
    Application context = ApplicationProvider.getApplicationContext();
    ShadowApplication shadowContext = Shadows.shadowOf(context);
    shadowContext.setSystemService(Context.LOCATION_SERVICE, mockLocationManager);
    LocationsGPSUpdater locationsGPSUpdater = new LocationsGPSUpdater(context);

    doThrow(SecurityException.class)
            .when(mockLocationManager)
            .requestLocationUpdates(
                    LocationManager.GPS_PROVIDER,
                    1000,
                    1,
                    mockLocationListener);

    locationsGPSUpdater.requestLocationUpdates(mockLocationListener, mockRequestUpdatesListener, 1000);

    verify(mockRequestUpdatesListener, times(1)).onRequestResult(false);
    verify(mockErrorListener, times(1)).onError(any());
    verify(mockLocationListener, never()).onLocationChanged(any());
}
 
Example #6
Source File: LocationsGPSUpdaterTest.java    From itag with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void locationsGPSUpdater_shouldEmitNotificationsOnLocationUpdates() {
    Application context = ApplicationProvider.getApplicationContext();
    LocationsGPSUpdater locationsGPSUpdater = new LocationsGPSUpdater(context);
    LocationManager manager =
            (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    ShadowLocationManager shadowLocationManager = Shadows.shadowOf(manager);


    locationsGPSUpdater.requestLocationUpdates(mockLocationListener, mockRequestUpdatesListener, 1000);
    verify(mockLocationListener, never()).onLocationChanged(any());

    Location location = new Location(LocationManager.GPS_PROVIDER);
    shadowLocationManager.simulateLocation(location);
    verify(mockLocationListener).onLocationChanged(any());
}
 
Example #7
Source File: WayTodayStartStopTest.java    From itag with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void activity_shouldStartWayToday5min() {
    try (ActivityScenario<MainActivity> ignored = ActivityScenario.launch(MainActivity.class)) {
        Application application = ApplicationProvider.getApplicationContext();
        SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(application);

        assertThat(LocationsTracker.isUpdating, is(false));

        ViewInteraction vi = onView(withId(R.id.btn_waytoday));
        vi.perform(click());
        onView(withText(R.string.freq_min_5))
                .perform(click());
        ArgumentCaptor<LocationsTracker.TrackingState> state =
                ArgumentCaptor.forClass(LocationsTracker.TrackingState.class);

        verify(mockTrackingStateListener, timeout(5000).atLeast(1)).onStateChange(state.capture());
        List<LocationsTracker.TrackingState> states =
                state.getAllValues();
        assertThat(states.size(), greaterThan(0));
        assertThat(states.get(0).isUpdating, is(true));
        assertThat(LocationsTracker.isUpdating, is(true));
        assertThat(p.getInt("freq", -1), equalTo(5 * 60 * 1000));
        assertThat(p.getBoolean("wt", false), is(true));
    }
}
 
Example #8
Source File: CrashlyticsReportDataCaptureTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  when(instanceIdMock.getId()).thenReturn("installId");
  when(stackTraceTrimmingStrategy.getTrimmedStackTrace(any(StackTraceElement[].class)))
      .thenAnswer(i -> i.getArguments()[0]);
  final Context context = ApplicationProvider.getApplicationContext();
  final IdManager idManager = new IdManager(context, context.getPackageName(), instanceIdMock);
  final AppData appData = AppData.create(context, idManager, "googleAppId", "buildId");
  dataCapture =
      new CrashlyticsReportDataCapture(context, idManager, appData, stackTraceTrimmingStrategy);
  timestamp = System.currentTimeMillis();
  eventType = "crash";
  eventThreadImportance = 4;
  maxChainedExceptions = 8;
}
 
Example #9
Source File: SpecTestCase.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Sets up a new client. Is used to initially setup the client initially and after every restart.
 */
private void initClient() {
  queue = new AsyncQueue();
  datastore = new MockDatastore(databaseInfo, queue, ApplicationProvider.getApplicationContext());

  ComponentProvider.Configuration configuration =
      new ComponentProvider.Configuration(
          ApplicationProvider.getApplicationContext(),
          queue,
          databaseInfo,
          datastore,
          currentUser,
          maxConcurrentLimboResolutions,
          new FirebaseFirestoreSettings.Builder().build());

  ComponentProvider provider =
      initializeComponentProvider(configuration, garbageCollectionEnabled);
  localPersistence = provider.getPersistence();
  remoteStore = provider.getRemoteStore();
  syncEngine = provider.getSyncEngine();
  eventManager = provider.getEventManager();
}
 
Example #10
Source File: SchemaManagerTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void upgradingV1ToLatest_nonEmptyDB_isLossless() {
  int oldVersion = 1;
  int newVersion = SCHEMA_VERSION;
  SchemaManager schemaManager =
      new SchemaManager(ApplicationProvider.getApplicationContext(), DB_NAME, oldVersion);
  SQLiteEventStore store = new SQLiteEventStore(clock, new UptimeClock(), CONFIG, schemaManager);
  // We simulate operations as done by an older SQLLiteEventStore at V1
  // We cannot simulate older operations with a newer client
  PersistedEvent event1 = simulatedPersistOnV1Database(schemaManager, CONTEXT1, EVENT1);

  // Upgrade to V2
  schemaManager.onUpgrade(schemaManager.getWritableDatabase(), oldVersion, newVersion);

  assertThat(store.loadBatch(CONTEXT1)).containsExactly(event1);
}
 
Example #11
Source File: SchemaManagerTest.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void upgradingV3ToV4_nonEmptyDB_isLossless() {
  int oldVersion = 3;
  int newVersion = 4;
  SchemaManager schemaManager =
      new SchemaManager(ApplicationProvider.getApplicationContext(), DB_NAME, oldVersion);
  SQLiteEventStore store = new SQLiteEventStore(clock, new UptimeClock(), CONFIG, schemaManager);
  // We simulate operations as done by an older SQLLiteEventStore at V1
  // We cannot simulate older operations with a newer client
  PersistedEvent event1 = simulatedPersistOnV1Database(schemaManager, CONTEXT1, EVENT1);

  // Upgrade to V4
  schemaManager.onUpgrade(schemaManager.getWritableDatabase(), oldVersion, newVersion);
  assertThat(store.loadBatch(CONTEXT1)).containsExactly(event1);

  long inlineRows =
      store
          .getDb()
          .compileStatement("SELECT COUNT(*) from events where inline = 1")
          .simpleQueryForLong();
  assertThat(inlineRows).isEqualTo(1);
}
 
Example #12
Source File: WayTodayStartStopTest.java    From itag with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void activity_shouldStartWayToday1h() {
    try (ActivityScenario<MainActivity> ignored = ActivityScenario.launch(MainActivity.class)) {
        Application application = ApplicationProvider.getApplicationContext();
        SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(application);

        assertThat(LocationsTracker.isUpdating, is(false));

        ViewInteraction vi = onView(withId(R.id.btn_waytoday));
        vi.perform(click());
        onView(withText(R.string.freq_hour_1))
                .perform(click());
        ArgumentCaptor<LocationsTracker.TrackingState> state =
                ArgumentCaptor.forClass(LocationsTracker.TrackingState.class);

        verify(mockTrackingStateListener, timeout(5000).atLeast(1)).onStateChange(state.capture());
        List<LocationsTracker.TrackingState> states =
                state.getAllValues();
        assertThat(states.size(), greaterThan(0));
        assertThat(states.get(0).isUpdating, is(true));
        assertThat(LocationsTracker.isUpdating, is(true));
        assertThat(p.getInt("freq", -1), equalTo(60 * 60 * 1000));
        assertThat(p.getBoolean("wt", false), is(true));

    }
}
 
Example #13
Source File: CondomContextBasicSemanticTest.java    From condom with Apache License 2.0 5 votes vote down vote up
@Test public void testNonApplicationAsApplicationContextOfBaseContext() {
	final Context context = ApplicationProvider.getApplicationContext();
	final ContextWrapper context_wo_app = new ContextWrapper(context) {
		@Override public Context getApplicationContext() {
			return new ContextWrapper(context);
		}
	};
	final CondomContext condom_context = CondomContext.wrap(context_wo_app, TAG);
	final Context condom_app_context = condom_context.getApplicationContext();
	assertFalse(condom_app_context instanceof Application);
	assertTrue(condom_app_context instanceof CondomContext);
}
 
Example #14
Source File: TrafficTest.java    From AndroidGodEye with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    GodEye.instance().init(ApplicationProvider.getApplicationContext());
    ThreadHelper.setupRxjava();
    ThreadUtil.setNeedDetectRunningThread(false);
    GodEye.instance().install(GodEyeConfig.noneConfigBuilder().withTrafficConfig(new TrafficConfig()).build());
}
 
Example #15
Source File: FixesTest.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void setupActivity() {
    Application application = ApplicationProvider.getApplicationContext();
    ShadowApplication shadowApplication = shadowOf(application);
    shadowApplication.grantPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION});
    Intent intent = new Intent(application, ITagsService.class);
    ITagsService iTagsService = new ITagsService();
    shadowApplication.setComponentNameAndServiceForBindServiceForIntent(
            intent,
            new ComponentName(ITagsService.class.getPackage().getName(),ITagsService.class.getName()),
            iTagsService.onBind(null)
    );
    mainActivity = Robolectric.setupActivity(MainActivity.class);
}
 
Example #16
Source File: WayTodayFirstSessionTest.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void before() {
    Application application = ApplicationProvider.getApplicationContext();
    SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(application);
    p.edit().remove("freq").apply();
    p.edit().remove("tid").apply();
    p.edit().remove("wt").apply();
    p.edit().remove("wtfirst").apply();
    reset(mockIDListener);
    reset(mockUploadListener);
}
 
Example #17
Source File: WayTodayChangeTrackIDTest.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void before() {
    Application application = ApplicationProvider.getApplicationContext();
    SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(application);
    p.edit().remove("freq").apply();
    p.edit().remove("tid").apply();
    p.edit().remove("wt").apply();
    reset(mockIDListener);
    reset(mockUploadListener);
    reset(mockTrackingStateListener);
    reset(mockLocationListener);
}
 
Example #18
Source File: LocationsGPSUpdaterTest.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() {
    reset(mockLocationManager);
    reset(mockLocationListener);
    reset(mockRequestUpdatesListener);
    reset(mockErrorListener);
    ErrorsObservable.addOnITagChangeListener(mockErrorListener);

    Application context = ApplicationProvider.getApplicationContext();
    locationsGPSUpdater = new LocationsGPSUpdater(context);
}
 
Example #19
Source File: AppSizeUtilTest.java    From AndroidGodEye with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 5000)
@Config(sdk = Build.VERSION_CODES.LOLLIPOP)
public void getAppSizeLowerO() {
    CountDownLatch countDownLatch = new CountDownLatch(1);
    final AppSizeInfo[] appSizeInfo = new AppSizeInfo[1];
    AppSizeUtil.getAppSize(ApplicationProvider.getApplicationContext(), new AppSizeUtil.OnGetSizeListener() {
        @Override
        public void onGetSize(AppSizeInfo ctAppSizeInfo) {
            countDownLatch.countDown();
            appSizeInfo[0] = ctAppSizeInfo;
        }

        @Override
        public void onError(Throwable t) {
            countDownLatch.countDown();
        }
    });
    try {
        countDownLatch.await(3, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        Assert.fail();
    }
    Log4Test.d(String.valueOf(appSizeInfo[0]));
    Assert.assertTrue(appSizeInfo[0].dataSize >= 0);
    Assert.assertTrue(appSizeInfo[0].codeSize >= 0);
    Assert.assertTrue(appSizeInfo[0].cacheSize >= 0);
}
 
Example #20
Source File: WayTodayStartStopTest.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void activity_shouldStopWayToday() {
    try (ActivityScenario<MainActivity> ignored = ActivityScenario.launch(MainActivity.class)) {
        Application application = ApplicationProvider.getApplicationContext();
        SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(application);

        assertThat(LocationsTracker.isUpdating, is(false));

        ViewInteraction vi = onView(withId(R.id.btn_waytoday));
        vi.perform(click());
        onView(withText(R.string.freq_hour_1))
                .perform(click());
        ArgumentCaptor<LocationsTracker.TrackingState> state =
                ArgumentCaptor.forClass(LocationsTracker.TrackingState.class);

        verify(mockTrackingStateListener, timeout(5000).atLeast(1)).onStateChange(state.capture());
        List<LocationsTracker.TrackingState> states =
                state.getAllValues();
        assertThat(states.size(), greaterThan(0));
        assertThat(states.get(0).isUpdating, is(true));
        assertThat(LocationsTracker.isUpdating, is(true));
        assertThat(p.getInt("freq", -1), equalTo(60 * 60 * 1000));
        assertThat(p.getBoolean("wt", false), is(true));

        reset(mockTrackingStateListener);

        vi.perform(click());
        onView(withText(R.string.off))
                .perform(click());
        verify(mockTrackingStateListener, timeout(5000).atLeast(1)).onStateChange(state.capture());
        states =
                state.getAllValues();
        assertThat(states.size(), greaterThan(0));
        assertThat(LocationsTracker.isUpdating, is(false));
        assertThat(p.getInt("freq", -1), equalTo(60 * 60 * 1000));
        assertThat(p.getBoolean("wt", true), is(false));

    }
}
 
Example #21
Source File: FirestoreRegistrarTest.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Ignore
@Test
public void storageRegistrar_getComponents_publishesLibVersionComponent() {
  FirebaseApp app =
      FirebaseApp.initializeApp(
          ApplicationProvider.getApplicationContext(),
          new FirebaseOptions.Builder()
              .setProjectId("projectId")
              .setApplicationId("1:196403931065:android:60949756fbe381ea")
              .build());
  UserAgentPublisher userAgentPublisher = app.get(UserAgentPublisher.class);
  String actualUserAgent = userAgentPublisher.getUserAgent();

  assertThat(actualUserAgent).contains("fire-fst");
}
 
Example #22
Source File: PersistenceTestHelpers.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
private static SQLitePersistence openSQLitePersistence(
    String name, LruGarbageCollector.Params params) {
  DatabaseId databaseId = DatabaseId.forProject("projectId");
  LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(databaseId));
  Context context = ApplicationProvider.getApplicationContext();
  SQLitePersistence persistence =
      new SQLitePersistence(context, name, databaseId, serializer, params);
  persistence.start();
  return persistence;
}
 
Example #23
Source File: IntegrationTestUtil.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
public static FirebaseApp testFirebaseApp() {
  try {
    return FirebaseApp.getInstance(FirebaseApp.DEFAULT_APP_NAME);
  } catch (IllegalStateException e) {
    return FirebaseApp.initializeApp(ApplicationProvider.getApplicationContext(), OPTIONS);
  }
}
 
Example #24
Source File: StreamTest.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testStreamRefreshesTokenUponExpiration() throws Exception {
  AsyncQueue testQueue = new AsyncQueue();
  MockCredentialsProvider mockCredentialsProvider = new MockCredentialsProvider();
  Datastore datastore =
      new Datastore(
          IntegrationTestUtil.testEnvDatabaseInfo(),
          testQueue,
          mockCredentialsProvider,
          ApplicationProvider.getApplicationContext(),
          null);
  StreamStatusCallback callback = new StreamStatusCallback();
  WriteStream writeStream = datastore.createWriteStream(callback);
  waitForWriteStreamOpen(testQueue, writeStream, callback);

  // Simulate callback from GRPC with an unauthenticated error -- this should invalidate the
  // token.
  testQueue.runSync(() -> writeStream.handleServerClose(Status.UNAUTHENTICATED));
  waitForWriteStreamOpen(testQueue, writeStream, callback);

  // Simulate a different error -- token should not be invalidated this time.
  testQueue.runSync(() -> writeStream.handleServerClose(Status.UNAVAILABLE));
  waitForWriteStreamOpen(testQueue, writeStream, callback);

  assertThat(mockCredentialsProvider.observedStates())
      .containsExactly("getToken", "invalidateToken", "getToken", "getToken")
      .inOrder();
}
 
Example #25
Source File: PoolBisectUtilTest.java    From litho with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetPoolNotInRange() {
  ComponentsConfiguration.isPoolBisectEnabled = true;
  ComponentsConfiguration.disablePoolsStart = "artistcomponent";
  ComponentsConfiguration.disablePoolsEnd = "bazcomponent";

  final MountContentPool pool = PoolBisectUtil.getPoolForComponent(mFooComponent);
  assertThat(pool).isInstanceOf(DefaultMountContentPool.class);

  final View view =
      (View) pool.acquire(ApplicationProvider.getApplicationContext(), mFooComponent);
  pool.release(view);
  assertThat(view)
      .isSameAs(pool.acquire(ApplicationProvider.getApplicationContext(), mFooComponent));
}
 
Example #26
Source File: CondomContextBasicSemanticTest.java    From condom with Apache License 2.0 5 votes vote down vote up
@Test public void testApplicationContextAsBaseContext() {
	final Context context = ApplicationProvider.getApplicationContext();
	final Context app_context = context.getApplicationContext();
	assertTrue(app_context instanceof Application);
	final CondomContext condom_context = CondomContext.wrap(app_context, TAG);
	final Context condom_app_context = condom_context.getApplicationContext();
	assertTrue(condom_app_context instanceof Application);
	assertEquals(condom_context, ((Application) condom_app_context).getBaseContext());
	assertTrue(((Application) condom_app_context).getBaseContext() instanceof CondomContext);
}
 
Example #27
Source File: CondomContextBasicSemanticTest.java    From condom with Apache License 2.0 5 votes vote down vote up
@Test public void testApplicationAsApplicationContextOfBaseContext() {
	final Context context = ApplicationProvider.getApplicationContext();
	final Context app_context = context.getApplicationContext();
	assertTrue(app_context instanceof Application);
	final CondomContext condom_context = CondomContext.wrap(context, TAG);
	final Context condom_app_context = condom_context.getApplicationContext();
	assertTrue(condom_app_context instanceof Application);
	assertNotSame(app_context, condom_app_context);
	assertTrue(((Application) condom_app_context).getBaseContext() instanceof CondomContext);
}
 
Example #28
Source File: ExampleInstrumentedTest.java    From magellan with Apache License 2.0 5 votes vote down vote up
@Test
public void useAppContext() {
  // Context of the app under test.
  Context appContext = ApplicationProvider.getApplicationContext();

  assertEquals("com.wealthfront.magellan.sample", appContext.getPackageName());
}
 
Example #29
Source File: LocationsGPSUpdaterNoPermissionTest.java    From itag with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void shadowContext_shouldProvideMockedSystemService() {
    Application context = ApplicationProvider.getApplicationContext();
    ShadowApplication shadowContext = Shadows.shadowOf(context);
    shadowContext.setSystemService(Context.LOCATION_SERVICE, mockLocationManager);

    LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    assertThat(manager).isEqualTo(mockLocationManager);
}
 
Example #30
Source File: JobSchedulerTest.java    From JobSchedulerCompat with MIT License 5 votes vote down vote up
@Before
public void setup() {
    application = ApplicationProvider.getApplicationContext();
    jobScheduler = JobScheduler.get(application);
    jobStore = JobStore.get(application);

    noopScheduler = new NoopScheduler(application);
    jobScheduler.schedulers.put(noopScheduler.getTag(), noopScheduler);
}