OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/chromeos/media/media_player.h" | 8 #include "chrome/browser/chromeos/media/media_player.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 | 15 |
16 class MediaPlayerBrowserTest : public InProcessBrowserTest { | 16 class MediaPlayerBrowserTest : public InProcessBrowserTest { |
17 public: | 17 public: |
18 MediaPlayerBrowserTest() {} | 18 MediaPlayerBrowserTest() {} |
19 | 19 |
20 GURL GetMusicTestURL() { | 20 GURL GetMusicTestURL() { |
21 return GURL("http://localhost:1337/files/plugin/sample_mp3.mp3"); | 21 return GURL("http://localhost:1337/files/plugin/sample_mp3.mp3"); |
22 } | 22 } |
23 | 23 |
24 bool IsBrowserVisible(Browser* browser) { | 24 bool IsBrowserVisible(Browser* browser) { |
25 if (browser == NULL) | 25 if (browser == NULL) |
26 return false; | 26 return false; |
27 for (BrowserList::const_iterator it = BrowserList::begin(); | 27 for (BrowserList::const_iterator it = BrowserList::begin(); |
28 it != BrowserList::end(); ++it) { | 28 it != BrowserList::end(); ++it) { |
29 if ((*it)->is_type_panel() && (*it)->is_app() && (*it) == browser) | 29 if ((*it)->is_type_popup() && (*it)->is_app() && (*it) == browser) |
30 return true; | 30 return true; |
31 } | 31 } |
32 return false; | 32 return false; |
33 } | 33 } |
34 | 34 |
35 bool IsPlayerVisible() { | 35 bool IsPlayerVisible() { |
36 return IsBrowserVisible(MediaPlayer::GetInstance()->GetBrowser()); | 36 return IsBrowserVisible(MediaPlayer::GetInstance()->GetBrowser()); |
37 } | 37 } |
38 }; | 38 }; |
39 | 39 |
40 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) { | 40 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) { |
41 ASSERT_TRUE(test_server()->Start()); | 41 ASSERT_TRUE(test_server()->Start()); |
42 // Doing this so we have a valid profile. | 42 // Doing this so we have a valid profile. |
43 ui_test_utils::NavigateToURL(browser(), | 43 ui_test_utils::NavigateToURL(browser(), |
44 GURL("chrome://downloads")); | 44 GURL("chrome://downloads")); |
45 | 45 |
46 MediaPlayer* player = MediaPlayer::GetInstance(); | 46 MediaPlayer* player = MediaPlayer::GetInstance(); |
47 // Check that its not currently visible | 47 // Check that its not currently visible |
48 ASSERT_FALSE(IsPlayerVisible()); | 48 ASSERT_FALSE(IsPlayerVisible()); |
49 | 49 |
50 player->PopupMediaPlayer(); | 50 player->PopupMediaPlayer(); |
51 player->ForcePlayMediaURL(GetMusicTestURL()); | 51 player->ForcePlayMediaURL(GetMusicTestURL()); |
52 | 52 |
53 ASSERT_TRUE(IsPlayerVisible()); | 53 ASSERT_TRUE(IsPlayerVisible()); |
54 } | 54 } |
OLD | NEW |