Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Side by Side Diff: chromecast/browser/test/chromecast_shell_browser_test.cc

Issue 1431193005: [Chromecast] Adds Browser test for media playback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove VLOG Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromecast/browser/BUILD.gn ('k') | chromecast/chromecast_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
servolk 2015/11/11 18:11:23 Nit: redundant empty line
halliwell 2015/11/11 18:40:21 Done.
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);
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 content::TitleWatcher title_watcher(web_contents(),
61 base::ASCIIToUTF16(expected_title));
62 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded));
63 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError));
64 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed));
65
66 NavigateToURL(web_contents(), gurl);
67 base::string16 result = title_watcher.WaitAndGetTitle();
68 return base::UTF16ToASCII(result);
69 }
70
25 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest); 71 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest);
26 }; 72 };
27 73
28 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) { 74 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) {
29 // Run an entire browser lifecycle to ensure nothing breaks. 75 // Run an entire browser lifecycle to ensure nothing breaks.
30 // TODO(gunsch): Remove this test case once there are actual assertions to 76 // TODO(gunsch): Remove this test case once there are actual assertions to
31 // test in a ChromecastBrowserTest instance. 77 // test in a ChromecastBrowserTest instance.
32 EXPECT_TRUE(true); 78 EXPECT_TRUE(true);
33 } 79 }
34 80
81 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, MediaPlayback) {
82 PlayVideo("bear.mp4");
83 }
84
35 } // namespace shell 85 } // namespace shell
36 } // namespace chromecast 86 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/BUILD.gn ('k') | chromecast/chromecast_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698