Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/strings/string_split.h" | |
| 7 #include "base/strings/utf_string_conversions.h" | |
| 6 #include "chromecast/browser/test/chromecast_browser_test.h" | 8 #include "chromecast/browser/test/chromecast_browser_test.h" |
| 9 #include "content/public/test/browser_test_utils.h" | |
| 10 #include "media/base/test_data_util.h" | |
| 7 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 8 #include "url/url_constants.h" | 12 #include "url/url_constants.h" |
| 9 | 13 |
| 10 namespace chromecast { | 14 namespace chromecast { |
| 11 namespace shell { | 15 namespace shell { |
| 16 namespace { | |
| 17 const char kEnded[] = "ENDED"; | |
| 18 const char kError[] = "ERROR"; | |
| 19 const char kFailed[] = "FAILED"; | |
| 20 | |
| 21 } | |
| 12 | 22 |
| 13 class ChromecastShellBrowserTest : public ChromecastBrowserTest { | 23 class ChromecastShellBrowserTest : public ChromecastBrowserTest { |
| 14 public: | 24 public: |
| 15 ChromecastShellBrowserTest() : url_(url::kAboutBlankURL) {} | 25 ChromecastShellBrowserTest() : url_(url::kAboutBlankURL) {} |
| 16 | 26 |
| 17 void SetUpOnMainThread() override { | 27 void SetUpOnMainThread() override { |
| 18 CreateBrowser(); | 28 CreateBrowser(); |
| 19 NavigateToURL(web_contents(), url_); | 29 NavigateToURL(web_contents(), url_); |
| 20 } | 30 } |
| 21 | 31 |
| 32 void PlayVideo(const std::string& media_file) { | |
| 33 PlayMedia("video", media_file); | |
| 34 } | |
| 35 | |
| 22 private: | 36 private: |
| 23 const GURL url_; | 37 const GURL url_; |
| 24 | 38 |
| 39 void PlayMedia(const std::string& tag, | |
| 40 const std::string& media_file) { | |
| 41 base::StringPairs query_params; | |
| 42 query_params.push_back(std::make_pair(tag, media_file)); | |
| 43 RunMediaTestPage("player.html", query_params, kEnded); | |
|
slan
2015/11/10 23:02:11
nit: const in anon namespace
halliwell
2015/11/11 17:22:40
I disagree: the point of such constants is to crea
slan
2015/11/11 17:46:22
Agreed, thanks.
| |
| 44 } | |
| 45 | |
| 46 void RunMediaTestPage(const std::string& html_page, | |
| 47 const base::StringPairs& query_params, | |
| 48 const std::string& expected_title) { | |
| 49 std::string query = media::GetURLQueryString(query_params); | |
| 50 GURL gurl = content::GetFileUrlWithQuery( | |
| 51 media::GetTestDataFilePath(html_page), | |
| 52 query); | |
| 53 | |
| 54 std::string final_title = RunTest(gurl, expected_title); | |
| 55 EXPECT_EQ(expected_title, final_title); | |
| 56 } | |
| 57 | |
| 58 std::string RunTest(const GURL& gurl, | |
| 59 const std::string& expected_title) { | |
| 60 VLOG(0) << "Running test URL: " << gurl; | |
|
slan
2015/11/10 23:02:11
nit: LOG(INFO) or remove.
halliwell
2015/11/11 17:22:40
removed.
| |
| 61 content::TitleWatcher title_watcher(web_contents(), | |
| 62 base::ASCIIToUTF16(expected_title)); | |
| 63 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); | |
| 64 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError)); | |
| 65 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); | |
| 66 | |
| 67 NavigateToURL(web_contents(), gurl); | |
| 68 base::string16 result = title_watcher.WaitAndGetTitle(); | |
| 69 return base::UTF16ToASCII(result); | |
| 70 } | |
| 71 | |
| 25 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest); | 72 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest); |
| 26 }; | 73 }; |
| 27 | 74 |
| 28 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) { | 75 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) { |
| 29 // Run an entire browser lifecycle to ensure nothing breaks. | 76 // Run an entire browser lifecycle to ensure nothing breaks. |
| 30 // TODO(gunsch): Remove this test case once there are actual assertions to | 77 // TODO(gunsch): Remove this test case once there are actual assertions to |
| 31 // test in a ChromecastBrowserTest instance. | 78 // test in a ChromecastBrowserTest instance. |
| 32 EXPECT_TRUE(true); | 79 EXPECT_TRUE(true); |
| 33 } | 80 } |
| 34 | 81 |
| 82 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, MediaPlayback) { | |
| 83 PlayVideo("bear.mp4"); | |
|
slan
2015/11/10 23:02:11
nit const in anon namespace
halliwell
2015/11/11 17:22:40
disagree as above.
slan
2015/11/11 17:46:22
Acknowledged.
| |
| 84 } | |
| 85 | |
| 35 } // namespace shell | 86 } // namespace shell |
| 36 } // namespace chromecast | 87 } // namespace chromecast |
| OLD | NEW |