/** Fails if the subject is empty. */ public void isNotEmpty() { check().that(actualList).isNotEmpty(); }
/** Fails if the subject is empty. */ public void isNotEmpty() { check().that(actualList).isNotEmpty(); }
/** Fails if the subject is empty. */ public void isNotEmpty() { check().that(actualList).isNotEmpty(); }
@AndroidIncompatible // Android forbids null parent ClassLoader // https://github.com/google/guava/issues/2152 public void testJarFileWithSpaces() throws Exception { URL url = makeJarUrlWithName("To test unescaped spaces in jar file name.jar"); URLClassLoader classloader = new URLClassLoader(new URL[] {url}, null); assertThat(ClassPath.from(classloader).getTopLevelClasses()).isNotEmpty(); }
@Test @Config(minSdk = JELLY_BEAN_MR1) public void queryIntentServicesAsUser() { Intent i = new Intent("org.robolectric.ACTION_DIFFERENT_PACKAGE"); i.addCategory(Intent.CATEGORY_LAUNCHER); i.setType("image/jpeg"); List<ResolveInfo> services = packageManager.queryIntentServicesAsUser(i, 0, 0); assertThat(services).isNotEmpty(); }
@Test public void queryIntentServices_fromManifest() { Intent i = new Intent("org.robolectric.ACTION_DIFFERENT_PACKAGE"); i.addCategory(Intent.CATEGORY_LAUNCHER); i.setType("image/jpeg"); List<ResolveInfo> services = packageManager.queryIntentServices(i, 0); assertThat(services).isNotEmpty(); }
@Test public void testQueryBroadcastReceiverSucceeds() { Intent intent = new Intent("org.robolectric.ACTION_RECEIVER_PERMISSION_PACKAGE"); intent.setPackage(ApplicationProvider.getApplicationContext().getPackageName()); List<ResolveInfo> receiverInfos = packageManager.queryBroadcastReceivers(intent, PackageManager.GET_RESOLVED_FILTER); assertThat(receiverInfos).isNotEmpty(); assertThat(receiverInfos.get(0).activityInfo.name) .isEqualTo("org.robolectric.ConfigTestReceiverPermissionsAndActions"); assertThat(receiverInfos.get(0).activityInfo.permission) .isEqualTo("org.robolectric.CUSTOM_PERM"); assertThat(receiverInfos.get(0).filter.getAction(0)) .isEqualTo("org.robolectric.ACTION_RECEIVER_PERMISSION_PACKAGE"); }
@Test public void cancelNonExistentJob() { jobScheduler.schedule( new JobInfo.Builder(99, new ComponentName(context, "component_class_name")) .setPeriodic(1000) .build()); assertThat(jobScheduler.getAllPendingJobs()).isNotEmpty(); jobScheduler.cancel(33); assertThat(jobScheduler.getAllPendingJobs()).isNotEmpty(); }
@Test public void queryPermissionsByGroup_nullMatchesPermissionsNotAssociatedWithGroup_with_addPermissionInfo() throws Exception { PermissionInfo permissionInfo = new PermissionInfo(); permissionInfo.name = "some_name"; shadowPackageManager.addPermissionInfo(permissionInfo); List<PermissionInfo> permissions = packageManager.queryPermissionsByGroup(null, 0); assertThat(permissions).isNotEmpty(); assertThat(permissions.get(0).name).isEqualTo(permissionInfo.name); }
@Test public void getInstalledPackages_disabledPackage_includeDisabled() throws Exception { packageManager.setApplicationEnabledSetting( ApplicationProvider.getApplicationContext().getPackageName(), COMPONENT_ENABLED_STATE_DISABLED, 0); assertThat(packageManager.getInstalledPackages(MATCH_DISABLED_COMPONENTS)).isNotEmpty(); assertThat(packageManager.getInstalledPackages(MATCH_DISABLED_COMPONENTS).get(0).packageName) .isEqualTo(ApplicationProvider.getApplicationContext().getPackageName()); }
@Test public void shouldReleaseAllStateAfterClassSoWeDontLeakMemory() throws Exception { final List<RobolectricTestRunner.RobolectricFrameworkMethod> methods = new ArrayList<>(); RobolectricTestRunner robolectricTestRunner = new Runner(SimpleTest.class) { @Override protected void finallyAfterTest(FrameworkMethod method) { super.finallyAfterTest(method); RobolectricFrameworkMethod roboMethod = (RobolectricFrameworkMethod) method; assertThat(roboMethod.parallelUniverseInterface).isNull(); assertThat(roboMethod.testLifecycle).isNull(); methods.add(roboMethod); } }; robolectricTestRunner.run(new RunNotifier()); assertThat(methods).isNotEmpty(); }
@Test public void litmus() { AndroidThreeTen.init(context); assertThat(ZoneRulesProvider.getAvailableZoneIds()).isNotEmpty(); } }
@Test public void builderWithoutRequestHandler() { Picasso picasso = new Picasso.Builder(RuntimeEnvironment.application).build(); assertThat(picasso.getRequestHandlers()).isNotEmpty(); assertThat(picasso.getRequestHandlers()).doesNotContain(requestHandler); }
@Test public void loggerEnabled() { db.setLoggingEnabled(true); db.insert(TABLE_EMPLOYEE, CONFLICT_NONE, employee("john", "John Johnson")); assertThat(logs).isNotEmpty(); }
@Test public void clear() { assertThat(ShadowLog.getLogsForTag("tag1")).isEmpty(); Log.d("tag1", "1"); assertThat(ShadowLog.getLogsForTag("tag1")).isNotEmpty(); ShadowLog.clear(); assertThat(ShadowLog.getLogsForTag("tag1")).isEmpty(); assertThat(ShadowLog.getLogs()).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 cancelSingleJob() { jobScheduler.schedule( new JobInfo.Builder(99, new ComponentName(context, "component_class_name")) .setPeriodic(1000) .build()); assertThat(jobScheduler.getAllPendingJobs()).isNotEmpty(); jobScheduler.cancel(99); assertThat(jobScheduler.getAllPendingJobs()).isEmpty(); }
public void testLoggerEnabled() { db.setLoggingEnabled(true); db.createQuery(TABLE, null, null, null, null, false).subscribe(o); o.assertCursor().isExhausted(); contentResolver.insert(TABLE, values("key1", "value1")); o.assertCursor().hasRow("key1", "value1").isExhausted(); assertThat(logs).isNotEmpty(); }
@Test public void parseManifest_shouldReadServices() throws Exception { AndroidManifest config = newConfig("TestAndroidManifestWithServices.xml"); assertThat(config.getServices()).hasSize(2); assertThat(config.getServices().get(0).getClassName()).isEqualTo("com.foo.Service"); assertThat(config.getServices().get(0).getActions()).contains("org.robolectric.ACTION_DIFFERENT_PACKAGE"); assertThat(config.getServices().get(0).getIntentFilters()).isNotEmpty(); assertThat(config.getServices().get(0).getIntentFilters().get(0).getMimeTypes()).containsExactly("image/jpeg"); assertThat(config.getServices().get(1).getClassName()).isEqualTo("com.bar.ServiceWithoutIntentFilter"); assertThat(config.getServices().get(1).getActions()).isEmpty(); assertThat(config.getServices().get(1).getIntentFilters()).isEmpty(); assertThat(config.getServiceData("com.foo.Service").getClassName()).isEqualTo("com.foo.Service"); assertThat(config.getServiceData("com.bar.ServiceWithoutIntentFilter").getClassName()).isEqualTo("com.bar.ServiceWithoutIntentFilter"); assertThat(config.getServiceData("com.foo.Service").getPermission()) .isEqualTo("com.foo.Permission"); assertThat(config.getServiceData("com.foo.Service").isEnabled()).isTrue(); assertThat(config.getServiceData("com.bar.ServiceWithoutIntentFilter").isEnabled()).isFalse(); }
@Test public void testMergingMediaSourcePeriodCreation() throws Exception { FakeMediaSource[] mediaSources = new FakeMediaSource[2]; for (int i = 0; i < mediaSources.length; i++) { mediaSources[i] = new FakeMediaSource(new FakeTimeline(/* windowCount= */ 2), /* manifest= */ null); } MergingMediaSource mediaSource = new MergingMediaSource(mediaSources); MediaSourceTestRunner testRunner = new MediaSourceTestRunner(mediaSource, null); try { testRunner.prepareSource(); testRunner.assertPrepareAndReleaseAllPeriods(); for (FakeMediaSource element : mediaSources) { assertThat(element.getCreatedMediaPeriods()).isNotEmpty(); } testRunner.releaseSource(); } finally { testRunner.release(); } }