Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: content/browser/media/encrypted_media_browsertest.cc

Issue 2268283003: media: Add External Clear Key content browser test on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/media/media_browsertest.h" 9 #include "content/browser/media/media_browsertest.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
11 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/browser_test_utils.h"
12 #include "content/shell/browser/shell.h" 12 #include "content/shell/browser/shell.h"
13
13 #if defined(OS_ANDROID) 14 #if defined(OS_ANDROID)
14 #include "base/android/build_info.h" 15 #include "base/android/build_info.h"
15 #include "media/base/media.h" 16 #include "media/base/media.h"
17 #include "media/base/media_switches.h"
16 #endif 18 #endif
17 19
18 #if defined(ENABLE_MOJO_RENDERER) 20 #if defined(ENABLE_MOJO_RENDERER)
19 // TODO(xhwang): Enable tests by running AesDecryptor in remote mojo CDM and 21 // TODO(xhwang): Enable tests by running AesDecryptor in remote mojo CDM and
20 // using ExternalClearKey instead of ClearKey: crbug.com/641559 22 // using ExternalClearKey instead of ClearKey: crbug.com/641559
21 #define DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS 1 23 #define DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS 1
22 #endif 24 #endif
23 25
24 // Available key systems. 26 // Available key systems.
25 const char kClearKeyKeySystem[] = "org.w3.clearkey"; 27 const char kClearKeyKeySystem[] = "org.w3.clearkey";
26 28
29 #if defined(OS_ANDROID)
30 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
31 #endif
32
27 // Supported media types. 33 // Supported media types.
28 const char kWebMVorbisAudioOnly[] = "audio/webm; codecs=\"vorbis\""; 34 const char kWebMVorbisAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
29 #if !defined(DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS) 35 #if !defined(DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS)
30 const char kWebMOpusAudioOnly[] = "audio/webm; codecs=\"opus\""; 36 const char kWebMOpusAudioOnly[] = "audio/webm; codecs=\"opus\"";
31 const char kWebMVP8VideoOnly[] = "video/webm; codecs=\"vp8\""; 37 const char kWebMVP8VideoOnly[] = "video/webm; codecs=\"vp8\"";
32 const char kWebMOpusAudioVP9Video[] = "video/webm; codecs=\"opus, vp9\""; 38 const char kWebMOpusAudioVP9Video[] = "video/webm; codecs=\"opus, vp9\"";
33 #endif 39 #endif
34 const char kWebMVorbisAudioVP8Video[] = "video/webm; codecs=\"vorbis, vp8\""; 40 const char kWebMVorbisAudioVP8Video[] = "video/webm; codecs=\"vorbis, vp8\"";
35 41
36 // EME-specific test results and errors. 42 // EME-specific test results and errors.
(...skipping 16 matching lines...) Expand all
53 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { 59 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
54 VLOG(0) << "MSE is only supported in Android 4.1 and later."; 60 VLOG(0) << "MSE is only supported in Android 4.1 and later.";
55 return false; 61 return false;
56 } 62 }
57 #endif // defined(OS_ANDROID) 63 #endif // defined(OS_ANDROID)
58 return true; 64 return true;
59 } 65 }
60 66
61 // Tests encrypted media playback with a combination of parameters: 67 // Tests encrypted media playback with a combination of parameters:
62 // - char*: Key system name. 68 // - char*: Key system name.
63 // - bool: True to load media using MSE, otherwise use src. 69 // - SrcType: The type of video src used to load media, MSE or SRC.
70 // It is okay to run this test as a non-parameterized test, in this case,
71 // GetParam() should not be called.
64 class EncryptedMediaTest : public content::MediaBrowserTest, 72 class EncryptedMediaTest : public content::MediaBrowserTest,
65 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > { 73 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > {
66 public: 74 public:
67 // Can only be used in parameterized (*_P) tests. 75 // Can only be used in parameterized (*_P) tests.
68 const std::string CurrentKeySystem() { 76 const std::string CurrentKeySystem() {
69 return std::tr1::get<0>(GetParam()); 77 return std::tr1::get<0>(GetParam());
70 } 78 }
71 79
72 // Can only be used in parameterized (*_P) tests. 80 // Can only be used in parameterized (*_P) tests.
73 SrcType CurrentSourceType() { 81 SrcType CurrentSourceType() {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // We want to fail quickly when a test fails because an error is encountered. 143 // We want to fail quickly when a test fails because an error is encountered.
136 void AddTitlesToAwait(content::TitleWatcher* title_watcher) override { 144 void AddTitlesToAwait(content::TitleWatcher* title_watcher) override {
137 MediaBrowserTest::AddTitlesToAwait(title_watcher); 145 MediaBrowserTest::AddTitlesToAwait(title_watcher);
138 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); 146 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError));
139 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError)); 147 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError));
140 } 148 }
141 149
142 void SetUpCommandLine(base::CommandLine* command_line) override { 150 void SetUpCommandLine(base::CommandLine* command_line) override {
143 command_line->AppendSwitch( 151 command_line->AppendSwitch(
144 switches::kDisableGestureRequirementForMediaPlayback); 152 switches::kDisableGestureRequirementForMediaPlayback);
153 #if defined(OS_ANDROID)
154 command_line->AppendSwitchASCII(switches::kEnableFeatures,
155 media::kExternalClearKeyForTesting.name);
156 #endif
145 } 157 }
146 }; 158 };
147 159
148 using ::testing::Combine; 160 using ::testing::Combine;
149 using ::testing::Values; 161 using ::testing::Values;
150 162
151 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, 163 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest,
152 Combine(Values(kClearKeyKeySystem), Values(SRC))); 164 Combine(Values(kClearKeyKeySystem), Values(SRC)));
153 165
154 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, 166 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 TestFrameSizeChange(); 220 TestFrameSizeChange();
209 } 221 }
210 #endif // !defined(DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS) 222 #endif // !defined(DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS)
211 223
212 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { 224 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) {
213 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", 225 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
214 kWebMVorbisAudioOnly, "com.example.foo", MSE, 226 kWebMVorbisAudioOnly, "com.example.foo", MSE,
215 kEmeNotSupportedError); 227 kEmeNotSupportedError);
216 } 228 }
217 229
230 #if defined(OS_ANDROID)
231 // On Android, External Clear Key is supported in //content/shell/ by using mojo
232 // CDM with AesDecryptor running in the GPU process.
233 // On other platforms, External Clear Key is supported in chrome/, so it is
234 // tested in browser_tests.
235 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, ExternalClearKeyPlayback) {
236 RunSimpleEncryptedMediaTest("bear-320x240-av_enc-av.webm",
237 kWebMVorbisAudioVP8Video,
238 kExternalClearKeyKeySystem, MSE);
239 }
240 #endif
241
218 } // namespace content 242 } // namespace content
OLDNEW
« no previous file with comments | « components/cdm/renderer/external_clear_key_key_system_properties.cc ('k') | content/shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698