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

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

Issue 27230004: Do not run MSE related tests when MSE is not available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Comments Created 7 years, 2 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 | Annotate | Revision Log
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/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 #if defined(OS_ANDROID)
14 #include "base/android/build_info.h"
15 #endif
13 16
14 // Available key systems. 17 // Available key systems.
15 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; 18 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
16 19
17 // Supported media types. 20 // Supported media types.
18 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; 21 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\"";
19 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; 22 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\"";
20 static const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; 23 static const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\"";
21 24
22 // EME-specific test results and errors. 25 // EME-specific test results and errors.
(...skipping 29 matching lines...) Expand all
52 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType()); 55 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType());
53 } 56 }
54 57
55 void TestFrameSizeChange() { 58 void TestFrameSizeChange() {
56 RunEncryptedMediaTest("encrypted_frame_size_change.html", 59 RunEncryptedMediaTest("encrypted_frame_size_change.html",
57 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, 60 "frame_size_change-av-enc-v.webm", kWebMAudioVideo,
58 CurrentKeySystem(), CurrentSourceType(), kEnded); 61 CurrentKeySystem(), CurrentSourceType(), kEnded);
59 } 62 }
60 63
61 void TestConfigChange() { 64 void TestConfigChange() {
65 if (CurrentSourceType() != MSE) {
66 LOG(INFO) << "Skipping test - config change only applies to MSE.";
67 return;
68 }
69
70 #if defined(OS_ANDROID)
71 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
72 LOG(INFO) << "Skipping test - MSE only supported in JellyBean and later.";
73 return;
74 }
75 #endif // defined(OS_ANDROID)
76
62 std::vector<StringPair> query_params; 77 std::vector<StringPair> query_params;
63 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); 78 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem()));
64 query_params.push_back(std::make_pair("runencrypted", "1")); 79 query_params.push_back(std::make_pair("runencrypted", "1"));
65 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); 80 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true);
66 } 81 }
67 82
68 void RunEncryptedMediaTest(const char* html_page, 83 void RunEncryptedMediaTest(const char* html_page,
69 const char* media_file, 84 const char* media_file,
70 const char* media_type, 85 const char* media_type,
71 const char* key_system, 86 const char* key_system,
72 SrcType src_type, 87 SrcType src_type,
73 const char* expectation) { 88 const char* expectation) {
89 #if defined(OS_ANDROID)
90 DCHECK_EQ(src_type, MSE) << "EME only works with MSE on Android.";
91 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) {
92 LOG(INFO) << "Skipping test - MSE only supported in JellyBean and later.";
93 return;
94 }
95 #endif // defined(OS_ANDROID)
96
74 std::vector<StringPair> query_params; 97 std::vector<StringPair> query_params;
75 query_params.push_back(std::make_pair("mediafile", media_file)); 98 query_params.push_back(std::make_pair("mediafile", media_file));
76 query_params.push_back(std::make_pair("mediatype", media_type)); 99 query_params.push_back(std::make_pair("mediatype", media_type));
77 query_params.push_back(std::make_pair("keysystem", key_system)); 100 query_params.push_back(std::make_pair("keysystem", key_system));
78 if (src_type == MSE) 101 if (src_type == MSE)
79 query_params.push_back(std::make_pair("usemse", "1")); 102 query_params.push_back(std::make_pair("usemse", "1"));
80 RunMediaTestPage(html_page, &query_params, expectation, true); 103 RunMediaTestPage(html_page, &query_params, expectation, true);
81 } 104 }
82 105
83 void RunSimpleEncryptedMediaTest(const char* media_file, 106 void RunSimpleEncryptedMediaTest(const char* media_file,
(...skipping 20 matching lines...) Expand all
104 #endif 127 #endif
105 }; 128 };
106 129
107 using ::testing::Combine; 130 using ::testing::Combine;
108 using ::testing::Values; 131 using ::testing::Values;
109 132
110 #if !defined(OS_ANDROID) 133 #if !defined(OS_ANDROID)
111 // Encrypted media playback with SRC is not supported on Android. 134 // Encrypted media playback with SRC is not supported on Android.
112 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest, 135 INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest,
113 Combine(Values(kClearKeyKeySystem), Values(SRC))); 136 Combine(Values(kClearKeyKeySystem), Values(SRC)));
114 #endif // defined(OS_ANDROID) 137 #endif // !defined(OS_ANDROID)
115 138
116 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, 139 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
117 Combine(Values(kClearKeyKeySystem), Values(MSE))); 140 Combine(Values(kClearKeyKeySystem), Values(MSE)));
118 141
119 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { 142 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
120 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); 143 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly);
121 } 144 }
122 145
123 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { 146 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
124 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); 147 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo);
(...skipping 24 matching lines...) Expand all
149 TestFrameSizeChange(); 172 TestFrameSizeChange();
150 } 173 }
151 174
152 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) { 175 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) {
153 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm", 176 RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm",
154 kWebMAudioOnly, "com.example.foo", MSE, 177 kWebMAudioOnly, "com.example.foo", MSE,
155 kEmeGkrException); 178 kEmeGkrException);
156 } 179 }
157 180
158 } // namespace content 181 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698