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

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

Issue 1996863002: media: Use bundled Widevine CDM in encrypted media browser tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/media/media_browsertest.h" 13 #include "chrome/browser/media/media_browsertest.h"
14 #include "chrome/browser/media/test_license_server.h" 14 #include "chrome/browser/media/test_license_server.h"
15 #include "chrome/browser/media/wv_test_license_server_config.h" 15 #include "chrome/browser/media/wv_test_license_server_config.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/test_launcher_utils.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
21 #include "testing/gtest/include/gtest/gtest-spi.h" 22 #include "testing/gtest/include/gtest/gtest-spi.h"
22 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
23 #include "base/android/build_info.h" 24 #include "base/android/build_info.h"
24 #endif 25 #endif
25 26
26 #if defined(ENABLE_PEPPER_CDMS) 27 #if defined(ENABLE_PEPPER_CDMS)
27 #include "chrome/browser/media/pepper_cdm_test_helper.h" 28 #include "chrome/browser/media/pepper_cdm_test_helper.h"
28 #endif 29 #endif
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 DVLOG(0) << "MSE is only supported in Android 4.1 and later."; 92 DVLOG(0) << "MSE is only supported in Android 4.1 and later.";
92 return false; 93 return false;
93 } 94 }
94 #endif // defined(OS_ANDROID) 95 #endif // defined(OS_ANDROID)
95 return true; 96 return true;
96 } 97 }
97 98
98 // Base class for encrypted media tests. 99 // Base class for encrypted media tests.
99 class EncryptedMediaTestBase : public MediaBrowserTest { 100 class EncryptedMediaTestBase : public MediaBrowserTest {
100 public: 101 public:
101 EncryptedMediaTestBase() {}
102
103 bool IsExternalClearKey(const std::string& key_system) { 102 bool IsExternalClearKey(const std::string& key_system) {
104 if (key_system == kExternalClearKeyKeySystem) 103 if (key_system == kExternalClearKeyKeySystem)
105 return true; 104 return true;
106 std::string prefix = std::string(kExternalClearKeyKeySystem) + '.'; 105 std::string prefix = std::string(kExternalClearKeyKeySystem) + '.';
107 return key_system.substr(0, prefix.size()) == prefix; 106 return key_system.substr(0, prefix.size()) == prefix;
108 } 107 }
109 108
110 #if defined(WIDEVINE_CDM_AVAILABLE) 109 #if defined(WIDEVINE_CDM_AVAILABLE)
111 bool IsWidevine(const std::string& key_system) { 110 bool IsWidevine(const std::string& key_system) {
112 return key_system == kWidevineKeySystem; 111 return key_system == kWidevineKeySystem;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 base::ASCIIToUTF16(kEmeMessageUnexpectedType)); 233 base::ASCIIToUTF16(kEmeMessageUnexpectedType));
235 title_watcher->AlsoWaitForTitle( 234 title_watcher->AlsoWaitForTitle(
236 base::ASCIIToUTF16(kEmeRenewalMissingHeader)); 235 base::ASCIIToUTF16(kEmeRenewalMissingHeader));
237 } 236 }
238 237
239 void SetUpCommandLine(base::CommandLine* command_line) override { 238 void SetUpCommandLine(base::CommandLine* command_line) override {
240 command_line->AppendSwitch( 239 command_line->AppendSwitch(
241 switches::kDisableGestureRequirementForMediaPlayback); 240 switches::kDisableGestureRequirementForMediaPlayback);
242 } 241 }
243 242
243 #if defined(ENABLE_PEPPER_CDMS)
244 void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
245 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM);
246 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line);
247 test_launcher_utils::RemoveCommandLineSwitch(
248 default_command_line, switches::kDisableComponentUpdate, command_line);
249 }
250 #endif // defined(ENABLE_PEPPER_CDMS)
251
244 void SetUpCommandLineForKeySystem(const std::string& key_system, 252 void SetUpCommandLineForKeySystem(const std::string& key_system,
245 base::CommandLine* command_line) { 253 base::CommandLine* command_line) {
246 if (GetServerConfig(key_system)) 254 if (GetServerConfig(key_system))
247 // Since the web and license servers listen on different ports, we need to 255 // Since the web and license servers listen on different ports, we need to
248 // disable web-security to send license requests to the license server. 256 // disable web-security to send license requests to the license server.
249 // TODO(shadi): Add port forwarding to the test web server configuration. 257 // TODO(shadi): Add port forwarding to the test web server configuration.
250 command_line->AppendSwitch(switches::kDisableWebSecurity); 258 command_line->AppendSwitch(switches::kDisableWebSecurity);
251 259
252 #if defined(ENABLE_PEPPER_CDMS) 260 #if defined(ENABLE_PEPPER_CDMS)
253 if (IsExternalClearKey(key_system)) { 261 if (IsExternalClearKey(key_system)) {
254 RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory, 262 RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory,
255 kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName, 263 kClearKeyCdmAdapterFileName, kClearKeyCdmDisplayName,
256 kClearKeyCdmPepperMimeType); 264 kClearKeyCdmPepperMimeType);
257 } 265 }
258 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
259 else if (IsWidevine(key_system)) { // NOLINT
260 RegisterPepperCdm(command_line, kWidevineCdmBaseDirectory,
261 kWidevineCdmAdapterFileName, kWidevineCdmDisplayName,
262 kWidevineCdmPluginMimeType);
263 }
264 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
265 #endif // defined(ENABLE_PEPPER_CDMS) 266 #endif // defined(ENABLE_PEPPER_CDMS)
266 } 267 }
267 }; 268 };
268 269
269 #if defined(ENABLE_PEPPER_CDMS) 270 #if defined(ENABLE_PEPPER_CDMS)
270 // Tests encrypted media playback using ExternalClearKey key system in 271 // Tests encrypted media playback using ExternalClearKey key system in
271 // decrypt-and-decode mode. 272 // decrypt-and-decode mode.
272 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { 273 class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
273 public: 274 public:
274 // We use special |key_system| names to do non-playback related tests, e.g. 275 // We use special |key_system| names to do non-playback related tests, e.g.
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 624
624 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { 625 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
625 TestPlaybackCase(kLoadableSession, kEnded); 626 TestPlaybackCase(kLoadableSession, kEnded);
626 } 627 }
627 628
628 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { 629 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
629 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound); 630 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound);
630 } 631 }
631 632
632 #endif // defined(ENABLE_PEPPER_CDMS) 633 #endif // defined(ENABLE_PEPPER_CDMS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698