| 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/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.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 "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 13 | 14 |
| 14 // Available key systems. | 15 // Available key systems. |
| 15 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 16 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| 16 | 17 |
| 17 // Supported media types. | 18 // Supported media types. |
| 18 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; | 19 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
| 19 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; | 20 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
| 20 static const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; | 21 static const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; |
| 21 | 22 |
| 22 // EME-specific test results and errors. | 23 // EME-specific test results and errors. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType()); | 53 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType()); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void TestFrameSizeChange() { | 56 void TestFrameSizeChange() { |
| 56 RunEncryptedMediaTest("encrypted_frame_size_change.html", | 57 RunEncryptedMediaTest("encrypted_frame_size_change.html", |
| 57 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, | 58 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, |
| 58 CurrentKeySystem(), CurrentSourceType(), kEnded); | 59 CurrentKeySystem(), CurrentSourceType(), kEnded); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void TestConfigChange() { | 62 void TestConfigChange() { |
| 63 if (CurrentSourceType() != MSE) { |
| 64 LOG(INFO) << "Skipping test - config change only applies to MSE."; |
| 65 return; |
| 66 } |
| 67 |
| 68 // TODO(xhwang): Update this to check for unprefixed MSE API when |
| 69 // http://crbug.com/307107 is fixed. |
| 70 if (!WebKit::WebRuntimeFeatures::isWebKitMediaSourceEnabled()) { |
| 71 LOG(INFO) << "Could not run test - prefixed MSE not supported."; |
| 72 return; |
| 73 } |
| 74 |
| 62 std::vector<StringPair> query_params; | 75 std::vector<StringPair> query_params; |
| 63 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); | 76 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); |
| 64 query_params.push_back(std::make_pair("runencrypted", "1")); | 77 query_params.push_back(std::make_pair("runencrypted", "1")); |
| 65 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); | 78 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); |
| 66 } | 79 } |
| 67 | 80 |
| 68 void RunEncryptedMediaTest(const char* html_page, | 81 void RunEncryptedMediaTest(const char* html_page, |
| 69 const char* media_file, | 82 const char* media_file, |
| 70 const char* media_type, | 83 const char* media_type, |
| 71 const char* key_system, | 84 const char* key_system, |
| 72 SrcType src_type, | 85 SrcType src_type, |
| 73 const char* expectation) { | 86 const char* expectation) { |
| 87 // TODO(xhwang): Update this to check for unprefixed MSE API when |
| 88 // http://crbug.com/307107 is fixed. |
| 89 if (src_type == MSE && |
| 90 !WebKit::WebRuntimeFeatures::isWebKitMediaSourceEnabled()) { |
| 91 LOG(INFO) << "Could not run test - prefixed MSE not supported."; |
| 92 return; |
| 93 } |
| 94 |
| 74 std::vector<StringPair> query_params; | 95 std::vector<StringPair> query_params; |
| 75 query_params.push_back(std::make_pair("mediafile", media_file)); | 96 query_params.push_back(std::make_pair("mediafile", media_file)); |
| 76 query_params.push_back(std::make_pair("mediatype", media_type)); | 97 query_params.push_back(std::make_pair("mediatype", media_type)); |
| 77 query_params.push_back(std::make_pair("keysystem", key_system)); | 98 query_params.push_back(std::make_pair("keysystem", key_system)); |
| 78 if (src_type == MSE) | 99 if (src_type == MSE) |
| 79 query_params.push_back(std::make_pair("usemse", "1")); | 100 query_params.push_back(std::make_pair("usemse", "1")); |
| 80 RunMediaTestPage(html_page, &query_params, expectation, true); | 101 RunMediaTestPage(html_page, &query_params, expectation, true); |
| 81 } | 102 } |
| 82 | 103 |
| 83 void RunSimpleEncryptedMediaTest(const char* media_file, | 104 void RunSimpleEncryptedMediaTest(const char* media_file, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 #endif | 125 #endif |
| 105 }; | 126 }; |
| 106 | 127 |
| 107 using ::testing::Combine; | 128 using ::testing::Combine; |
| 108 using ::testing::Values; | 129 using ::testing::Values; |
| 109 | 130 |
| 110 #if !defined(OS_ANDROID) | 131 #if !defined(OS_ANDROID) |
| 111 // Encrypted media playback with SRC is not supported on Android. | 132 // Encrypted media playback with SRC is not supported on Android. |
| 112 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, | 133 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, |
| 113 Combine(Values(kClearKeyKeySystem), Values(SRC))); | 134 Combine(Values(kClearKeyKeySystem), Values(SRC))); |
| 114 #endif // defined(OS_ANDROID) | 135 #endif // !defined(OS_ANDROID) |
| 115 | 136 |
| 116 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, | 137 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, |
| 117 Combine(Values(kClearKeyKeySystem), Values(MSE))); | 138 Combine(Values(kClearKeyKeySystem), Values(MSE))); |
| 118 | 139 |
| 119 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 140 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
| 120 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); | 141 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); |
| 121 } | 142 } |
| 122 | 143 |
| 123 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { | 144 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
| 124 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); | 145 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 149 TestFrameSizeChange(); | 170 TestFrameSizeChange(); |
| 150 } | 171 } |
| 151 | 172 |
| 152 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { | 173 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { |
| 153 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm", | 174 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm", |
| 154 kWebMAudioOnly, "com.example.foo", MSE, | 175 kWebMAudioOnly, "com.example.foo", MSE, |
| 155 kEmeGkrException); | 176 kEmeGkrException); |
| 156 } | 177 } |
| 157 | 178 |
| 158 } // namespace content | 179 } // namespace content |
| OLD | NEW |