Chromium Code Reviews| 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 "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 // TODO(sandersd): Change the tests to use a more unique message. | |
|
ddorwin
2017/02/12 04:28:52
How is this different from 32? Why doesn't 32 have
xhwang
2017/02/14 23:59:32
Removed TODO on l.32.
| |
| 23 // See http://crbug.com/592067 | |
| 24 | |
| 22 // Common test results. | 25 // Common test results. |
| 26 const char MediaBrowserTest::kFailed[] = "FAILED"; | |
| 27 | |
| 28 // Uncapitalized event name as set by Utils.failTest(). | |
|
ddorwin
2017/02/12 04:28:52
nit: "Lower case"?
xhwang
2017/02/14 23:59:32
Done.
| |
| 29 const char MediaBrowserTest::kError[] = "error"; | |
| 30 | |
| 31 // Capitalized event name set by Utils.installTitleEventHandler(). | |
|
ddorwin
2017/02/12 04:28:52
nit: Upper case
xhwang
2017/02/14 23:59:32
Done.
| |
| 32 // TODO(sandersd): Change the tests to use a more unique message. | |
| 23 const char MediaBrowserTest::kEnded[] = "ENDED"; | 33 const char MediaBrowserTest::kEnded[] = "ENDED"; |
| 24 const char MediaBrowserTest::kError[] = "ERROR"; | 34 const char MediaBrowserTest::kErrorEvent[] = "ERROR"; |
| 25 const char MediaBrowserTest::kFailed[] = "FAILED"; | |
| 26 | 35 |
| 27 void MediaBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { | 36 void MediaBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 28 command_line->AppendSwitch( | 37 command_line->AppendSwitch( |
| 29 switches::kDisableGestureRequirementForMediaPlayback); | 38 switches::kDisableGestureRequirementForMediaPlayback); |
| 30 command_line->AppendSwitch(switches::kEnableVp9InMp4); | 39 command_line->AppendSwitch(switches::kEnableVp9InMp4); |
| 31 } | 40 } |
| 32 | 41 |
| 33 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, | 42 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, |
| 34 const base::StringPairs& query_params, | 43 const base::StringPairs& query_params, |
| 35 const std::string& expected_title, | 44 const std::string& expected_title, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 57 base::ASCIIToUTF16(expected_title)); | 66 base::ASCIIToUTF16(expected_title)); |
| 58 AddTitlesToAwait(&title_watcher); | 67 AddTitlesToAwait(&title_watcher); |
| 59 NavigateToURL(shell(), gurl); | 68 NavigateToURL(shell(), gurl); |
| 60 base::string16 result = title_watcher.WaitAndGetTitle(); | 69 base::string16 result = title_watcher.WaitAndGetTitle(); |
| 61 return base::UTF16ToASCII(result); | 70 return base::UTF16ToASCII(result); |
| 62 } | 71 } |
| 63 | 72 |
| 64 void MediaBrowserTest::AddTitlesToAwait(content::TitleWatcher* title_watcher) { | 73 void MediaBrowserTest::AddTitlesToAwait(content::TitleWatcher* title_watcher) { |
| 65 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); | 74 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); |
| 66 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); | 75 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); |
| 76 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kErrorEvent)); | |
| 67 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); | 77 title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); |
| 68 } | 78 } |
| 69 | 79 |
| 70 // 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 |
| 71 // 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 |
| 72 // 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 |
| 73 // 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. |
| 74 class MediaTest : public testing::WithParamInterface<bool>, | 84 class MediaTest : public testing::WithParamInterface<bool>, |
| 75 public MediaBrowserTest { | 85 public MediaBrowserTest { |
| 76 public: | 86 public: |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { | 271 IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { |
| 262 PlayVideo("bear.webm", false); | 272 PlayVideo("bear.webm", false); |
| 263 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 273 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| 264 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); | 274 EXPECT_FALSE(shell()->web_contents()->IsCrashed()); |
| 265 } | 275 } |
| 266 | 276 |
| 267 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); | 277 INSTANTIATE_TEST_CASE_P(File, MediaTest, ::testing::Values(false)); |
| 268 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); | 278 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true)); |
| 269 | 279 |
| 270 } // namespace content | 280 } // namespace content |
| OLD | NEW |