@Test public void toString_returnsNotEmptyString() throws Exception { assertThat(surface.toString()).isNotEmpty(); } }
@Test public void getProfileSwitchingLabel_shouldNotBeEmpty() { shadowOf(crossProfileApps).addTargetUserProfile(userHandle1); CharSequence label = crossProfileApps.getProfileSwitchingLabel(userHandle1); assertThat(label.toString()).isNotEmpty(); }
@Test @Config(minSdk = Build.VERSION_CODES.N) public void addAutomaticZenRule_oneRule_shouldAddRuleAndReturnId() { shadowOf(notificationManager).setNotificationPolicyAccessGranted(true); AutomaticZenRule rule = new AutomaticZenRule( "name", new ComponentName("pkg", "cls"), Uri.parse("condition://id"), NotificationManager.INTERRUPTION_FILTER_PRIORITY, /* enabled= */ true); String id = notificationManager.addAutomaticZenRule(rule); assertThat(id).isNotEmpty(); assertThat(notificationManager.getAutomaticZenRule(id)).isEqualTo(rule); assertThat(notificationManager.getAutomaticZenRules()).containsExactly(id, rule); }
@Test public void installPackage_defaults() { PackageInfo info = new PackageInfo(); info.packageName = "name"; info.activities = new ActivityInfo[] {new ActivityInfo()}; shadowPackageManager.installPackage(info); PackageInfo installed = shadowPackageManager.getInternalMutablePackageInfo("name"); ActivityInfo activity = installed.activities[0]; assertThat(installed.applicationInfo).isNotNull(); assertThat(installed.applicationInfo.packageName).isEqualTo("name"); assertThat((installed.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED) != 0) .named("%s is installed", installed.applicationInfo) .isTrue(); assertThat(activity.packageName).isEqualTo("name"); // this should be really equal in parcel sense as ApplicationInfo doesn't implement equals(). assertThat(activity.applicationInfo).isEqualTo(installed.applicationInfo); assertThat(installed.applicationInfo.processName).isEqualTo("name"); assertThat(activity.name).isNotEmpty(); }
assertThat(job.jobAuthorization().state()) .isEqualTo(JobAuthorization.State.CREDS_ENCRYPTION_KEY_GENERATED); assertThat(job.jobAuthorization().authPublicKey()).isNotEmpty(); JobAuthorization jobAuthorization = job.jobAuthorization(); assertThat(jobAuthorization.state()).isEqualTo(JobAuthorization.State.CREDS_STORED); assertThat(jobAuthorization.encryptedAuthData()).isNotEmpty();
@Test public void testShouldGenerateStandardHeaders() throws Exception { Message message = new MimeMessage(); Map<String, String> map = new HashMap<String, String>(); Date sent = new Date(); PersonRecord person = new PersonRecord(0, null, null, null); generator.setHeaders(message, map, DataType.SMS, "1234", person, sent, 0); assertThat(get(message, Headers.ADDRESS)).isEqualTo("1234"); assertThat(get(message, Headers.DATATYPE)).isEqualTo("SMS"); assertThat(get(message, Headers.BACKUP_TIME)).isNotEmpty(); assertThat(get(message, Headers.VERSION)).isNotEmpty(); assertThat(message.getMessageId()).contains("sms-backup-plus.local"); assertThat(message.getSentDate()).isEqualTo(sent); assertThat(message.getReferences()).isNotEmpty(); }
private Intent assertAlarmScheduled(String ofExpectedType) { AlarmManager alarmManager = (AlarmManager) RuntimeEnvironment.application.getSystemService(Context.ALARM_SERVICE); ShadowAlarmManager shadow = shadowOf(alarmManager); ShadowAlarmManager.ScheduledAlarm nextScheduledAlarm = shadow.getNextScheduledAlarm(); assertThat(nextScheduledAlarm.type).isEqualTo(AlarmManager.RTC_WAKEUP); assertThat(nextScheduledAlarm.triggerAtTime).isGreaterThan(0L); PendingIntent pendingIntent = nextScheduledAlarm.operation; ShadowPendingIntent shadowPendingIntent = shadowOf(pendingIntent); ComponentName component = shadowPendingIntent.getSavedIntent().getComponent(); assertThat(component.getPackageName()).isEqualTo("com.zegoggles.smssync"); assertThat(component.getClassName()).isEqualTo("com.zegoggles.smssync.service.SmsBackupService"); assertThat(shadowPendingIntent.getFlags()).isEqualTo(FLAG_UPDATE_CURRENT); assertThat(shadowPendingIntent.getSavedIntent().getAction()).isNotEmpty(); assertThat(shadowPendingIntent.getSavedIntent().getAction()) .isEqualTo(ofExpectedType); return shadowPendingIntent.getSavedIntent(); }
@Test public void query_basicIntegration() throws Exception { Cursor cursor = provider.query(Uri.parse("content://org.transdroid.search.torrentsearchprovider/search/music"), null, null, null, null); assertThat(cursor).isNotNull(); assertThat(cursor.getCount()).isGreaterThan(0); assertThat(cursor.getColumnCount()).isEqualTo(8); assertThat(cursor.moveToFirst()).isTrue(); int id = 0; do { assertThat(cursor.getInt(0)).isEqualTo(id); // Incremental id assertThat(cursor.getString(1)).isNotEmpty(); // Title assertThat(cursor.getString(2)).isNotEmpty(); // Torrent url assertThat(cursor.getString(3)).isNotEmpty(); // Details url assertThat(cursor.getString(4)).isNotEmpty(); // Size assertThat(cursor.getLong(5)).isGreaterThan(0L); // Timestamp assertThat(cursor.getInt(6)).isAtLeast(0); // Seeders assertThat(cursor.getInt(7)).isAtLeast(0); // Leechers id++; } while (cursor.moveToNext()); }
@Test public void itDecryptKeyCorrectly() { String decrypted = subject.decrypt(ALIAS_FOR_TEST); assertThat(decrypted).isNotEmpty(); assertThat(decrypted).isEqualTo(VALUE_FOR_TEST); }
@Test public void query_hasSitesWithCodeAndName() throws Exception { Cursor cursor = provider.query(TorrentSitesProvider.CONTENT_URI, null, null, null, null); assertThat(cursor).isNotNull(); assertThat(cursor.getCount()).isGreaterThan(0); assertThat(cursor.getColumnCount()).isEqualTo(5); assertThat(cursor.moveToFirst()).isTrue(); int id = 0; do { assertThat(cursor.getInt(0)).isEqualTo(id); // Incremental id assertThat(cursor.getString(1)).isNotEmpty(); // Site code assertThat(cursor.getString(2)).isNotEmpty(); // Site name assertThat(cursor.getInt(4)).isAnyOf(0, 1); // Public or private site id++; } while (cursor.moveToNext()); }
@Test public void testBasicMathFu() throws Exception { File templates[] = templates( new File("../third_party/mathfu/cdep")); File output = new File(".test-files/testBasicMathFu").getAbsoluteFile(); List<File> result = Fullfill.multiple(environment, templates, output, new File("../third_party/mathfu"), "1.2.3"); assertThat(result).hasSize(2); File manifestFile = new File(output, "layout"); manifestFile = new File(manifestFile, "cdep-manifest.yml"); CDepManifestYml manifest = CDepManifestYmlUtils.convertStringToManifest(manifestFile.getAbsolutePath(), FileUtils.readAllText(manifestFile)); assertThat(manifest.dependencies[0].sha256).isNotNull(); assertThat(manifest.dependencies[0].sha256).isNotEmpty(); }
@Test public void testMiniFirebase() throws Exception { File templates[] = new File[]{ new File("../third_party/mini-firebase/cdep-manifest-app.yml"), new File("../third_party/mini-firebase/cdep-manifest-database.yml") }; File output = new File(".test-files/testMiniFirebase").getAbsoluteFile(); output.delete(); List<File> result = Fullfill.multiple(environment, templates, output, new File("../third_party/mini-firebase/firebase_cpp_sdk"), "1.2.3"); File manifestFile = new File(output, "layout"); manifestFile = new File(manifestFile, "cdep-manifest-database.yml"); CDepManifestYml manifest = CDepManifestYmlUtils.convertStringToManifest(manifestFile.getAbsolutePath(), FileUtils.readAllText(manifestFile)); assertThat(manifest.dependencies[0].sha256).isNotNull(); assertThat(manifest.dependencies[0].sha256).isNotEmpty(); // Don't allow + in file name to escape. if(manifest.android != null) assertThat(manifest.android.archives[0].file.contains("+")).isFalse(); }
@Test public void canFetchRandomJokeFromApi() throws IOException { barricade.setEnabled(false); Response<Joke> response = getApiService().getRandomJoke().execute(); assertThat(response.isSuccessful()).isTrue(); assertThat(response.code()).isEqualTo(200); assertThat(response.body()).isNotNull(); Joke joke = response.body(); assertThat(joke.id).isNotNull(); assertThat(joke.id).isNotEmpty(); assertThat(joke.value).isNotNull(); assertThat(joke.value).isNotEmpty(); assertThat(joke.iconUrl).isNotNull(); assertThat(joke.iconUrl).isNotEmpty(); }
@Test public void canFetchRandomJokeFromBarricade() throws IOException { barricade.setEnabled(true); Response<Joke> response = getApiService().getRandomJoke().execute(); assertThat(response.isSuccessful()).isTrue(); assertThat(response.code()).isEqualTo(200); assertThat(response.body()).isNotNull(); Joke joke = response.body(); assertThat(joke.id).isNotNull(); assertThat(joke.id).isNotEmpty(); assertThat(joke.id).isEqualTo("gX6RQU9EQxC4oZd6kVeiSw"); assertThat(joke.value).isNotNull(); assertThat(joke.value).isNotEmpty(); assertThat(joke.value).isEqualTo("When Chuck Norris was a kid, he made his mom eat her vegetables"); assertThat(joke.iconUrl).isNotNull(); assertThat(joke.iconUrl).isNotEmpty(); assertThat(joke.iconUrl).isEqualTo("https://assets.chucknorris.host/img/avatar/chuck-norris.png"); }
private void searchSite(TorrentSite torrentSite) throws Exception { // Set test user and password if (torrentSite.getAdapter().getAuthType() != NONE) { String user = getResourceString(torrentSite.name() + "_user"); String pass = getResourceString(torrentSite.name() + "_pass"); String token = getResourceString(torrentSite.name() + "_token"); if (!(has(user, pass) || has(token))) assert_().fail(torrentSite.name() + " is private but no credentials found: untestable"); prefs.edit() .putString("pref_key_user_" + torrentSite.name(), user) .putString("pref_key_pass_" + torrentSite.name(), pass) .putString("pref_key_token_" + torrentSite.name(), token) .commit(); } List<SearchResult> results = torrentSite.search(prefs, QUERY, ORDER, RESULTS); assertThat(results).isNotEmpty(); for (SearchResult result : results) { assertThat(result.getTitle()).isNotEmpty(); assertThat(result.getTorrentUri()).isNotNull(); assertThat(result.getTorrentUri().toString()).isNotEmpty(); assertThat(result.getDetailsUrl()).isNotEmpty(); assertThat(result.getSize()).isNotEmpty(); assertThat(result.getAddedDate()).isNotNull(); assertThat(result.getAddedDate().getTime()).isGreaterThan(THE_YEAR_2000); assertThat(result.getSeeds()).isAtLeast(0); assertThat(result.getLeechers()).isAtLeast(0); } }