| 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/cast_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 CastNavigationBrowserTest : public CastBrowserTest { | |
| 24 public: | |
| 25 CastNavigationBrowserTest() {} | |
| 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, const std::string& media_file) { | |
| 44 base::StringPairs query_params; | |
| 45 query_params.push_back(std::make_pair(tag, media_file)); | |
| 46 RunMediaTestPage("player.html", query_params, kEnded); | |
| 47 } | |
| 48 | |
| 49 void RunMediaTestPage(const std::string& html_page, | |
| 50 const base::StringPairs& query_params, | |
| 51 const std::string& expected_title) { | |
| 52 std::string query = media::GetURLQueryString(query_params); | |
| 53 GURL gurl = content::GetFileUrlWithQuery( | |
| 54 media::GetTestDataFilePath(html_page), query); | |
| 55 | |
| 56 std::string final_title = RunTest(gurl, expected_title); | |
| 57 EXPECT_EQ(expected_title, final_title); | |
| 58 } | |
| 59 | |
| 60 std::string RunTest(const GURL& gurl, const std::string& expected_title) { | |
| 61 content::WebContents* web_contents = NavigateToURL(gurl); | |
| 62 content::TitleWatcher title_watcher(web_contents, | |
| 63 base::ASCIIToUTF16(expected_title)); | |
| 64 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); | |
| 65 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError)); | |
| 66 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); | |
| 67 base::string16 result = title_watcher.WaitAndGetTitle(); | |
| 68 return base::UTF16ToASCII(result); | |
| 69 } | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(CastNavigationBrowserTest); | |
| 72 }; | |
| 73 | |
| 74 IN_PROC_BROWSER_TEST_F(CastNavigationBrowserTest, EmptyTest) { | |
| 75 // Run an entire browser lifecycle to ensure nothing breaks. | |
| 76 LoadAboutBlank(); | |
| 77 } | |
| 78 | |
| 79 IN_PROC_BROWSER_TEST_F(CastNavigationBrowserTest, AudioPlaybackWavPcm) { | |
| 80 PlayAudio("bear_pcm.wav"); | |
| 81 } | |
| 82 | |
| 83 #if !BUILDFLAG(IS_CAST_AUDIO_ONLY) | |
| 84 IN_PROC_BROWSER_TEST_F(CastNavigationBrowserTest, VideoPlaybackMp4) { | |
| 85 PlayVideo("bear.mp4"); | |
| 86 } | |
| 87 #endif | |
| 88 | |
| 89 } // namespace shell | |
| 90 } // namespace chromecast | |
| OLD | NEW |