OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/command_line.h" |
5 #include "base/ref_counted.h" | 6 #include "base/ref_counted.h" |
6 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
7 #include "chrome/test/automation/dom_element_proxy.h" | 8 #include "chrome/test/automation/dom_element_proxy.h" |
8 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/dom_ui/mediaplayer_ui.h" | 11 #include "chrome/browser/dom_ui/mediaplayer_ui.h" |
11 #include "chrome/browser/prefs/pref_service.h" | |
12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
13 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "chrome/test/in_process_browser_test.h" | 16 #include "chrome/test/in_process_browser_test.h" |
17 #include "chrome/test/ui_test_utils.h" | 17 #include "chrome/test/ui_test_utils.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class MediaPlayerBrowserTest : public InProcessBrowserTest { | 21 class MediaPlayerBrowserTest : public InProcessBrowserTest { |
22 public: | 22 public: |
23 MediaPlayerBrowserTest() {} | 23 MediaPlayerBrowserTest() {} |
24 | 24 |
| 25 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 26 command_line->AppendSwitch(switches::kEnableMediaPlayer); |
| 27 } |
| 28 |
25 GURL GetMusicTestURL() { | 29 GURL GetMusicTestURL() { |
26 return GURL("http://localhost:1337/files/plugin/sample_mp3.mp3"); | 30 return GURL("http://localhost:1337/files/plugin/sample_mp3.mp3"); |
27 } | 31 } |
28 | 32 |
29 bool IsPlayerVisible() { | 33 bool IsPlayerVisible() { |
30 for (BrowserList::const_iterator it = BrowserList::begin(); | 34 for (BrowserList::const_iterator it = BrowserList::begin(); |
31 it != BrowserList::end(); ++it) { | 35 it != BrowserList::end(); ++it) { |
32 if ((*it)->type() == Browser::TYPE_APP_PANEL) { | 36 if ((*it)->type() == Browser::TYPE_APP_PANEL) { |
33 const GURL& url = | 37 const GURL& url = |
34 (*it)->GetTabContentsAt((*it)->selected_index())->GetURL(); | 38 (*it)->GetTabContentsAt((*it)->selected_index())->GetURL(); |
(...skipping 24 matching lines...) Expand all Loading... |
59 return false; | 63 return false; |
60 } | 64 } |
61 }; | 65 }; |
62 | 66 |
63 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) { | 67 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) { |
64 ASSERT_TRUE(test_server()->Start()); | 68 ASSERT_TRUE(test_server()->Start()); |
65 // Doing this so we have a valid profile. | 69 // Doing this so we have a valid profile. |
66 ui_test_utils::NavigateToURL(browser(), | 70 ui_test_utils::NavigateToURL(browser(), |
67 GURL("chrome://downloads")); | 71 GURL("chrome://downloads")); |
68 | 72 |
69 PrefService* pref_service = browser()->profile()->GetPrefs(); | |
70 pref_service->SetBoolean(prefs::kLabsMediaplayerEnabled, true); | |
71 | |
72 MediaPlayer* player = MediaPlayer::Get(); | 73 MediaPlayer* player = MediaPlayer::Get(); |
73 // Check that its not currently visible | 74 // Check that its not currently visible |
74 ASSERT_FALSE(IsPlayerVisible()); | 75 ASSERT_FALSE(IsPlayerVisible()); |
75 | 76 |
76 player->EnqueueMediaURL(GetMusicTestURL(), NULL); | 77 player->EnqueueMediaURL(GetMusicTestURL(), NULL); |
77 | 78 |
78 ASSERT_TRUE(IsPlayerVisible()); | 79 ASSERT_TRUE(IsPlayerVisible()); |
79 } | 80 } |
80 | 81 |
81 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, PopupPlaylist) { | 82 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, PopupPlaylist) { |
82 ASSERT_TRUE(test_server()->Start()); | 83 ASSERT_TRUE(test_server()->Start()); |
83 // Doing this so we have a valid profile. | 84 // Doing this so we have a valid profile. |
84 ui_test_utils::NavigateToURL(browser(), | 85 ui_test_utils::NavigateToURL(browser(), |
85 GURL("chrome://downloads")); | 86 GURL("chrome://downloads")); |
86 | 87 |
87 | 88 |
88 PrefService* pref_service = browser()->profile()->GetPrefs(); | |
89 pref_service->SetBoolean(prefs::kLabsMediaplayerEnabled, true); | |
90 | |
91 MediaPlayer* player = MediaPlayer::Get(); | 89 MediaPlayer* player = MediaPlayer::Get(); |
92 | 90 |
93 player->EnqueueMediaURL(GetMusicTestURL(), NULL); | 91 player->EnqueueMediaURL(GetMusicTestURL(), NULL); |
94 | 92 |
95 EXPECT_FALSE(IsPlaylistVisible()); | 93 EXPECT_FALSE(IsPlaylistVisible()); |
96 | 94 |
97 player->TogglePlaylistWindowVisible(); | 95 player->TogglePlaylistWindowVisible(); |
98 | 96 |
99 EXPECT_TRUE(IsPlaylistVisible()); | 97 EXPECT_TRUE(IsPlaylistVisible()); |
100 } | 98 } |
101 | 99 |
102 } // namespace | 100 } // namespace |
OLD | NEW |