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

Side by Side Diff: trunk/src/content/browser/media/media_browsertest.cc

Issue 383063009: Revert 282795 "Have media content and chrome browser tests load ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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 "content/browser/media/media_browsertest.h" 5 #include "content/browser/media/media_browsertest.h"
6 6
7 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/common/url_constants.h"
9 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/browser_test_utils.h"
10 #include "content/public/test/content_browser_test_utils.h" 12 #include "content/public/test/content_browser_test_utils.h"
11 #include "content/shell/browser/shell.h" 13 #include "content/shell/browser/shell.h"
12 14
13 // TODO(wolenetz): Fix Media.YUV* tests on MSVS 2012 x64. crbug.com/180074 15 // TODO(wolenetz): Fix Media.YUV* tests on MSVS 2012 x64. crbug.com/180074
14 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) && _MSC_VER == 1700 16 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) && _MSC_VER == 1700
15 #define MAYBE(x) DISABLED_##x 17 #define MAYBE(x) DISABLED_##x
16 #else 18 #else
17 #define MAYBE(x) x 19 #define MAYBE(x) x
18 #endif 20 #endif
19 21
20 namespace content { 22 namespace content {
21 23
22 // Common test results. 24 // Common test results.
23 const char MediaBrowserTest::kEnded[] = "ENDED"; 25 const char MediaBrowserTest::kEnded[] = "ENDED";
24 const char MediaBrowserTest::kError[] = "ERROR"; 26 const char MediaBrowserTest::kError[] = "ERROR";
25 const char MediaBrowserTest::kFailed[] = "FAILED"; 27 const char MediaBrowserTest::kFailed[] = "FAILED";
26 28
27 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, 29 void MediaBrowserTest::RunMediaTestPage(
28 const media::QueryParams& query_params, 30 const char* html_page, std::vector<StringPair>* query_params,
29 const std::string& expected_title, 31 const char* expected, bool http) {
30 bool http) {
31 GURL gurl; 32 GURL gurl;
32 std::string query = media::GetURLQueryString(query_params); 33 std::string query = "";
33 scoped_ptr<net::SpawnedTestServer> http_test_server; 34 if (query_params != NULL && !query_params->empty()) {
35 std::vector<StringPair>::const_iterator itr = query_params->begin();
36 query = base::StringPrintf("%s=%s", itr->first, itr->second);
37 ++itr;
38 for (; itr != query_params->end(); ++itr) {
39 query.append(base::StringPrintf("&%s=%s", itr->first, itr->second));
40 }
41 }
34 if (http) { 42 if (http) {
35 http_test_server = media::StartMediaHttpTestServer(); 43 ASSERT_TRUE(test_server()->Start());
36 gurl = http_test_server->GetURL("files/" + html_page + "?" + query); 44 gurl = test_server()->GetURL(
45 base::StringPrintf("files/media/%s?%s", html_page, query.c_str()));
37 } else { 46 } else {
38 gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page), 47 base::FilePath test_file_path = GetTestFilePath("media", html_page);
39 query); 48 gurl = GetFileUrlWithQuery(test_file_path, query);
40 } 49 }
41 std::string final_title = RunTest(gurl, expected_title); 50 RunTest(gurl, expected);
51 }
52
53 void MediaBrowserTest::RunTest(const GURL& gurl, const char* expected) {
54 const base::string16 expected_title = base::ASCIIToUTF16(expected);
55 DVLOG(1) << "Running test URL: " << gurl;
56 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
57 AddWaitForTitles(&title_watcher);
58 NavigateToURL(shell(), gurl);
59
60 base::string16 final_title = title_watcher.WaitAndGetTitle();
42 EXPECT_EQ(expected_title, final_title); 61 EXPECT_EQ(expected_title, final_title);
43 } 62 }
44 63
45 std::string MediaBrowserTest::RunTest(const GURL& gurl,
46 const std::string& expected_title) {
47 VLOG(0) << "Running test URL: " << gurl;
48 TitleWatcher title_watcher(shell()->web_contents(),
49 base::ASCIIToUTF16(expected_title));
50 AddWaitForTitles(&title_watcher);
51 NavigateToURL(shell(), gurl);
52 base::string16 result = title_watcher.WaitAndGetTitle();
53 return base::UTF16ToASCII(result);
54 }
55
56 void MediaBrowserTest::AddWaitForTitles(content::TitleWatcher* title_watcher) { 64 void MediaBrowserTest::AddWaitForTitles(content::TitleWatcher* title_watcher) {
57 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); 65 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded));
58 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); 66 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError));
59 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); 67 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed));
60 } 68 }
61 69
62 // Tests playback and seeking of an audio or video file over file or http based 70 // Tests playback and seeking of an audio or video file over file or http based
63 // on a test parameter. Test starts with playback, then, after X seconds or the 71 // on a test parameter. Test starts with playback, then, after X seconds or the
64 // ended event fires, seeks near end of file; see player.html for details. The 72 // ended event fires, seeks near end of file; see player.html for details. The
65 // test completes when either the last 'ended' or an 'error' event fires. 73 // test completes when either the last 'ended' or an 'error' event fires.
66 class MediaTest : public testing::WithParamInterface<bool>, 74 class MediaTest : public testing::WithParamInterface<bool>,
67 public MediaBrowserTest { 75 public MediaBrowserTest {
68 public: 76 public:
69 // Play specified audio over http:// or file:// depending on |http| setting. 77 // Play specified audio over http:// or file:// depending on |http| setting.
70 void PlayAudio(const std::string& media_file, bool http) { 78 void PlayAudio(const char* media_file, bool http) {
71 PlayMedia("audio", media_file, http); 79 PlayMedia("audio", media_file, http);
72 } 80 }
73 81
74 // Play specified video over http:// or file:// depending on |http| setting. 82 // Play specified video over http:// or file:// depending on |http| setting.
75 void PlayVideo(const std::string& media_file, bool http) { 83 void PlayVideo(const char* media_file, bool http) {
76 PlayMedia("video", media_file, http); 84 PlayMedia("video", media_file, http);
77 } 85 }
78 86
79 // Run specified color format test with the expected result. 87 // Run specified color format test with the expected result.
80 void RunColorFormatTest(const std::string& media_file, 88 void RunColorFormatTest(const char* media_file, const char* expected) {
81 const std::string& expected) { 89 base::FilePath test_file_path = GetTestFilePath("media", "blackwhite.html");
82 base::FilePath test_file_path =
83 media::GetTestDataFilePath("blackwhite.html");
84 RunTest(GetFileUrlWithQuery(test_file_path, media_file), expected); 90 RunTest(GetFileUrlWithQuery(test_file_path, media_file), expected);
85 } 91 }
86 92
87 void PlayMedia(const std::string& tag, 93 void PlayMedia(const char* tag, const char* media_file, bool http) {
88 const std::string& media_file, 94 std::vector<StringPair> query_params;
89 bool http) {
90 media::QueryParams query_params;
91 query_params.push_back(std::make_pair(tag, media_file)); 95 query_params.push_back(std::make_pair(tag, media_file));
92 RunMediaTestPage("player.html", query_params, kEnded, http); 96 RunMediaTestPage("player.html", &query_params, kEnded, http);
93 } 97 }
94 }; 98 };
95 99
96 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearTheora) { 100 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearTheora) {
97 PlayVideo("bear.ogv", GetParam()); 101 PlayVideo("bear.ogv", GetParam());
98 } 102 }
99 103
100 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearSilentTheora) { 104 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearSilentTheora) {
101 PlayVideo("bear_silent.ogv", GetParam()); 105 PlayVideo("bear_silent.ogv", GetParam());
102 } 106 }
(...skipping 26 matching lines...) Expand all
129 // While we support the big endian (be) PCM codecs on Chromium, Quicktime seems 133 // While we support the big endian (be) PCM codecs on Chromium, Quicktime seems
130 // to be the only creator of this format and only for .mov files. 134 // to be the only creator of this format and only for .mov files.
131 // TODO(dalecurtis/ihf): Find or create some .wav test cases for "be" format. 135 // TODO(dalecurtis/ihf): Find or create some .wav test cases for "be" format.
132 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS16be) { 136 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS16be) {
133 PlayVideo("bear_pcm_s16be.mov", GetParam()); 137 PlayVideo("bear_pcm_s16be.mov", GetParam());
134 } 138 }
135 139
136 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS24be) { 140 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS24be) {
137 PlayVideo("bear_pcm_s24be.mov", GetParam()); 141 PlayVideo("bear_pcm_s24be.mov", GetParam());
138 } 142 }
139 #endif // defined(USE_PROPRIETARY_CODECS) 143 #endif
140 144
141 #if defined(OS_CHROMEOS) 145 #if defined(OS_CHROMEOS)
142 #if defined(USE_PROPRIETARY_CODECS) 146 #if defined(USE_PROPRIETARY_CODECS)
143 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearAviMp3Mpeg4) { 147 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearAviMp3Mpeg4) {
144 PlayVideo("bear_mpeg4_mp3.avi", GetParam()); 148 PlayVideo("bear_mpeg4_mp3.avi", GetParam());
145 } 149 }
146 150
147 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearAviMp3Mpeg4Asp) { 151 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearAviMp3Mpeg4Asp) {
148 PlayVideo("bear_mpeg4asp_mp3.avi", GetParam()); 152 PlayVideo("bear_mpeg4asp_mp3.avi", GetParam());
149 } 153 }
(...skipping 10 matching lines...) Expand all
160 PlayVideo("bear_mpeg4_amrnb.3gp", GetParam()); 164 PlayVideo("bear_mpeg4_amrnb.3gp", GetParam());
161 } 165 }
162 166
163 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavGsmms) { 167 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavGsmms) {
164 PlayAudio("bear_gsm_ms.wav", GetParam()); 168 PlayAudio("bear_gsm_ms.wav", GetParam());
165 } 169 }
166 170
167 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearFlac) { 171 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearFlac) {
168 PlayAudio("bear.flac", GetParam()); 172 PlayAudio("bear.flac", GetParam());
169 } 173 }
170 #endif // defined(USE_PROPRIETARY_CODECS) 174 #endif
171 #endif // defined(OS_CHROMEOS) 175 #endif
172
173 176
174 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavAlaw) { 177 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavAlaw) {
175 PlayAudio("bear_alaw.wav", GetParam()); 178 PlayAudio("bear_alaw.wav", GetParam());
176 } 179 }
177 180
178 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavMulaw) { 181 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavMulaw) {
179 PlayAudio("bear_mulaw.wav", GetParam()); 182 PlayAudio("bear_mulaw.wav", GetParam());
180 } 183 }
181 184
182 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavPcm) { 185 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavPcm) {
(...skipping 16 matching lines...) Expand all
199 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { 202 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) {
200 PlayVideo("bear.ogv", false); 203 PlayVideo("bear.ogv", false);
201 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); 204 NavigateToURL(shell(), GURL(url::kAboutBlankURL));
202 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); 205 EXPECT_FALSE(shell()->web_contents()->IsCrashed());
203 } 206 }
204 207
205 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); 208 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false));
206 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); 209 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true));
207 210
208 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pTheora)) { 211 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pTheora)) {
209 RunColorFormatTest("yuv420p.ogv", kEnded); 212 RunColorFormatTest("yuv420p.ogv", "ENDED");
210 } 213 }
211 214
212 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv422pTheora)) { 215 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv422pTheora)) {
213 RunColorFormatTest("yuv422p.ogv", kEnded); 216 RunColorFormatTest("yuv422p.ogv", "ENDED");
214 } 217 }
215 218
216 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv444pTheora)) { 219 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv444pTheora)) {
217 RunColorFormatTest("yuv444p.ogv", kEnded); 220 RunColorFormatTest("yuv444p.ogv", "ENDED");
218 } 221 }
219 222
220 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pVp8)) { 223 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pVp8)) {
221 RunColorFormatTest("yuv420p.webm", kEnded); 224 RunColorFormatTest("yuv420p.webm", "ENDED");
222 } 225 }
223 226
224 // TODO(johannkoenig): Reenable after landing libvpx roll 227 // TODO(johannkoenig): Reenable after landing libvpx roll
225 // http://www.crbug.com/392309 228 // http://www.crbug.com/392309
226 IN_PROC_BROWSER_TEST_F(MediaTest, DISABLED_Yuv444pVp9) { 229 IN_PROC_BROWSER_TEST_F(MediaTest, DISABLED_Yuv444pVp9) {
227 RunColorFormatTest("yuv444p.webm", "ENDED"); 230 RunColorFormatTest("yuv444p.webm", "ENDED");
228 } 231 }
229 232
230 #if defined(USE_PROPRIETARY_CODECS) 233 #if defined(USE_PROPRIETARY_CODECS)
231 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pH264)) { 234 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pH264)) {
232 RunColorFormatTest("yuv420p.mp4", kEnded); 235 RunColorFormatTest("yuv420p.mp4", "ENDED");
233 } 236 }
234 237
235 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuvj420pH264)) { 238 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuvj420pH264)) {
236 RunColorFormatTest("yuvj420p.mp4", kEnded); 239 RunColorFormatTest("yuvj420p.mp4", "ENDED");
237 } 240 }
238 241
239 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv422pH264)) { 242 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv422pH264)) {
240 RunColorFormatTest("yuv422p.mp4", kEnded); 243 RunColorFormatTest("yuv422p.mp4", "ENDED");
241 } 244 }
242 245
243 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv444pH264)) { 246 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv444pH264)) {
244 RunColorFormatTest("yuv444p.mp4", kEnded); 247 RunColorFormatTest("yuv444p.mp4", "ENDED");
245 } 248 }
246 249
247 #if defined(OS_CHROMEOS) 250 #if defined(OS_CHROMEOS)
248 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) { 251 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) {
249 RunColorFormatTest("yuv420p.avi", kEnded); 252 RunColorFormatTest("yuv420p.avi", "ENDED");
250 } 253 }
251 #endif // defined(OS_CHROMEOS) 254 #endif // defined(OS_CHROMEOS)
252 #endif // defined(USE_PROPRIETARY_CODECS) 255 #endif // defined(USE_PROPRIETARY_CODECS)
253 256
254 } // namespace content 257 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/browser/media/media_browsertest.h ('k') | trunk/src/content/browser/media/media_source_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698