@Test public void queryIntentActivities_MatchWithImplicitIntents() throws Exception { Uri uri = Uri.parse("content://testhost1.com:1/testPath/test.jpeg"); Intent i = new Intent(Intent.ACTION_VIEW); i.addCategory(Intent.CATEGORY_DEFAULT); i.setDataAndType(uri, "image/jpeg"); List<ResolveInfo> activities = packageManager.queryIntentActivities(i, 0); assertThat(activities).isNotNull(); assertThat(activities).hasSize(1); assertThat(activities.get(0).resolvePackageName).isEqualTo("org.robolectric"); assertThat(activities.get(0).activityInfo.name) .isEqualTo("org.robolectric.shadows.TestActivity"); }
@Test public void queryIntentActivities_MatchDisabledComponents() throws Exception { Intent i = new Intent(); i.setClassName( ApplicationProvider.getApplicationContext(), "org.robolectric.shadows.DisabledActivity"); List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(i, PackageManager.MATCH_DISABLED_COMPONENTS); assertThat(resolveInfos).isNotNull(); assertThat(resolveInfos).hasSize(1); assertThat(resolveInfos.get(0).activityInfo.enabled).isFalse(); }
@Test public void queryIntentActivities_MatchWithExplicitIntent() throws Exception { Intent i = new Intent(); i.setClassName( ApplicationProvider.getApplicationContext(), "org.robolectric.shadows.TestActivity"); List<ResolveInfo> activities = packageManager.queryIntentActivities(i, 0); assertThat(activities).isNotNull(); assertThat(activities).hasSize(1); assertThat(activities.get(0).resolvePackageName).isEqualTo("org.robolectric"); assertThat(activities.get(0).activityInfo.name) .isEqualTo("org.robolectric.shadows.TestActivity"); }
@Test public void shouldReturnASensorList() throws Exception { assertThat(sensorManager.getSensorList(0)).isNotNull(); }
@Test public void testGetSupportedPreviewFrameRates() throws Exception { List<Integer> supportedRates = parameters.getSupportedPreviewFrameRates(); assertThat(supportedRates).isNotNull(); assertThat(supportedRates.size()).isEqualTo(3); assertThat(supportedRates.get(0)).isEqualTo(10); }
@Test public void testGetSupportedPictureSizes() throws Exception { List<Camera.Size> supportedSizes = parameters.getSupportedPictureSizes(); assertThat(supportedSizes).isNotNull(); assertThat(supportedSizes.size()).isEqualTo(3); assertThat(supportedSizes.get(0).width).isEqualTo(320); assertThat(supportedSizes.get(0).height).isEqualTo(240); }
@Test public void testGetSupportedPreviewSizes() throws Exception { List<Camera.Size> supportedSizes = parameters.getSupportedPreviewSizes(); assertThat(supportedSizes).isNotNull(); assertThat(supportedSizes.size()).isEqualTo(2); assertThat(supportedSizes.get(0).width).isEqualTo(320); assertThat(supportedSizes.get(0).height).isEqualTo(240); }
@Test public void queryBroadcastReceivers_MatchWithExplicitIntent() throws Exception { Intent i = new Intent(); i.setClassName( ApplicationProvider.getApplicationContext(), "org.robolectric.fakes.ConfigTestReceiver"); List<ResolveInfo> receivers = packageManager.queryBroadcastReceivers(i, 0); assertThat(receivers).isNotNull(); assertThat(receivers).hasSize(1); assertThat(receivers.get(0).resolvePackageName).isEqualTo("org.robolectric"); assertThat(receivers.get(0).activityInfo.name) .isEqualTo("org.robolectric.fakes.ConfigTestReceiver"); }
@Test public void testGetSupportedPreviewFormats() throws Exception { List<Integer> supportedFormats = parameters.getSupportedPreviewFormats(); assertThat(supportedFormats).isNotNull(); assertThat(supportedFormats.size()).isNotEqualTo((0)); assertThat(supportedFormats).contains(ImageFormat.NV21); }
@Test public void testGetSupportedPreviewFpsRange() throws Exception { List<int[]> supportedRanges = parameters.getSupportedPreviewFpsRange(); assertThat(supportedRanges).isNotNull(); assertThat(supportedRanges.size()).isEqualTo(2); assertThat(supportedRanges.get(0)[0]).isEqualTo(15000); assertThat(supportedRanges.get(0)[1]).isEqualTo(15000); assertThat(supportedRanges.get(1)[0]).isEqualTo(10000); assertThat(supportedRanges.get(1)[1]).isEqualTo(30000); }
@Test public void queryIntentServices_MatchWithExplicitIntent() throws Exception { Intent i = new Intent(); i.setClassName(ApplicationProvider.getApplicationContext(), "com.foo.Service"); List<ResolveInfo> services = packageManager.queryIntentServices(i, 0); assertThat(services).isNotNull(); assertThat(services).hasSize(1); assertThat(services.get(0).resolvePackageName).isEqualTo("org.robolectric"); assertThat(services.get(0).serviceInfo.name).isEqualTo("com.foo.Service"); }
@Test public void testGetSupportedPictureFormats() throws Exception { List<Integer> supportedFormats = parameters.getSupportedPictureFormats(); assertThat(supportedFormats).isNotNull(); assertThat(supportedFormats.size()).isEqualTo(2); assertThat(supportedFormats).contains(ImageFormat.NV21); }
@Test public void testGetParameters() throws Exception { Camera.Parameters parameters = camera.getParameters(); assertThat(parameters).isNotNull(); assertThat(parameters.getSupportedPreviewFormats()).isNotNull(); assertThat(parameters.getSupportedPreviewFormats().size()).isNotEqualTo(0); }
@Test public void queryIntentActivities_ServiceMatch() throws Exception { Intent i = new Intent("SomeStrangeAction"); ResolveInfo info = new ResolveInfo(); info.nonLocalizedLabel = TEST_PACKAGE_LABEL; info.serviceInfo = new ServiceInfo(); info.serviceInfo.name = "name"; info.serviceInfo.packageName = TEST_PACKAGE_NAME; shadowPackageManager.addResolveInfoForIntent(i, info); List<ResolveInfo> activities = packageManager.queryIntentActivities(i, 0); assertThat(activities).isNotNull(); assertThat(activities).isEmpty(); }
@Test public void testAddSupportedPreviewSizes() throws Exception { Shadows.shadowOf(parameters).initSupportedPreviewSizes(); Shadows.shadowOf(parameters).addSupportedPreviewSize(320, 240); List<Camera.Size> supportedSizes = parameters.getSupportedPreviewSizes(); assertThat(supportedSizes).isNotNull(); assertThat(supportedSizes).hasSize(1); assertThat(supportedSizes.get(0).width).isEqualTo(320); assertThat(supportedSizes.get(0).height).isEqualTo(240); }
@Test @Config(minSdk = N) public void getStorageVolumes() { File file1 = new File("/storage/sdcard"); shadowOf(storageManager).addStorageVolume(buildAndGetStorageVolume(file1, "sd card")); assertThat(shadowOf(storageManager).getStorageVolumes()).isNotNull(); }
@Test public void testInitSupportedPreviewSizes() throws Exception { Shadows.shadowOf(parameters).initSupportedPreviewSizes(); assertThat(parameters.getSupportedPreviewSizes()).isNotNull(); assertThat(parameters.getSupportedPreviewSizes()).isEmpty(); }
@Test public void builderWithRequestHandler() { Picasso picasso = new Picasso.Builder(RuntimeEnvironment.application) .addRequestHandler(requestHandler).build(); assertThat(picasso.getRequestHandlers()).isNotNull(); assertThat(picasso.getRequestHandlers()).isNotEmpty(); assertThat(picasso.getRequestHandlers()).contains(requestHandler); }
@Test public void attachMultipleRequests() { Action action1 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget()); Action action2 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget()); BitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, stats, action1); assertThat(hunter.actions).isNull(); hunter.attach(action2); assertThat(hunter.actions).isNotNull(); assertThat(hunter.actions).hasSize(1); }
@Test public void detachMultipleRequests() { Action action = mockAction(URI_KEY_1, URI_1, mockImageViewTarget()); Action action2 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget()); BitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, stats, action); hunter.attach(action2); hunter.detach(action2); assertThat(hunter.action).isNotNull(); assertThat(hunter.actions).isNotNull(); assertThat(hunter.actions).isEmpty(); hunter.detach(action); assertThat(hunter.action).isNull(); }