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

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

Issue 2485843002: [chromecast] Merge ChromecastBrowserTestHelper into ChromecastBrowserTest (Closed)
Patch Set: addressed comment Created 4 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
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"
10 #include "chromecast/chromecast_features.h" 9 #include "chromecast/chromecast_features.h"
11 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
12 #include "media/base/test_data_util.h" 11 #include "media/base/test_data_util.h"
13 #include "url/gurl.h" 12 #include "url/gurl.h"
14 #include "url/url_constants.h" 13 #include "url/url_constants.h"
15 14
16 namespace chromecast { 15 namespace chromecast {
17 namespace shell { 16 namespace shell {
18 namespace { 17 namespace {
19 const char kEnded[] = "ENDED"; 18 const char kEnded[] = "ENDED";
20 const char kError[] = "ERROR"; 19 const char kError[] = "ERROR";
21 const char kFailed[] = "FAILED"; 20 const char kFailed[] = "FAILED";
22 } 21 }
23 22
24 class ChromecastShellBrowserTest : public ChromecastBrowserTest { 23 class ChromecastShellBrowserTest : public ChromecastBrowserTest {
25 public: 24 public:
26 ChromecastShellBrowserTest() {} 25 ChromecastShellBrowserTest() {}
27 26
28 void LoadAboutBlank() { 27 void LoadAboutBlank() {
29 content::WebContents* web_contents = 28 content::WebContents* web_contents =
30 helper_->NavigateToURL(GURL(url::kAboutBlankURL)); 29 NavigateToURL(GURL(url::kAboutBlankURL));
31 content::TitleWatcher title_watcher( 30 content::TitleWatcher title_watcher(
32 web_contents, base::ASCIIToUTF16(url::kAboutBlankURL)); 31 web_contents, base::ASCIIToUTF16(url::kAboutBlankURL));
33 base::string16 result = title_watcher.WaitAndGetTitle(); 32 base::string16 result = title_watcher.WaitAndGetTitle();
34 EXPECT_EQ(url::kAboutBlankURL, base::UTF16ToASCII(result)); 33 EXPECT_EQ(url::kAboutBlankURL, base::UTF16ToASCII(result));
35 } 34 }
36 void PlayAudio(const std::string& media_file) { 35 void PlayAudio(const std::string& media_file) {
37 PlayMedia("audio", media_file); 36 PlayMedia("audio", media_file);
38 } 37 }
39 void PlayVideo(const std::string& media_file) { 38 void PlayVideo(const std::string& media_file) {
40 PlayMedia("video", media_file); 39 PlayMedia("video", media_file);
(...skipping 14 matching lines...) Expand all
55 GURL gurl = content::GetFileUrlWithQuery( 54 GURL gurl = content::GetFileUrlWithQuery(
56 media::GetTestDataFilePath(html_page), 55 media::GetTestDataFilePath(html_page),
57 query); 56 query);
58 57
59 std::string final_title = RunTest(gurl, expected_title); 58 std::string final_title = RunTest(gurl, expected_title);
60 EXPECT_EQ(expected_title, final_title); 59 EXPECT_EQ(expected_title, final_title);
61 } 60 }
62 61
63 std::string RunTest(const GURL& gurl, 62 std::string RunTest(const GURL& gurl,
64 const std::string& expected_title) { 63 const std::string& expected_title) {
65 content::WebContents* web_contents = helper_->NavigateToURL(gurl); 64 content::WebContents* web_contents = NavigateToURL(gurl);
66 content::TitleWatcher title_watcher(web_contents, 65 content::TitleWatcher title_watcher(web_contents,
67 base::ASCIIToUTF16(expected_title)); 66 base::ASCIIToUTF16(expected_title));
68 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); 67 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded));
69 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError)); 68 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError));
70 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); 69 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed));
71 base::string16 result = title_watcher.WaitAndGetTitle(); 70 base::string16 result = title_watcher.WaitAndGetTitle();
72 return base::UTF16ToASCII(result); 71 return base::UTF16ToASCII(result);
73 } 72 }
74 73
75 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest); 74 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest);
76 }; 75 };
77 76
78 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) { 77 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) {
79 // Run an entire browser lifecycle to ensure nothing breaks. 78 // Run an entire browser lifecycle to ensure nothing breaks.
80 LoadAboutBlank(); 79 LoadAboutBlank();
81 } 80 }
82 81
83 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, AudioPlaybackWavPcm) { 82 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, AudioPlaybackWavPcm) {
84 PlayAudio("bear_pcm.wav"); 83 PlayAudio("bear_pcm.wav");
85 } 84 }
86 85
87 #if !BUILDFLAG(IS_CAST_AUDIO_ONLY) 86 #if !BUILDFLAG(IS_CAST_AUDIO_ONLY)
88 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, VideoPlaybackMp4) { 87 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, VideoPlaybackMp4) {
89 PlayVideo("bear.mp4"); 88 PlayVideo("bear.mp4");
90 } 89 }
91 #endif 90 #endif
92 91
93 } // namespace shell 92 } // namespace shell
94 } // namespace chromecast 93 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698