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

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

Issue 1870443003: [Chromecast] Enable browser media tests to work on internal builds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months 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
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" 6 #include "base/strings/string_split.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chromecast/browser/test/chromecast_browser_test.h" 8 #include "chromecast/browser/test/chromecast_browser_test.h"
9 #include "chromecast/browser/test/chromecast_browser_test_helper.h"
9 #include "chromecast/chromecast_features.h" 10 #include "chromecast/chromecast_features.h"
10 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/browser_test_utils.h"
11 #include "media/base/test_data_util.h" 12 #include "media/base/test_data_util.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 #include "url/url_constants.h" 14 #include "url/url_constants.h"
14 15
15 namespace chromecast { 16 namespace chromecast {
16 namespace shell { 17 namespace shell {
17 namespace { 18 namespace {
18 const char kEnded[] = "ENDED"; 19 const char kEnded[] = "ENDED";
19 const char kError[] = "ERROR"; 20 const char kError[] = "ERROR";
20 const char kFailed[] = "FAILED"; 21 const char kFailed[] = "FAILED";
21 } 22 }
22 23
23 class ChromecastShellBrowserTest : public ChromecastBrowserTest { 24 class ChromecastShellBrowserTest : public ChromecastBrowserTest {
24 public: 25 public:
25 ChromecastShellBrowserTest() : url_(url::kAboutBlankURL) {} 26 ChromecastShellBrowserTest() {}
26 27
27 void SetUpOnMainThread() override { 28 void LoadAboutBlank() {
28 CreateBrowser(); 29 content::WebContents* web_contents =
29 NavigateToURL(web_contents(), url_); 30 helper_->NavigateToURL(GURL(url::kAboutBlankURL));
31 content::TitleWatcher title_watcher(
32 web_contents, base::ASCIIToUTF16(url::kAboutBlankURL));
33 base::string16 result = title_watcher.WaitAndGetTitle();
34 EXPECT_EQ(url::kAboutBlankURL, base::UTF16ToASCII(result));
30 } 35 }
31
32 void PlayAudio(const std::string& media_file) { 36 void PlayAudio(const std::string& media_file) {
33 PlayMedia("audio", media_file); 37 PlayMedia("audio", media_file);
34 } 38 }
35 void PlayVideo(const std::string& media_file) { 39 void PlayVideo(const std::string& media_file) {
36 PlayMedia("video", media_file); 40 PlayMedia("video", media_file);
37 } 41 }
38 42
39 private: 43 private:
40 const GURL url_;
41
42 void PlayMedia(const std::string& tag, 44 void PlayMedia(const std::string& tag,
43 const std::string& media_file) { 45 const std::string& media_file) {
44 base::StringPairs query_params; 46 base::StringPairs query_params;
45 query_params.push_back(std::make_pair(tag, media_file)); 47 query_params.push_back(std::make_pair(tag, media_file));
46 RunMediaTestPage("player.html", query_params, kEnded); 48 RunMediaTestPage("player.html", query_params, kEnded);
47 } 49 }
48 50
49 void RunMediaTestPage(const std::string& html_page, 51 void RunMediaTestPage(const std::string& html_page,
50 const base::StringPairs& query_params, 52 const base::StringPairs& query_params,
51 const std::string& expected_title) { 53 const std::string& expected_title) {
52 std::string query = media::GetURLQueryString(query_params); 54 std::string query = media::GetURLQueryString(query_params);
53 GURL gurl = content::GetFileUrlWithQuery( 55 GURL gurl = content::GetFileUrlWithQuery(
54 media::GetTestDataFilePath(html_page), 56 media::GetTestDataFilePath(html_page),
55 query); 57 query);
56 58
57 std::string final_title = RunTest(gurl, expected_title); 59 std::string final_title = RunTest(gurl, expected_title);
58 EXPECT_EQ(expected_title, final_title); 60 EXPECT_EQ(expected_title, final_title);
59 } 61 }
60 62
61 std::string RunTest(const GURL& gurl, 63 std::string RunTest(const GURL& gurl,
62 const std::string& expected_title) { 64 const std::string& expected_title) {
63 content::TitleWatcher title_watcher(web_contents(), 65 content::WebContents* web_contents = helper_->NavigateToURL(gurl);
66 content::TitleWatcher title_watcher(web_contents,
64 base::ASCIIToUTF16(expected_title)); 67 base::ASCIIToUTF16(expected_title));
65 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); 68 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded));
66 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError)); 69 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError));
67 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); 70 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed));
68
69 NavigateToURL(web_contents(), gurl);
70 base::string16 result = title_watcher.WaitAndGetTitle(); 71 base::string16 result = title_watcher.WaitAndGetTitle();
71 return base::UTF16ToASCII(result); 72 return base::UTF16ToASCII(result);
72 } 73 }
73 74
74 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest); 75 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest);
75 }; 76 };
76 77
77 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) { 78 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) {
78 // Run an entire browser lifecycle to ensure nothing breaks. 79 // Run an entire browser lifecycle to ensure nothing breaks.
79 // TODO(gunsch): Remove this test case once there are actual assertions to 80 LoadAboutBlank();
80 // test in a ChromecastBrowserTest instance.
81 EXPECT_TRUE(true);
82 } 81 }
83 82
84 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, AudioPlaybackWavPcm) { 83 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, AudioPlaybackWavPcm) {
85 PlayAudio("bear_pcm.wav"); 84 PlayAudio("bear_pcm.wav");
86 } 85 }
87 86
88 #if !BUILDFLAG(DISABLE_DISPLAY) 87 #if !BUILDFLAG(DISABLE_DISPLAY)
89 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, VideoPlaybackMp4) { 88 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, VideoPlaybackMp4) {
90 PlayVideo("bear.mp4"); 89 PlayVideo("bear.mp4");
91 } 90 }
92 #endif 91 #endif
93 92
94 } // namespace shell 93 } // namespace shell
95 } // namespace chromecast 94 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/test/chromecast_browser_test_helper_default.cc ('k') | chromecast/chromecast_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698