Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #if defined(OS_ANDROID) | 13 #if defined(OS_ANDROID) |
| 14 #include "base/android/build_info.h" | 14 #include "base/android/build_info.h" |
| 15 #include "media/base/media_switches.h" | |
| 15 #endif | 16 #endif |
| 16 | 17 |
| 17 // Available key systems. | 18 // Available key systems. |
| 18 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 19 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 19 | 20 |
| 20 // Supported media types. | 21 // Supported media types. |
| 21 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; | 22 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
| 22 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; | 23 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
| 23 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; | 24 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; |
| 24 | 25 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 42 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { | 43 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { |
| 43 VLOG(0) << "MSE is only supported in Android 4.1 and later."; | 44 VLOG(0) << "MSE is only supported in Android 4.1 and later."; |
| 44 return false; | 45 return false; |
| 45 } | 46 } |
| 46 #endif // defined(OS_ANDROID) | 47 #endif // defined(OS_ANDROID) |
| 47 return true; | 48 return true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 // Tests encrypted media playback with a combination of parameters: | 51 // Tests encrypted media playback with a combination of parameters: |
| 51 // - char*: Key system name. | 52 // - char*: Key system name. |
| 52 // - bool: True to load media using MSE, otherwise use src. | 53 // - bool: True to load media using MSE, otherwise use SRC. |
|
ddorwin
2016/03/30 22:13:03
I think this was referring to .src= rather than th
xhwang
2016/03/30 22:18:01
Done.
| |
| 53 class EncryptedMediaTest : public content::MediaBrowserTest, | 54 class EncryptedMediaTest : public content::MediaBrowserTest, |
| 54 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > { | 55 public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > { |
| 55 public: | 56 public: |
| 56 // Can only be used in parameterized (*_P) tests. | 57 // Can only be used in parameterized (*_P) tests. |
| 57 const std::string CurrentKeySystem() { | 58 const std::string CurrentKeySystem() { |
| 58 return std::tr1::get<0>(GetParam()); | 59 return std::tr1::get<0>(GetParam()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 // Can only be used in parameterized (*_P) tests. | 62 // Can only be used in parameterized (*_P) tests. |
| 62 SrcType CurrentSourceType() { | 63 SrcType CurrentSourceType() { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 // We want to fail quickly when a test fails because an error is encountered. | 124 // We want to fail quickly when a test fails because an error is encountered. |
| 124 void AddWaitForTitles(content::TitleWatcher* title_watcher) override { | 125 void AddWaitForTitles(content::TitleWatcher* title_watcher) override { |
| 125 MediaBrowserTest::AddWaitForTitles(title_watcher); | 126 MediaBrowserTest::AddWaitForTitles(title_watcher); |
| 126 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); | 127 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); |
| 127 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError)); | 128 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError)); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void SetUpCommandLine(base::CommandLine* command_line) override { | 131 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 131 command_line->AppendSwitch( | 132 command_line->AppendSwitch( |
| 132 switches::kDisableGestureRequirementForMediaPlayback); | 133 switches::kDisableGestureRequirementForMediaPlayback); |
| 134 #if defined(OS_ANDROID) | |
| 135 command_line->AppendSwitch(switches::kEnableUnifiedMediaPipeline); | |
| 136 #endif | |
| 133 } | 137 } |
| 134 }; | 138 }; |
| 135 | 139 |
| 136 using ::testing::Combine; | 140 using ::testing::Combine; |
| 137 using ::testing::Values; | 141 using ::testing::Values; |
| 138 | 142 |
| 139 #if !defined(OS_ANDROID) | |
| 140 // Encrypted media playback with SRC is not supported on Android. | |
| 141 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, | 143 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, |
| 142 Combine(Values(kClearKeyKeySystem), Values(SRC))); | 144 Combine(Values(kClearKeyKeySystem), Values(SRC))); |
| 143 #endif // !defined(OS_ANDROID) | |
| 144 | 145 |
| 145 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, | 146 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, |
| 146 Combine(Values(kClearKeyKeySystem), Values(MSE))); | 147 Combine(Values(kClearKeyKeySystem), Values(MSE))); |
| 147 | 148 |
| 148 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 149 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
| 149 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly); | 150 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly); |
| 150 } | 151 } |
| 151 | 152 |
| 152 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { | 153 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
| 153 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo); | 154 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { | 201 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { |
| 201 RunEncryptedMediaTest(kDefaultEmePlayer, | 202 RunEncryptedMediaTest(kDefaultEmePlayer, |
| 202 "bear-a_enc-a.webm", | 203 "bear-a_enc-a.webm", |
| 203 kWebMAudioOnly, | 204 kWebMAudioOnly, |
| 204 "com.example.foo", | 205 "com.example.foo", |
| 205 MSE, | 206 MSE, |
| 206 kEmeNotSupportedError); | 207 kEmeNotSupportedError); |
| 207 } | 208 } |
| 208 | 209 |
| 209 } // namespace content | 210 } // namespace content |
| OLD | NEW |