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 "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/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/common/url_constants.h" |
10 #include "content/public/test/browser_test_utils.h" | 11 #include "content/public/test/browser_test_utils.h" |
11 #include "content/shell/shell.h" | 12 #include "content/shell/shell.h" |
12 #include "content/test/content_browser_test_utils.h" | 13 #include "content/test/content_browser_test_utils.h" |
13 | 14 |
14 // 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 |
15 #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 |
16 #define MAYBE(x) DISABLED_##x | 17 #define MAYBE(x) DISABLED_##x |
17 #else | 18 #else |
18 #define MAYBE(x) x | 19 #define MAYBE(x) x |
19 #endif | 20 #endif |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 // Common test results. | 24 // Common test results. |
24 const char MediaBrowserTest::kEnded[] = "ENDED"; | 25 const char MediaBrowserTest::kEnded[] = "ENDED"; |
25 const char MediaBrowserTest::kError[] = "ERROR"; | 26 const char MediaBrowserTest::kError[] = "ERROR"; |
26 const char MediaBrowserTest::kFailed[] = "FAILED"; | 27 const char MediaBrowserTest::kFailed[] = "FAILED"; |
27 | 28 |
28 void MediaBrowserTest::RunMediaTestPage( | 29 void MediaBrowserTest::RunMediaTestPage( |
29 const char* html_page, std::vector<StringPair>* query_params, | 30 const char* html_page, std::vector<StringPair>* query_params, |
30 const char* expected, bool http) { | 31 const char* expected, bool http) { |
31 GURL gurl; | 32 GURL gurl; |
32 std::string query = ""; | 33 std::string query = ""; |
33 if (query_params != NULL && !query_params->empty()) { | 34 if (query_params != NULL && !query_params->empty()) { |
34 std::vector<StringPair>::const_iterator itr = query_params->begin(); | 35 std::vector<StringPair>::const_iterator itr = query_params->begin(); |
35 query = base::StringPrintf("%s=%s", itr->first, itr->second); | 36 query = base::StringPrintf("%s=%s", itr->first, itr->second); |
36 ++itr; | 37 ++itr; |
37 for (;itr != query_params->end(); ++itr) { | 38 for (; itr != query_params->end(); ++itr) { |
38 query.append(base::StringPrintf("&%s=%s", itr->first, itr->second)); | 39 query.append(base::StringPrintf("&%s=%s", itr->first, itr->second)); |
39 } | 40 } |
40 } | 41 } |
41 if (http) { | 42 if (http) { |
42 ASSERT_TRUE(test_server()->Start()); | 43 ASSERT_TRUE(test_server()->Start()); |
43 gurl = test_server()->GetURL( | 44 gurl = test_server()->GetURL( |
44 base::StringPrintf("files/media/%s?%s", html_page, query.c_str())); | 45 base::StringPrintf("files/media/%s?%s", html_page, query.c_str())); |
45 } else { | 46 } else { |
46 base::FilePath test_file_path = GetTestFilePath("media", html_page); | 47 base::FilePath test_file_path = GetTestFilePath("media", html_page); |
47 gurl = GetFileUrlWithQuery(test_file_path, query); | 48 gurl = GetFileUrlWithQuery(test_file_path, query); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 PlayAudio("bear_192kHz.wav", GetParam()); | 178 PlayAudio("bear_192kHz.wav", GetParam()); |
178 } | 179 } |
179 | 180 |
180 IN_PROC_BROWSER_TEST_P(MediaTest, VideoTulipWebm) { | 181 IN_PROC_BROWSER_TEST_P(MediaTest, VideoTulipWebm) { |
181 PlayVideo("tulip2.webm", GetParam()); | 182 PlayVideo("tulip2.webm", GetParam()); |
182 } | 183 } |
183 | 184 |
184 // Covers tear-down when navigating away as opposed to browser exiting. | 185 // Covers tear-down when navigating away as opposed to browser exiting. |
185 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { | 186 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { |
186 PlayVideo("bear.ogv", false); | 187 PlayVideo("bear.ogv", false); |
187 NavigateToURL(shell(), GURL("about:blank")); | 188 NavigateToURL(shell(), GURL(kAboutBlankURL)); |
188 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); | 189 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); |
189 } | 190 } |
190 | 191 |
191 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); | 192 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); |
192 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); | 193 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); |
193 | 194 |
194 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pTheora)) { | 195 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pTheora)) { |
195 RunColorFormatTest("yuv420p.ogv", "ENDED"); | 196 RunColorFormatTest("yuv420p.ogv", "ENDED"); |
196 } | 197 } |
197 | 198 |
(...skipping 29 matching lines...) Expand all Loading... |
227 } | 228 } |
228 | 229 |
229 #if defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
230 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) { | 231 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) { |
231 RunColorFormatTest("yuv420p.avi", "ENDED"); | 232 RunColorFormatTest("yuv420p.avi", "ENDED"); |
232 } | 233 } |
233 #endif | 234 #endif |
234 #endif | 235 #endif |
235 | 236 |
236 } // namespace content | 237 } // namespace content |
OLD | NEW |