| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 std::string final_title = RunTest(gurl, expected_title); | 47 std::string final_title = RunTest(gurl, expected_title); |
| 48 EXPECT_EQ(expected_title, final_title); | 48 EXPECT_EQ(expected_title, final_title); |
| 49 } | 49 } |
| 50 | 50 |
| 51 std::string MediaBrowserTest::RunTest(const GURL& gurl, | 51 std::string MediaBrowserTest::RunTest(const GURL& gurl, |
| 52 const std::string& expected_title) { | 52 const std::string& expected_title) { |
| 53 VLOG(0) << "Running test URL: " << gurl; | 53 VLOG(0) << "Running test URL: " << gurl; |
| 54 TitleWatcher title_watcher(shell()->web_contents(), | 54 TitleWatcher title_watcher(shell()->web_contents(), |
| 55 base::ASCIIToUTF16(expected_title)); | 55 base::ASCIIToUTF16(expected_title)); |
| 56 AddWaitForTitles(&title_watcher); | 56 AddTitlesToAwait(&title_watcher); |
| 57 NavigateToURL(shell(), gurl); | 57 NavigateToURL(shell(), gurl); |
| 58 base::string16 result = title_watcher.WaitAndGetTitle(); | 58 base::string16 result = title_watcher.WaitAndGetTitle(); |
| 59 return base::UTF16ToASCII(result); | 59 return base::UTF16ToASCII(result); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void MediaBrowserTest::AddWaitForTitles(content::TitleWatcher* title_watcher) { | 62 void MediaBrowserTest::AddTitlesToAwait(content::TitleWatcher* title_watcher) { |
| 63 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); | 63 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); |
| 64 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); | 64 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); |
| 65 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); | 65 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Tests playback and seeking of an audio or video file over file or http based | 68 // Tests playback and seeking of an audio or video file over file or http based |
| 69 // on a test parameter. Test starts with playback, then, after X seconds or the | 69 // on a test parameter. Test starts with playback, then, after X seconds or the |
| 70 // ended event fires, seeks near end of file; see player.html for details. The | 70 // ended event fires, seeks near end of file; see player.html for details. The |
| 71 // test completes when either the last 'ended' or an 'error' event fires. | 71 // test completes when either the last 'ended' or an 'error' event fires. |
| 72 class MediaTest : public testing::WithParamInterface<bool>, | 72 class MediaTest : public testing::WithParamInterface<bool>, |
| 73 public MediaBrowserTest { | 73 public MediaBrowserTest { |
| 74 public: | 74 public: |
| 75 // Play specified audio over http:// or file:// depending on |http| setting. | 75 // Play specified audio over http:// or file:// depending on |http| setting. |
| 76 void PlayAudio(const std::string& media_file, bool http) { | 76 void PlayAudio(const std::string& media_file, bool http) { |
| 77 PlayMedia("audio", media_file, http); | 77 PlayMedia("audio", media_file, http); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Play specified video over http:// or file:// depending on |http| setting. | 80 // Play specified video over http:// or file:// depending on |http| setting. |
| 81 void PlayVideo(const std::string& media_file, bool http) { | 81 void PlayVideo(const std::string& media_file, bool http) { |
| 82 PlayMedia("video", media_file, http); | 82 PlayMedia("video", media_file, http); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Run specified color format test with the expected result. | |
| 86 void RunColorFormatTest(const std::string& media_file, | |
| 87 const std::string& expected) { | |
| 88 base::FilePath test_file_path = | |
| 89 media::GetTestDataFilePath("blackwhite.html"); | |
| 90 RunTest(GetFileUrlWithQuery(test_file_path, media_file), expected); | |
| 91 } | |
| 92 | |
| 93 void PlayMedia(const std::string& tag, | 85 void PlayMedia(const std::string& tag, |
| 94 const std::string& media_file, | 86 const std::string& media_file, |
| 95 bool http) { | 87 bool http) { |
| 96 base::StringPairs query_params; | 88 base::StringPairs query_params; |
| 97 query_params.push_back(std::make_pair(tag, media_file)); | 89 query_params.push_back(std::make_pair(tag, media_file)); |
| 98 RunMediaTestPage("player.html", query_params, kEnded, http); | 90 RunMediaTestPage("player.html", query_params, kEnded, http); |
| 99 } | 91 } |
| 100 | 92 |
| 101 void RunVideoSizeTest(const char* media_file, int width, int height) { | 93 void RunVideoSizeTest(const char* media_file, int width, int height) { |
| 102 std::string expected; | 94 std::string expected; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // Covers tear-down when navigating away as opposed to browser exiting. | 238 // Covers tear-down when navigating away as opposed to browser exiting. |
| 247 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { | 239 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { |
| 248 PlayVideo("bear.ogv", false); | 240 PlayVideo("bear.ogv", false); |
| 249 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 241 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| 250 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); | 242 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); |
| 251 } | 243 } |
| 252 | 244 |
| 253 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); | 245 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); |
| 254 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); | 246 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); |
| 255 | 247 |
| 256 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pTheora) { | |
| 257 RunColorFormatTest("yuv420p.ogv", kEnded); | |
| 258 } | |
| 259 | |
| 260 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv422pTheora) { | |
| 261 RunColorFormatTest("yuv422p.ogv", kEnded); | |
| 262 } | |
| 263 | |
| 264 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv444pTheora) { | |
| 265 RunColorFormatTest("yuv444p.ogv", kEnded); | |
| 266 } | |
| 267 | |
| 268 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pVp8) { | |
| 269 RunColorFormatTest("yuv420p.webm", kEnded); | |
| 270 } | |
| 271 | |
| 272 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv444pVp9) { | |
| 273 RunColorFormatTest("yuv444p.webm", "ENDED"); | |
| 274 } | |
| 275 | |
| 276 #if defined(USE_PROPRIETARY_CODECS) | |
| 277 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pH264) { | |
| 278 RunColorFormatTest("yuv420p.mp4", kEnded); | |
| 279 } | |
| 280 | |
| 281 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pRec709H264) { | |
| 282 RunColorFormatTest("yuv420p_rec709.mp4", kEnded); | |
| 283 } | |
| 284 | |
| 285 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pHighBitDepth) { | |
| 286 RunColorFormatTest("yuv420p_hi10p.mp4", kEnded); | |
| 287 } | |
| 288 | |
| 289 IN_PROC_BROWSER_TEST_F(MediaTest, Yuvj420pH264) { | |
| 290 RunColorFormatTest("yuvj420p.mp4", kEnded); | |
| 291 } | |
| 292 | |
| 293 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv422pH264) { | |
| 294 RunColorFormatTest("yuv422p.mp4", kEnded); | |
| 295 } | |
| 296 | |
| 297 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv444pH264) { | |
| 298 RunColorFormatTest("yuv444p.mp4", kEnded); | |
| 299 } | |
| 300 | |
| 301 #if defined(OS_CHROMEOS) | |
| 302 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) { | |
| 303 RunColorFormatTest("yuv420p.avi", kEnded); | |
| 304 } | |
| 305 #endif // defined(OS_CHROMEOS) | |
| 306 #endif // defined(USE_PROPRIETARY_CODECS) | |
| 307 | |
| 308 } // namespace content | 248 } // namespace content |
| OLD | NEW |