Chromium Code Reviews| Index: android_webview/javatests/src/org/chromium/android_webview/test/KeySystemTest.java |
| diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/KeySystemTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/KeySystemTest.java |
| index 32ee9aa9af35d789157bf40f995062395e131608..d6ccda90084056140e5aef805fed9c3c8f0a5435 100644 |
| --- a/android_webview/javatests/src/org/chromium/android_webview/test/KeySystemTest.java |
| +++ b/android_webview/javatests/src/org/chromium/android_webview/test/KeySystemTest.java |
| @@ -4,6 +4,7 @@ |
| package org.chromium.android_webview.test; |
| +import android.os.Build; |
| import android.test.suitebuilder.annotation.SmallTest; |
| import org.chromium.android_webview.AwContents; |
| @@ -66,12 +67,17 @@ public class KeySystemTest extends AwTestBase { |
| + " navigator.requestMediaKeySystemAccess(keySystem, [{}]).then(" |
| + " success, failure);" |
| + "}" |
| + + "function areProprietaryCodecsSupported() {" |
| + + " var video = document.createElement('video');" |
| + + " result = video.canPlayType('video/mp4; codecs=\"avc1\"') ?" |
| + + " 'YES' : 'NO';" |
| + + "}" |
| + "</script> </html>"; |
| } |
| private String isKeySystemSupported(String keySystem) throws Exception { |
| executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, |
| - "isKeySystemSupported('" + keySystem + "')"); |
| + "result = null; isKeySystemSupported('" + keySystem + "')"); |
| poll(new Callable<Boolean>() { |
| @Override |
| @@ -83,6 +89,20 @@ public class KeySystemTest extends AwTestBase { |
| return getResultFromJS(); |
| } |
| + private boolean areProprietaryCodecsSupported() throws Exception { |
| + executeJavaScriptAndWaitForResult( |
| + mAwContents, mContentsClient, "result = null; areProprietaryCodecsSupported()"); |
| + |
| + poll(new Callable<Boolean>() { |
| + @Override |
| + public Boolean call() throws Exception { |
| + return !getResultFromJS().equals("null"); |
| + } |
| + }); |
| + |
| + return getResultFromJS().equals("YES"); |
| + } |
| + |
| private String getResultFromJS() { |
| String result = "null"; |
| try { |
| @@ -94,6 +114,18 @@ public class KeySystemTest extends AwTestBase { |
| return result; |
| } |
| + private String getPlatformKeySystemExpectations() throws Exception { |
| + // Android key systems only support proprietary codecs prior to Lollipop. |
|
boliu
2016/03/09 22:23:33
This comment seems backwards. Code says widevine *
DaleCurtis
2016/03/09 23:58:54
Key systems (widevine or test) with non-proprietar
|
| + // When neither is true isKeySystemSupported() will return an error for |
| + // all key systems except ClearKey (which is handled by Chrome itself). |
| + if (!areProprietaryCodecsSupported() |
| + && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { |
| + return "\"NotSupportedError\""; |
| + } |
| + |
| + return "\"supported\""; |
| + } |
| + |
| @Feature({"AndroidWebView"}) |
| @SmallTest |
| public void testSupportClearKeySystem() throws Throwable { |
| @@ -103,7 +135,8 @@ public class KeySystemTest extends AwTestBase { |
| @Feature({"AndroidWebView"}) |
| @SmallTest |
| public void testSupportWidevineKeySystem() throws Throwable { |
| - assertEquals("\"supported\"", isKeySystemSupported("com.widevine.alpha")); |
| + assertEquals( |
| + getPlatformKeySystemExpectations(), isKeySystemSupported("com.widevine.alpha")); |
| } |
| @Feature({"AndroidWebView"}) |
| @@ -115,7 +148,8 @@ public class KeySystemTest extends AwTestBase { |
| @Feature({"AndroidWebView"}) |
| @SmallTest |
| public void testSupportPlatformKeySystem() throws Throwable { |
| - assertEquals("\"supported\"", isKeySystemSupported("x-com.oem.test-keysystem")); |
| + assertEquals(getPlatformKeySystemExpectations(), |
| + isKeySystemSupported("x-com.oem.test-keysystem")); |
| } |
| @Feature({"AndroidWebView"}) |