Commit 2fe478ad by eguven Committed by Oliver Woodman

Invert DashHostedTest and inner class Builder to make the design more natural

Builder class was renamed to DashTestRunner and DashHostedTest moved
into it as an inner class.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150307988
parent 9b0d24c9
......@@ -137,6 +137,16 @@ public final class DashTestData {
WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID,
WIDEVINE_VP9_360P_VIDEO_REPRESENTATION_ID};
private static final String WIDEVINE_LICENSE_URL =
"https://proxy.uat.widevine.com/proxy?provider=widevine_test&video_id=";
private static final String WIDEVINE_SW_CRYPTO_CONTENT_ID = "exoplayer_test_1";
private static final String WIDEVINE_HW_SECURE_DECODE_CONTENT_ID = "exoplayer_test_2";
public static String getWidevineLicenseUrl(boolean useL1Widevine) {
return WIDEVINE_LICENSE_URL
+ (useL1Widevine ? WIDEVINE_HW_SECURE_DECODE_CONTENT_ID : WIDEVINE_SW_CRYPTO_CONTENT_ID);
}
private DashTestData() {
}
......
......@@ -37,7 +37,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
private static final String TAG = "DashWidevineOfflineTest";
private static final String USER_AGENT = "ExoPlayerPlaybackTests";
private DashHostedTest.Builder builder;
private DashTestRunner testRunner;
private DefaultHttpDataSourceFactory httpDataSourceFactory;
private OfflineLicenseHelper<FrameworkMediaCrypto> offlineLicenseHelper;
private byte[] offlineLicenseKeySetId;
......@@ -49,7 +49,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
@Override
protected void setUp() throws Exception {
super.setUp();
builder = new DashHostedTest.Builder(TAG)
testRunner = new DashTestRunner(TAG, getActivity(), getInstrumentation())
.setStreamName("test_widevine_h264_fixed_offline")
.setManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST)
.setWidevineMimeType(MimeTypes.VIDEO_H264)
......@@ -58,8 +58,8 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
.setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID,
DashTestData.WIDEVINE_H264_CDD_FIXED);
boolean useL1Widevine = DashHostedTest.isL1WidevineAvailable(MimeTypes.VIDEO_H264);
String widevineLicenseUrl = DashHostedTest.getWidevineLicenseUrl(useL1Widevine);
boolean useL1Widevine = DashTestRunner.isL1WidevineAvailable(MimeTypes.VIDEO_H264);
String widevineLicenseUrl = DashTestData.getWidevineLicenseUrl(useL1Widevine);
httpDataSourceFactory = new DefaultHttpDataSourceFactory(USER_AGENT);
offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(widevineLicenseUrl,
httpDataSourceFactory);
......@@ -67,12 +67,15 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
@Override
protected void tearDown() throws Exception {
testRunner = null;
if (offlineLicenseKeySetId != null) {
releaseLicense();
}
if (offlineLicenseHelper != null) {
offlineLicenseHelper.releaseResources();
}
offlineLicenseHelper = null;
httpDataSourceFactory = null;
super.tearDown();
}
......@@ -83,7 +86,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
return; // Pass.
}
downloadLicense();
builder.runTest(getActivity(), getInstrumentation());
testRunner.run();
// Renew license after playback should still work
offlineLicenseKeySetId = offlineLicenseHelper.renew(offlineLicenseKeySetId);
......@@ -98,7 +101,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
releaseLicense(); // keySetId no longer valid.
try {
builder.runTest(getActivity(), getInstrumentation());
testRunner.run();
fail("Playback should fail because the license has been released.");
} catch (Throwable e) {
// Get the root cause
......@@ -138,7 +141,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
}
// DefaultDrmSessionManager should renew the license and stream play fine
builder.runTest(getActivity(), getInstrumentation());
testRunner.run();
}
public void testWidevineOfflineLicenseExpiresOnPause() throws Exception {
......@@ -157,9 +160,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
.delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build();
// DefaultDrmSessionManager should renew the license and stream play fine
builder
.setActionSchedule(schedule)
.runTest(getActivity(), getInstrumentation());
testRunner.setActionSchedule(schedule).run();
}
private void downloadLicense() throws InterruptedException, DrmSessionException, IOException {
......@@ -167,7 +168,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
httpDataSourceFactory.createDataSource(), DashTestData.WIDEVINE_H264_MANIFEST);
Assert.assertNotNull(offlineLicenseKeySetId);
Assert.assertTrue(offlineLicenseKeySetId.length > 0);
builder.setOfflineLicenseKeySetId(offlineLicenseKeySetId);
testRunner.setOfflineLicenseKeySetId(offlineLicenseKeySetId);
}
private void releaseLicense() throws DrmSessionException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment