| 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" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 14 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
| 15 #include "content/shell/browser/shell.h" | 15 #include "content/shell/browser/shell.h" |
| 16 #include "media/base/media_switches.h" | 16 #include "media/base/media_switches.h" |
| 17 #include "media/base/test_data_util.h" | 17 #include "media/base/test_data_util.h" |
| 18 #include "media/media_features.h" | 18 #include "media/media_features.h" |
| 19 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 // TODO(sandersd): Change the tests to use a more unique message. |
| 24 // See http://crbug.com/592067 |
| 25 |
| 23 // Common test results. | 26 // Common test results. |
| 27 const char MediaBrowserTest::kFailed[] = "FAILED"; |
| 28 |
| 29 // Upper case event name set by Utils.installTitleEventHandler(). |
| 24 const char MediaBrowserTest::kEnded[] = "ENDED"; | 30 const char MediaBrowserTest::kEnded[] = "ENDED"; |
| 25 const char MediaBrowserTest::kError[] = "ERROR"; | 31 const char MediaBrowserTest::kErrorEvent[] = "ERROR"; |
| 26 const char MediaBrowserTest::kFailed[] = "FAILED"; | 32 |
| 33 // Lower case event name as set by Utils.failTest(). |
| 34 const char MediaBrowserTest::kError[] = "error"; |
| 27 | 35 |
| 28 void MediaBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { | 36 void MediaBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 29 command_line->AppendSwitch( | 37 command_line->AppendSwitch( |
| 30 switches::kDisableGestureRequirementForMediaPlayback); | 38 switches::kDisableGestureRequirementForMediaPlayback); |
| 31 command_line->AppendSwitch(switches::kEnableVp9InMp4); | 39 command_line->AppendSwitch(switches::kEnableVp9InMp4); |
| 32 } | 40 } |
| 33 | 41 |
| 34 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, | 42 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, |
| 35 const base::StringPairs& query_params, | 43 const base::StringPairs& query_params, |
| 36 const std::string& expected_title, | 44 const std::string& expected_title, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 base::ASCIIToUTF16(expected_title)); | 66 base::ASCIIToUTF16(expected_title)); |
| 59 AddTitlesToAwait(&title_watcher); | 67 AddTitlesToAwait(&title_watcher); |
| 60 NavigateToURL(shell(), gurl); | 68 NavigateToURL(shell(), gurl); |
| 61 base::string16 result = title_watcher.WaitAndGetTitle(); | 69 base::string16 result = title_watcher.WaitAndGetTitle(); |
| 62 return base::UTF16ToASCII(result); | 70 return base::UTF16ToASCII(result); |
| 63 } | 71 } |
| 64 | 72 |
| 65 void MediaBrowserTest::AddTitlesToAwait(content::TitleWatcher* title_watcher) { | 73 void MediaBrowserTest::AddTitlesToAwait(content::TitleWatcher* title_watcher) { |
| 66 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); | 74 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); |
| 67 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); | 75 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); |
| 76 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kErrorEvent)); |
| 68 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); | 77 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); |
| 69 } | 78 } |
| 70 | 79 |
| 71 // Tests playback and seeking of an audio or video file over file or http based | 80 // Tests playback and seeking of an audio or video file over file or http based |
| 72 // on a test parameter. Test starts with playback, then, after X seconds or the | 81 // on a test parameter. Test starts with playback, then, after X seconds or the |
| 73 // ended event fires, seeks near end of file; see player.html for details. The | 82 // ended event fires, seeks near end of file; see player.html for details. The |
| 74 // test completes when either the last 'ended' or an 'error' event fires. | 83 // test completes when either the last 'ended' or an 'error' event fires. |
| 75 class MediaTest : public testing::WithParamInterface<bool>, | 84 class MediaTest : public testing::WithParamInterface<bool>, |
| 76 public MediaBrowserTest { | 85 public MediaBrowserTest { |
| 77 public: | 86 public: |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { | 275 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { |
| 267 PlayVideo("bear.webm", false); | 276 PlayVideo("bear.webm", false); |
| 268 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 277 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| 269 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); | 278 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); |
| 270 } | 279 } |
| 271 | 280 |
| 272 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); | 281 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); |
| 273 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); | 282 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); |
| 274 | 283 |
| 275 } // namespace content | 284 } // namespace content |
| OLD | NEW |