| 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 #include "media/base/media.h" |
| 14 #include "media/base/media_switches.h" |
| 13 | 15 |
| 14 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 15 #include "base/android/build_info.h" | 17 #include "base/android/build_info.h" |
| 16 #include "media/base/media.h" | |
| 17 #include "media/base/media_switches.h" | |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 #if defined(ENABLE_MOJO_RENDERER) | 20 // MojoCdm supports Clear Key, but currently MojoRenderer cannot use it. |
| 21 // TODO(xhwang): Enable tests by running AesDecryptor in remote mojo CDM and | 21 // See http://crbug.com/441957 for details. |
| 22 // using ExternalClearKey instead of ClearKey: crbug.com/641559 | 22 #if !(defined(ENABLE_MOJO_CDM) && defined(ENABLE_MOJO_RENDERER)) |
| 23 #define DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS 1 | 23 #define SUPPORTS_CLEAR_KEY_IN_CONTENT_SHELL |
| 24 #endif |
| 25 |
| 26 #if defined(ENABLE_MOJO_CDM) |
| 27 // When mojo CDM is enabled, External Clear Key is supported in //content/shell/ |
| 28 // by using mojo CDM with AesDecryptor running in the remote (e.g. GPU or |
| 29 // Browser) process. |
| 30 // Note that External Clear Key is also supported in chrome/ when pepper CDM is |
| 31 // used, which is tested in browser_tests. |
| 32 #define SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL |
| 24 #endif | 33 #endif |
| 25 | 34 |
| 26 // Available key systems. | 35 // Available key systems. |
| 36 #if defined(SUPPORTS_CLEAR_KEY_IN_CONTENT_SHELL) |
| 27 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 37 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
| 38 #endif |
| 28 | 39 |
| 29 #if defined(OS_ANDROID) | 40 #if defined(SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL) |
| 30 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; | 41 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
| 31 #endif | 42 #endif |
| 32 | 43 |
| 33 // Supported media types. | 44 // Supported media types. |
| 34 const char kWebMVorbisAudioOnly[] = "audio/webm; codecs=\"vorbis\""; | 45 const char kWebMVorbisAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
| 35 #if !defined(DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS) | |
| 36 const char kWebMOpusAudioOnly[] = "audio/webm; codecs=\"opus\""; | 46 const char kWebMOpusAudioOnly[] = "audio/webm; codecs=\"opus\""; |
| 37 const char kWebMVP8VideoOnly[] = "video/webm; codecs=\"vp8\""; | 47 const char kWebMVP8VideoOnly[] = "video/webm; codecs=\"vp8\""; |
| 38 const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\""; | 48 const char kWebMVP9VideoOnly[] = "video/webm; codecs=\"vp9\""; |
| 39 const char kWebMOpusAudioVP9Video[] = "video/webm; codecs=\"opus, vp9\""; | 49 const char kWebMOpusAudioVP9Video[] = "video/webm; codecs=\"opus, vp9\""; |
| 40 #endif | |
| 41 const char kWebMVorbisAudioVP8Video[] = "video/webm; codecs=\"vorbis, vp8\""; | 50 const char kWebMVorbisAudioVP8Video[] = "video/webm; codecs=\"vorbis, vp8\""; |
| 42 | 51 |
| 43 // EME-specific test results and errors. | 52 // EME-specific test results and errors. |
| 44 const char kEmeKeyError[] = "KEYERROR"; | 53 const char kEmeKeyError[] = "KEYERROR"; |
| 45 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; | 54 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR"; |
| 46 | 55 |
| 47 const char kDefaultEmePlayer[] = "eme_player.html"; | 56 const char kDefaultEmePlayer[] = "eme_player.html"; |
| 48 | 57 |
| 49 // The type of video src used to load media. | 58 // The type of video src used to load media. |
| 50 enum SrcType { | 59 enum SrcType { |
| (...skipping 72 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. | 132 // We want to fail quickly when a test fails because an error is encountered. |
| 124 void AddTitlesToAwait(content::TitleWatcher* title_watcher) override { | 133 void AddTitlesToAwait(content::TitleWatcher* title_watcher) override { |
| 125 MediaBrowserTest::AddTitlesToAwait(title_watcher); | 134 MediaBrowserTest::AddTitlesToAwait(title_watcher); |
| 126 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); | 135 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError)); |
| 127 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError)); | 136 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError)); |
| 128 } | 137 } |
| 129 | 138 |
| 130 void SetUpCommandLine(base::CommandLine* command_line) override { | 139 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 131 command_line->AppendSwitch( | 140 command_line->AppendSwitch( |
| 132 switches::kDisableGestureRequirementForMediaPlayback); | 141 switches::kDisableGestureRequirementForMediaPlayback); |
| 133 #if defined(OS_ANDROID) | 142 #if defined(SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL) |
| 134 command_line->AppendSwitchASCII(switches::kEnableFeatures, | 143 command_line->AppendSwitchASCII(switches::kEnableFeatures, |
| 135 media::kExternalClearKeyForTesting.name); | 144 media::kExternalClearKeyForTesting.name); |
| 136 #endif | 145 #endif |
| 137 } | 146 } |
| 138 }; | 147 }; |
| 139 | 148 |
| 140 using ::testing::Combine; | 149 using ::testing::Combine; |
| 141 using ::testing::Values; | 150 using ::testing::Values; |
| 142 | 151 |
| 152 #if defined(SUPPORTS_CLEAR_KEY_IN_CONTENT_SHELL) |
| 143 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, | 153 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, |
| 144 Combine(Values(kClearKeyKeySystem), Values(SRC))); | 154 Combine(Values(kClearKeyKeySystem), Values(SRC))); |
| 145 | 155 |
| 146 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, | 156 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, |
| 147 Combine(Values(kClearKeyKeySystem), Values(MSE))); | 157 Combine(Values(kClearKeyKeySystem), Values(MSE))); |
| 158 #endif |
| 148 | 159 |
| 149 #if !defined(DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS) | 160 #if defined(SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL) |
| 161 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, |
| 162 EncryptedMediaTest, |
| 163 Combine(Values(kExternalClearKeyKeySystem), |
| 164 Values(SRC))); |
| 165 |
| 166 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, |
| 167 EncryptedMediaTest, |
| 168 Combine(Values(kExternalClearKeyKeySystem), |
| 169 Values(MSE))); |
| 170 #endif |
| 171 |
| 150 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 172 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
| 151 TestSimplePlayback("bear-a_enc-a.webm", kWebMVorbisAudioOnly); | 173 TestSimplePlayback("bear-a_enc-a.webm", kWebMVorbisAudioOnly); |
| 152 } | 174 } |
| 153 | 175 |
| 154 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { | 176 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
| 155 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMVorbisAudioVP8Video); | 177 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMVorbisAudioVP8Video); |
| 156 } | 178 } |
| 157 | 179 |
| 158 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { | 180 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { |
| 159 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMVorbisAudioVP8Video); | 181 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMVorbisAudioVP8Video); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVP9Video); | 224 TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVP9Video); |
| 203 } | 225 } |
| 204 | 226 |
| 205 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { | 227 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { |
| 206 TestConfigChange(); | 228 TestConfigChange(); |
| 207 } | 229 } |
| 208 | 230 |
| 209 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) { | 231 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) { |
| 210 TestFrameSizeChange(); | 232 TestFrameSizeChange(); |
| 211 } | 233 } |
| 212 #endif // !defined(DISABLE_ENCRYPTED_MEDIA_PLAYBACK_TESTS) | |
| 213 | 234 |
| 214 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { | 235 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { |
| 215 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", | 236 RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm", |
| 216 kWebMVorbisAudioOnly, "com.example.foo", MSE, | 237 kWebMVorbisAudioOnly, "com.example.foo", MSE, |
| 217 kEmeNotSupportedError); | 238 kEmeNotSupportedError); |
| 218 } | 239 } |
| 219 | 240 |
| 220 #if defined(OS_ANDROID) | |
| 221 // On Android, External Clear Key is supported in //content/shell/ by using mojo | |
| 222 // CDM with AesDecryptor running in the GPU process. | |
| 223 // On other platforms, External Clear Key is supported in chrome/, so it is | |
| 224 // tested in browser_tests. | |
| 225 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, ExternalClearKeyPlayback) { | |
| 226 RunSimpleEncryptedMediaTest("bear-320x240-av_enc-av.webm", | |
| 227 kWebMVorbisAudioVP8Video, | |
| 228 kExternalClearKeyKeySystem, MSE); | |
| 229 } | |
| 230 #endif | |
| 231 | |
| 232 } // namespace content | 241 } // namespace content |
| OLD | NEW |