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 { ...@@ -137,6 +137,16 @@ public final class DashTestData {
WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID, WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID,
WIDEVINE_VP9_360P_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() { private DashTestData() {
} }
......
...@@ -37,7 +37,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -37,7 +37,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
private static final String TAG = "DashWidevineOfflineTest"; private static final String TAG = "DashWidevineOfflineTest";
private static final String USER_AGENT = "ExoPlayerPlaybackTests"; private static final String USER_AGENT = "ExoPlayerPlaybackTests";
private DashHostedTest.Builder builder; private DashTestRunner testRunner;
private DefaultHttpDataSourceFactory httpDataSourceFactory; private DefaultHttpDataSourceFactory httpDataSourceFactory;
private OfflineLicenseHelper<FrameworkMediaCrypto> offlineLicenseHelper; private OfflineLicenseHelper<FrameworkMediaCrypto> offlineLicenseHelper;
private byte[] offlineLicenseKeySetId; private byte[] offlineLicenseKeySetId;
...@@ -49,7 +49,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -49,7 +49,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
builder = new DashHostedTest.Builder(TAG) testRunner = new DashTestRunner(TAG, getActivity(), getInstrumentation())
.setStreamName("test_widevine_h264_fixed_offline") .setStreamName("test_widevine_h264_fixed_offline")
.setManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST) .setManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST)
.setWidevineMimeType(MimeTypes.VIDEO_H264) .setWidevineMimeType(MimeTypes.VIDEO_H264)
...@@ -58,8 +58,8 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -58,8 +58,8 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
.setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID,
DashTestData.WIDEVINE_H264_CDD_FIXED); DashTestData.WIDEVINE_H264_CDD_FIXED);
boolean useL1Widevine = DashHostedTest.isL1WidevineAvailable(MimeTypes.VIDEO_H264); boolean useL1Widevine = DashTestRunner.isL1WidevineAvailable(MimeTypes.VIDEO_H264);
String widevineLicenseUrl = DashHostedTest.getWidevineLicenseUrl(useL1Widevine); String widevineLicenseUrl = DashTestData.getWidevineLicenseUrl(useL1Widevine);
httpDataSourceFactory = new DefaultHttpDataSourceFactory(USER_AGENT); httpDataSourceFactory = new DefaultHttpDataSourceFactory(USER_AGENT);
offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(widevineLicenseUrl, offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(widevineLicenseUrl,
httpDataSourceFactory); httpDataSourceFactory);
...@@ -67,12 +67,15 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -67,12 +67,15 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
testRunner = null;
if (offlineLicenseKeySetId != null) { if (offlineLicenseKeySetId != null) {
releaseLicense(); releaseLicense();
} }
if (offlineLicenseHelper != null) { if (offlineLicenseHelper != null) {
offlineLicenseHelper.releaseResources(); offlineLicenseHelper.releaseResources();
} }
offlineLicenseHelper = null;
httpDataSourceFactory = null;
super.tearDown(); super.tearDown();
} }
...@@ -83,7 +86,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -83,7 +86,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
return; // Pass. return; // Pass.
} }
downloadLicense(); downloadLicense();
builder.runTest(getActivity(), getInstrumentation()); testRunner.run();
// Renew license after playback should still work // Renew license after playback should still work
offlineLicenseKeySetId = offlineLicenseHelper.renew(offlineLicenseKeySetId); offlineLicenseKeySetId = offlineLicenseHelper.renew(offlineLicenseKeySetId);
...@@ -98,7 +101,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -98,7 +101,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
releaseLicense(); // keySetId no longer valid. releaseLicense(); // keySetId no longer valid.
try { try {
builder.runTest(getActivity(), getInstrumentation()); testRunner.run();
fail("Playback should fail because the license has been released."); fail("Playback should fail because the license has been released.");
} catch (Throwable e) { } catch (Throwable e) {
// Get the root cause // Get the root cause
...@@ -138,7 +141,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -138,7 +141,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
} }
// DefaultDrmSessionManager should renew the license and stream play fine // DefaultDrmSessionManager should renew the license and stream play fine
builder.runTest(getActivity(), getInstrumentation()); testRunner.run();
} }
public void testWidevineOfflineLicenseExpiresOnPause() throws Exception { public void testWidevineOfflineLicenseExpiresOnPause() throws Exception {
...@@ -157,9 +160,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -157,9 +160,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
.delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build(); .delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build();
// DefaultDrmSessionManager should renew the license and stream play fine // DefaultDrmSessionManager should renew the license and stream play fine
builder testRunner.setActionSchedule(schedule).run();
.setActionSchedule(schedule)
.runTest(getActivity(), getInstrumentation());
} }
private void downloadLicense() throws InterruptedException, DrmSessionException, IOException { private void downloadLicense() throws InterruptedException, DrmSessionException, IOException {
...@@ -167,7 +168,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -167,7 +168,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
httpDataSourceFactory.createDataSource(), DashTestData.WIDEVINE_H264_MANIFEST); httpDataSourceFactory.createDataSource(), DashTestData.WIDEVINE_H264_MANIFEST);
Assert.assertNotNull(offlineLicenseKeySetId); Assert.assertNotNull(offlineLicenseKeySetId);
Assert.assertTrue(offlineLicenseKeySetId.length > 0); Assert.assertTrue(offlineLicenseKeySetId.length > 0);
builder.setOfflineLicenseKeySetId(offlineLicenseKeySetId); testRunner.setOfflineLicenseKeySetId(offlineLicenseKeySetId);
} }
private void releaseLicense() throws DrmSessionException { 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