| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/macros.h" |
| 6 #include "base/strings/string_split.h" |
| 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chromecast/browser/test/chromecast_browser_test.h" |
| 9 #include "chromecast/chromecast_features.h" |
| 10 #include "content/public/test/browser_test_utils.h" |
| 11 #include "media/base/test_data_util.h" |
| 12 #include "url/gurl.h" |
| 13 #include "url/url_constants.h" |
| 14 |
| 15 namespace chromecast { |
| 16 namespace shell { |
| 17 namespace { |
| 18 const char kEnded[] = "ENDED"; |
| 19 const char kError[] = "ERROR"; |
| 20 const char kFailed[] = "FAILED"; |
| 21 } |
| 22 |
| 23 class ChromecastShellBrowserTest : public ChromecastBrowserTest { |
| 24 public: |
| 25 ChromecastShellBrowserTest() {} |
| 26 |
| 27 void LoadAboutBlank() { |
| 28 content::WebContents* web_contents = |
| 29 NavigateToURL(GURL(url::kAboutBlankURL)); |
| 30 content::TitleWatcher title_watcher( |
| 31 web_contents, base::ASCIIToUTF16(url::kAboutBlankURL)); |
| 32 base::string16 result = title_watcher.WaitAndGetTitle(); |
| 33 EXPECT_EQ(url::kAboutBlankURL, base::UTF16ToASCII(result)); |
| 34 } |
| 35 void PlayAudio(const std::string& media_file) { |
| 36 PlayMedia("audio", media_file); |
| 37 } |
| 38 void PlayVideo(const std::string& media_file) { |
| 39 PlayMedia("video", media_file); |
| 40 } |
| 41 |
| 42 private: |
| 43 void PlayMedia(const std::string& tag, |
| 44 const std::string& media_file) { |
| 45 base::StringPairs query_params; |
| 46 query_params.push_back(std::make_pair(tag, media_file)); |
| 47 RunMediaTestPage("player.html", query_params, kEnded); |
| 48 } |
| 49 |
| 50 void RunMediaTestPage(const std::string& html_page, |
| 51 const base::StringPairs& query_params, |
| 52 const std::string& expected_title) { |
| 53 std::string query = media::GetURLQueryString(query_params); |
| 54 GURL gurl = content::GetFileUrlWithQuery( |
| 55 media::GetTestDataFilePath(html_page), |
| 56 query); |
| 57 |
| 58 std::string final_title = RunTest(gurl, expected_title); |
| 59 EXPECT_EQ(expected_title, final_title); |
| 60 } |
| 61 |
| 62 std::string RunTest(const GURL& gurl, |
| 63 const std::string& expected_title) { |
| 64 content::WebContents* web_contents = NavigateToURL(gurl); |
| 65 content::TitleWatcher title_watcher(web_contents, |
| 66 base::ASCIIToUTF16(expected_title)); |
| 67 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); |
| 68 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError)); |
| 69 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); |
| 70 base::string16 result = title_watcher.WaitAndGetTitle(); |
| 71 return base::UTF16ToASCII(result); |
| 72 } |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest); |
| 75 }; |
| 76 |
| 77 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) { |
| 78 // Run an entire browser lifecycle to ensure nothing breaks. |
| 79 LoadAboutBlank(); |
| 80 } |
| 81 |
| 82 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, AudioPlaybackWavPcm) { |
| 83 PlayAudio("bear_pcm.wav"); |
| 84 } |
| 85 |
| 86 #if !BUILDFLAG(IS_CAST_AUDIO_ONLY) |
| 87 IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, VideoPlaybackMp4) { |
| 88 PlayVideo("bear.mp4"); |
| 89 } |
| 90 #endif |
| 91 |
| 92 } // namespace shell |
| 93 } // namespace chromecast |
| OLD | NEW |