OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/ref_counted.h" |
| 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/test/automation/dom_element_proxy.h" |
| 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/chromeos/cros/mock_mount_library.h" |
| 11 #include "chrome/browser/chromeos/usb_mount_observer.h" |
| 12 #include "chrome/browser/dom_ui/mediaplayer_ui.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 14 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/test/in_process_browser_test.h" |
| 16 #include "chrome/test/ui_test_utils.h" |
| 17 |
| 18 namespace { |
| 19 |
| 20 class USBMountObserverBrowserTest : public InProcessBrowserTest { |
| 21 public: |
| 22 USBMountObserverBrowserTest() {} |
| 23 |
| 24 bool IsFilebrowserVisible() { |
| 25 for (BrowserList::const_iterator it = BrowserList::begin(); |
| 26 it != BrowserList::end(); ++it) { |
| 27 if ((*it)->type() == Browser::TYPE_POPUP) { |
| 28 const GURL& url = |
| 29 (*it)->GetTabContentsAt((*it)->selected_index())->GetURL(); |
| 30 if (url.SchemeIs(chrome::kChromeUIScheme) && |
| 31 url.host() == chrome::kChromeUIFileBrowseHost) { |
| 32 return true; |
| 33 } |
| 34 } |
| 35 } |
| 36 return false; |
| 37 } |
| 38 }; |
| 39 |
| 40 IN_PROC_BROWSER_TEST_F(USBMountObserverBrowserTest, PopupOnEvent) { |
| 41 StartHTTPServer(); |
| 42 // Doing this so we have a valid profile |
| 43 ui_test_utils::NavigateToURL(browser(), |
| 44 GURL(chrome::kChromeUIDownloadsURL)); |
| 45 chromeos::USBMountObserver* observe = chromeos::USBMountObserver::Get(); |
| 46 observe->set_profile(browser()->profile()); |
| 47 scoped_ptr<chromeos::MockMountLibrary> lib(new chromeos::MockMountLibrary()); |
| 48 lib->AddObserver(observe); |
| 49 // Check that its not currently visible |
| 50 EXPECT_FALSE(IsFilebrowserVisible()); |
| 51 |
| 52 lib->FireDeviceInsertEvents(); |
| 53 |
| 54 EXPECT_TRUE(IsFilebrowserVisible()); |
| 55 } |
| 56 |
| 57 } |
OLD | NEW |