private static void assertOfflineLicenseKeySetIdEqual( byte[] expectedKeySetId, byte[] actualKeySetId) throws Exception { assertThat(actualKeySetId).isNotNull(); assertThat(actualKeySetId).isEqualTo(expectedKeySetId); }
@Test public void loadBitmapDrawable_asBytes_providesBytesOfBitmap() { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical); byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(new BitmapDrawable(context.getResources(), bitmap)) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadBitmap_asBytes_providesBytesOfBitmap() { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical); byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(bitmap) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadVideoResourceId_asBytes_providesBytesOfFrame() { byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(ResourceIds.raw.video) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadVideoFileUri_asBytes_providesByteOfFrame() throws IOException { byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(Uri.fromFile(writeVideoToFile())) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadImageResourceId_asBytes_providesBytesOfBitmap() { byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(ResourceIds.raw.canonical) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadVideoFilePath_asBytes_providesByteOfFrame() throws IOException { byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(writeVideoToFile().getAbsolutePath()) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadVideoFile_asBytes_providesByteOfFrame() throws IOException { byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(writeVideoToFile()) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadVideoResourceId_asBytes_withFrameTime_providesBytesOfFrame() { byte[] data = concurrency.get( GlideApp.with(context) .as(byte[].class) .load(ResourceIds.raw.video) .frame(TimeUnit.SECONDS.toMicros(1)) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadVideoFileUri_asBytes_withFrameTime_providesByteOfFrame() throws IOException { byte[] data = concurrency.get( GlideApp.with(context) .as(byte[].class) .load(Uri.fromFile(writeVideoToFile())) .frame(TimeUnit.SECONDS.toMicros(1)) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void loadVideoFilePath_asBytes_withFrameTime_providesByteOfFrame() throws IOException { byte[] data = concurrency.get( GlideApp.with(context) .as(byte[].class) .load(writeVideoToFile().getAbsolutePath()) .frame(TimeUnit.SECONDS.toMicros(1)) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void testWidevineOfflineLicenseV22() throws Exception { if (Util.SDK_INT < 22) { return; // Pass. } downloadLicense(); testRunner.run(); // Renew license after playback should still work offlineLicenseKeySetId = offlineLicenseHelper.renewLicense(offlineLicenseKeySetId); assertThat(offlineLicenseKeySetId).isNotNull(); }
@Test public void testDownloadLicenseDoesNotFailIfDurationNotAvailable() throws Exception { setDefaultStubKeySetId(); byte[] offlineLicenseKeySetId = offlineLicenseHelper.downloadLicense(newDrmInitData()); assertThat(offlineLicenseKeySetId).isNotNull(); }
@Test public void loadVideoFile_asBytes_withFrameTime_providesByteOfFrame() throws IOException { byte[] data = concurrency.get( GlideApp.with(context) .as(byte[].class) .load(writeVideoToFile()) .frame(TimeUnit.SECONDS.toMicros(1)) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void testInsertEmptyBlobArgument() throws Exception { ContentValues emptyBlobValues = new ContentValues(); emptyBlobValues.put("id", 1); emptyBlobValues.put("blob_col", new byte[]{}); ContentValues nullBlobValues = new ContentValues(); nullBlobValues.put("id", 2); nullBlobValues.put("blob_col", (byte[])null); long key = database.insertWithOnConflict("blob_table", null, emptyBlobValues, SQLiteDatabase.CONFLICT_FAIL); assertThat(key).isNotEqualTo(0L); key = database.insertWithOnConflict("blob_table", null, nullBlobValues, SQLiteDatabase.CONFLICT_FAIL); assertThat(key).isNotEqualTo(0L); Cursor cursor = database.query("blob_table", new String[]{"blob_col"}, "id=1", null, null, null, null); try { assertThat(cursor.moveToFirst()).isTrue(); assertThat(cursor.getBlob(cursor.getColumnIndexOrThrow("blob_col"))).isNotNull(); } finally { cursor.close(); } cursor = database.query("blob_table", new String[]{"blob_col"}, "id=2", null, null, null, null); try { assertThat(cursor.moveToFirst()).isTrue(); assertThat(cursor.getBlob(cursor.getColumnIndexOrThrow("blob_col"))).isNull(); } finally { cursor.close(); } }
private void downloadLicense() throws InterruptedException, DrmSessionException, IOException { DataSource dataSource = httpDataSourceFactory.createDataSource(); DashManifest dashManifest = DashUtil.loadManifest(dataSource, Uri.parse(DashTestData.WIDEVINE_H264_MANIFEST)); DrmInitData drmInitData = DashUtil.loadDrmInitData(dataSource, dashManifest.getPeriod(0)); offlineLicenseKeySetId = offlineLicenseHelper.downloadLicense(drmInitData); assertThat(offlineLicenseKeySetId).isNotNull(); assertThat(offlineLicenseKeySetId.length).isGreaterThan(0); testRunner.setOfflineLicenseKeySetId(offlineLicenseKeySetId); }
@Test public void testReadSetupHeadersWithIOExceptions() throws IOException, InterruptedException { byte[] data = OggTestData.getVorbisHeaderPages(); ExtractorInput input = new FakeExtractorInput.Builder().setData(data).setSimulateIOErrors(true) .setSimulateUnknownLength(true).setSimulatePartialReads(true).build(); VorbisReader reader = new VorbisReader(); VorbisReader.VorbisSetup vorbisSetup = readSetupHeaders(reader, input); assertThat(vorbisSetup.idHeader).isNotNull(); assertThat(vorbisSetup.commentHeader).isNotNull(); assertThat(vorbisSetup.setupHeaderData).isNotNull(); assertThat(vorbisSetup.modes).isNotNull(); assertThat(vorbisSetup.commentHeader.length).isEqualTo(45); assertThat(vorbisSetup.idHeader.data).hasLength(30); assertThat(vorbisSetup.setupHeaderData).hasLength(3597); assertThat(vorbisSetup.idHeader.bitrateMax).isEqualTo(-1); assertThat(vorbisSetup.idHeader.bitrateMin).isEqualTo(-1); assertThat(vorbisSetup.idHeader.bitrateNominal).isEqualTo(66666); assertThat(vorbisSetup.idHeader.blockSize0).isEqualTo(512); assertThat(vorbisSetup.idHeader.blockSize1).isEqualTo(1024); assertThat(vorbisSetup.idHeader.channels).isEqualTo(2); assertThat(vorbisSetup.idHeader.framingFlag).isTrue(); assertThat(vorbisSetup.idHeader.sampleRate).isEqualTo(22050); assertThat(vorbisSetup.idHeader.version).isEqualTo(0); assertThat(vorbisSetup.commentHeader.vendor).isEqualTo("Xiph.Org libVorbis I 20030909"); assertThat(vorbisSetup.iLogModes).isEqualTo(1); assertThat(vorbisSetup.setupHeaderData[vorbisSetup.setupHeaderData.length - 1]) .isEqualTo(data[data.length - 1]); assertThat(vorbisSetup.modes[0].blockFlag).isFalse(); assertThat(vorbisSetup.modes[1].blockFlag).isTrue(); }
BlobInfo sourceBlob = BlobInfo.newBuilder(BUCKET, sourceBlobName).build(); assertThat(storage.create(sourceBlob)).isNotNull(); assertThat(storage.readAllBytes(BUCKET, sourceBlobName)).isNotNull(); try { unauthorizedStorage.readAllBytes(BUCKET, sourceBlobName);
@Test public void decodeBlueReaderPacket_notReadyFor_oneTime() { // :: Setup byte[] buffer = "not ready for".getBytes(); // :: Act byte[] reply = blueReader.decodeblueReaderPacket(buffer, -1); // :: Verify assertThat(reply).isNotNull(); assertThat(new String(reply)).isEqualTo("h"); assertThat(getLogs()).contains("E/blueReader: Found blueReader in a ugly State (1/3), send hibernate to reset! If this does not help in the next 5 Minutes, then turn the bluereader manually off and on!"); }
@Test public void decodeBlueReaderPacket_notReadyFor_oneTime() { // :: Setup byte[] buffer = "not ready for".getBytes(); // :: Act byte[] reply = blueReader.decodeblueReaderPacket(buffer, -1); // :: Verify assertThat(reply).isNotNull(); assertThat(new String(reply)).isEqualTo("h"); assertThat(getLogs()).contains("E/blueReader: Found blueReader in a ugly State (1/3), send hibernate to reset! If this does not help in the next 5 Minutes, then turn the bluereader manually off and on!"); }