Add test for the TermsOfServiceURL policy
[chromium-blink-merge.git] / chrome / browser / chromeos / media / media_player_browsertest.cc
blob6590705837681372ceb3a9201ef1aa8c9915943f
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/memory/ref_counted.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/media/media_player.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_iterator.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
16 class MediaPlayerBrowserTest : public InProcessBrowserTest {
17 public:
18 MediaPlayerBrowserTest() {}
20 GURL GetMusicTestURL() {
21 return GURL("http://localhost:1337/files/plugin/sample_mp3.mp3");
24 bool IsBrowserVisible(Browser* browser) {
25 if (browser == NULL)
26 return false;
27 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
28 if (it->is_type_popup() && it->is_app() && (*it) == browser)
29 return true;
31 return false;
34 bool IsPlayerVisible() {
35 return IsBrowserVisible(MediaPlayer::GetInstance()->GetBrowser());
39 IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) {
40 ASSERT_TRUE(test_server()->Start());
41 // Doing this so we have a valid profile.
42 ui_test_utils::NavigateToURL(browser(),
43 GURL("chrome://downloads"));
45 MediaPlayer* player = MediaPlayer::GetInstance();
46 // Check that its not currently visible
47 ASSERT_FALSE(IsPlayerVisible());
49 player->PopupMediaPlayer();
50 player->ForcePlayMediaURL(GetMusicTestURL());
52 ASSERT_TRUE(IsPlayerVisible());