| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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/command_line.h" | |
| 6 #include "base/memory/ref_counted.h" | |
| 7 #include "base/utf_string_conversions.h" | |
| 8 #include "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/browser/ui/browser_list.h" | |
| 10 #include "chrome/browser/ui/webui/mediaplayer_ui.h" | |
| 11 #include "chrome/common/chrome_switches.h" | |
| 12 #include "chrome/common/url_constants.h" | |
| 13 #include "chrome/test/automation/dom_element_proxy.h" | |
| 14 #include "chrome/test/in_process_browser_test.h" | |
| 15 #include "chrome/test/ui_test_utils.h" | |
| 16 #include "content/browser/tab_contents/tab_contents.h" | |
| 17 | |
| 18 namespace { | |
| 19 | |
| 20 class MediaPlayerBrowserTest : public InProcessBrowserTest { | |
| 21 public: | |
| 22 MediaPlayerBrowserTest() {} | |
| 23 | |
| 24 GURL GetMusicTestURL() { | |
| 25 return GURL("http://localhost:1337/files/plugin/sample_mp3.mp3"); | |
| 26 } | |
| 27 | |
| 28 bool IsPlayerVisible() { | |
| 29 for (BrowserList::const_iterator it = BrowserList::begin(); | |
| 30 it != BrowserList::end(); ++it) { | |
| 31 if ((*it)->is_type_panel() && (*it)->is_app()) { | |
| 32 const GURL& url = | |
| 33 (*it)->GetTabContentsAt((*it)->active_index())->GetURL(); | |
| 34 | |
| 35 if (url.SchemeIs(chrome::kChromeUIScheme) && | |
| 36 url.host() == chrome::kChromeUIMediaplayerHost) { | |
| 37 return true; | |
| 38 } | |
| 39 } | |
| 40 } | |
| 41 return false; | |
| 42 } | |
| 43 | |
| 44 bool IsPlaylistVisible() { | |
| 45 for (BrowserList::const_iterator it = BrowserList::begin(); | |
| 46 it != BrowserList::end(); ++it) { | |
| 47 if ((*it)->is_type_panel() && (*it)->is_app()) { | |
| 48 const GURL& url = | |
| 49 (*it)->GetTabContentsAt((*it)->active_index())->GetURL(); | |
| 50 | |
| 51 if (url.SchemeIs(chrome::kChromeUIScheme) && | |
| 52 url.host() == chrome::kChromeUIMediaplayerHost && | |
| 53 url.ref() == "playlist") { | |
| 54 return true; | |
| 55 } | |
| 56 } | |
| 57 } | |
| 58 return false; | |
| 59 } | |
| 60 }; | |
| 61 | |
| 62 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) { | |
| 63 ASSERT_TRUE(test_server()->Start()); | |
| 64 // Doing this so we have a valid profile. | |
| 65 ui_test_utils::NavigateToURL(browser(), | |
| 66 GURL("chrome://downloads")); | |
| 67 | |
| 68 MediaPlayer* player = MediaPlayer::GetInstance(); | |
| 69 // Check that its not currently visible | |
| 70 ASSERT_FALSE(IsPlayerVisible()); | |
| 71 | |
| 72 player->EnqueueMediaFileUrl(GetMusicTestURL(), NULL); | |
| 73 | |
| 74 ASSERT_TRUE(IsPlayerVisible()); | |
| 75 } | |
| 76 | |
| 77 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, PopupPlaylist) { | |
| 78 ASSERT_TRUE(test_server()->Start()); | |
| 79 // Doing this so we have a valid profile. | |
| 80 ui_test_utils::NavigateToURL(browser(), | |
| 81 GURL("chrome://downloads")); | |
| 82 | |
| 83 | |
| 84 MediaPlayer* player = MediaPlayer::GetInstance(); | |
| 85 | |
| 86 player->EnqueueMediaFileUrl(GetMusicTestURL(), NULL); | |
| 87 | |
| 88 EXPECT_FALSE(IsPlaylistVisible()); | |
| 89 | |
| 90 player->TogglePlaylistWindowVisible(); | |
| 91 | |
| 92 EXPECT_TRUE(IsPlaylistVisible()); | |
| 93 } | |
| 94 | |
| 95 } // namespace | |
| OLD | NEW |