OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 PlayMedia("audio", media_file, http); | 29 PlayMedia("audio", media_file, http); |
30 } | 30 } |
31 | 31 |
32 // Play specified video over http:// or file:// depending on |http| setting. | 32 // Play specified video over http:// or file:// depending on |http| setting. |
33 void PlayVideo(const char* media_file, bool http) { | 33 void PlayVideo(const char* media_file, bool http) { |
34 PlayMedia("video", media_file, http); | 34 PlayMedia("video", media_file, http); |
35 } | 35 } |
36 | 36 |
37 // Run specified color format test with the expected result. | 37 // Run specified color format test with the expected result. |
38 void RunColorFormatTest(const char* media_file, const char* expected) { | 38 void RunColorFormatTest(const char* media_file, const char* expected) { |
39 FilePath test_file_path = GetTestFilePath("media", "blackwhite.html"); | 39 base::FilePath test_file_path = GetTestFilePath("media", "blackwhite.html"); |
40 RunTest(GetFileUrlWithQuery(test_file_path, media_file), expected); | 40 RunTest(GetFileUrlWithQuery(test_file_path, media_file), expected); |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 void PlayMedia(const char* tag, const char* media_file, bool http) { | 44 void PlayMedia(const char* tag, const char* media_file, bool http) { |
45 GURL gurl; | 45 GURL gurl; |
46 | 46 |
47 if (http) { | 47 if (http) { |
48 if (!test_server()->Start()) { | 48 if (!test_server()->Start()) { |
49 ADD_FAILURE() << "Failed to start test server"; | 49 ADD_FAILURE() << "Failed to start test server"; |
50 return; | 50 return; |
51 } | 51 } |
52 | 52 |
53 gurl = test_server()->GetURL( | 53 gurl = test_server()->GetURL( |
54 base::StringPrintf("files/media/player.html?%s=%s", tag, media_file)); | 54 base::StringPrintf("files/media/player.html?%s=%s", tag, media_file)); |
55 } else { | 55 } else { |
56 FilePath test_file_path = GetTestFilePath("media", "player.html"); | 56 base::FilePath test_file_path = GetTestFilePath("media", "player.html"); |
57 gurl = GetFileUrlWithQuery( | 57 gurl = GetFileUrlWithQuery( |
58 test_file_path, base::StringPrintf("%s=%s", tag, media_file)); | 58 test_file_path, base::StringPrintf("%s=%s", tag, media_file)); |
59 } | 59 } |
60 | 60 |
61 RunTest(gurl, "ENDED"); | 61 RunTest(gurl, "ENDED"); |
62 } | 62 } |
63 | 63 |
64 void RunTest(const GURL& gurl, const char* expected) { | 64 void RunTest(const GURL& gurl, const char* expected) { |
65 const string16 kExpected = ASCIIToUTF16(expected); | 65 const string16 kExpected = ASCIIToUTF16(expected); |
66 const string16 kEnded = ASCIIToUTF16("ENDED"); | 66 const string16 kEnded = ASCIIToUTF16("ENDED"); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 IN_PROC_BROWSER_TEST_P(MediaTest, VideoTulipWebm) { | 164 IN_PROC_BROWSER_TEST_P(MediaTest, VideoTulipWebm) { |
165 PlayVideo("tulip2.webm", GetParam()); | 165 PlayVideo("tulip2.webm", GetParam()); |
166 } | 166 } |
167 | 167 |
168 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); | 168 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); |
169 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); | 169 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); |
170 | 170 |
171 class MediaLayoutTest : public InProcessBrowserLayoutTest { | 171 class MediaLayoutTest : public InProcessBrowserLayoutTest { |
172 protected: | 172 protected: |
173 MediaLayoutTest() : InProcessBrowserLayoutTest( | 173 MediaLayoutTest() : InProcessBrowserLayoutTest( |
174 FilePath(), FilePath().AppendASCII("media")) { | 174 base::FilePath(), base::FilePath().AppendASCII("media")) { |
175 } | 175 } |
176 virtual ~MediaLayoutTest() {} | 176 virtual ~MediaLayoutTest() {} |
177 }; | 177 }; |
178 | 178 |
179 // Each browser test can only correspond to a single layout test, otherwise the | 179 // Each browser test can only correspond to a single layout test, otherwise the |
180 // 45 second timeout per test is not long enough for N tests on debug/asan/etc | 180 // 45 second timeout per test is not long enough for N tests on debug/asan/etc |
181 // builds. | 181 // builds. |
182 | 182 |
183 IN_PROC_BROWSER_TEST_F(MediaLayoutTest, VideoAutoplayTest) { | 183 IN_PROC_BROWSER_TEST_F(MediaLayoutTest, VideoAutoplayTest) { |
184 RunLayoutTest("video-autoplay.html"); | 184 RunLayoutTest("video-autoplay.html"); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 #if defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
231 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) { | 231 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) { |
232 RunColorFormatTest("yuv420p.avi", "ENDED"); | 232 RunColorFormatTest("yuv420p.avi", "ENDED"); |
233 } | 233 } |
234 #endif | 234 #endif |
235 #endif | 235 #endif |
236 | 236 |
237 } // namespace content | 237 } // namespace content |
OLD | NEW |