Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 "chrome/browser/ui/browser.h" | |
| 6 #include "chrome/browser/ui/browser_commands.h" | |
| 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 8 #include "chrome/browser/ui/toolbar/media_router_action.h" | |
| 9 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" | |
| 10 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 11 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | |
| 12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" | |
| 13 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | |
| 14 #include "chrome/test/base/in_process_browser_test.h" | |
| 15 #include "chrome/test/base/ui_test_utils.h" | |
| 16 #include "content/public/browser/web_contents.h" | |
| 17 #include "content/public/test/test_navigation_observer.h" | |
| 18 #include "content/public/test/test_utils.h" | |
| 19 | |
| 20 namespace media_router { | |
| 21 | |
| 22 class MediaRouterUIBrowserTest : public InProcessBrowserTest { | |
| 23 public: | |
| 24 MediaRouterUIBrowserTest() {} | |
| 25 ~MediaRouterUIBrowserTest() override {} | |
| 26 | |
| 27 void SetUpOnMainThread() override { | |
| 28 InProcessBrowserTest::SetUpOnMainThread(); | |
| 29 | |
| 30 BrowserActionsContainer* main_bar = | |
|
Peter Kasting
2015/06/04 00:17:53
Nit: I think |browser_actions| might be a better n
imcheng (use chromium acct)
2015/06/04 01:04:20
Done.
| |
| 31 BrowserView::GetBrowserViewForBrowser(browser()) | |
| 32 ->toolbar() | |
| 33 ->browser_actions(); | |
| 34 ASSERT_TRUE(main_bar); | |
| 35 | |
| 36 mr_action_.reset(new MediaRouterAction); | |
| 37 | |
| 38 // Sets delegate on |mr_action_|. | |
| 39 toolbar_action_view_.reset(new ToolbarActionView( | |
| 40 mr_action_.get(), browser()->profile(), main_bar)); | |
| 41 } | |
| 42 | |
| 43 void OpenMediaRouterDialog() { | |
| 44 content::TestNavigationObserver nav_observer(NULL); | |
| 45 nav_observer.StartWatchingNewWebContents(); | |
| 46 mr_action_->ExecuteAction(true); | |
| 47 nav_observer.Wait(); | |
| 48 nav_observer.StopWatchingNewWebContents(); | |
| 49 } | |
| 50 | |
| 51 protected: | |
| 52 // Must be initialized after |InProcessBrowserTest::SetUpOnMainThread|. | |
| 53 scoped_ptr<MediaRouterAction> mr_action_; | |
|
Peter Kasting
2015/06/04 00:17:53
Nit: |media_router_action_| (or at least |router_a
imcheng (use chromium acct)
2015/06/04 01:04:20
Done.
| |
| 54 | |
| 55 // ToolbarActionView constructed to set the delegate on |mr_action|. | |
| 56 scoped_ptr<ToolbarActionView> toolbar_action_view_; | |
| 57 }; | |
| 58 | |
| 59 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, MediaRouterCommands) { | |
|
Peter Kasting
2015/06/04 00:17:53
What is this actually testing? The comments say w
imcheng (use chromium acct)
2015/06/04 01:04:20
Renamed the function to be more explicit about exp
| |
| 60 // We start off at about:blank page. | |
| 61 // Make sure there is 1 tab and media router is enabled. | |
| 62 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | |
| 63 | |
| 64 OpenMediaRouterDialog(); | |
| 65 | |
| 66 // Reload the browser and wait. | |
| 67 content::TestNavigationObserver reload_observer( | |
| 68 browser()->tab_strip_model()->GetActiveWebContents()); | |
| 69 chrome::Reload(browser(), CURRENT_TAB); | |
| 70 reload_observer.Wait(); | |
| 71 | |
| 72 OpenMediaRouterDialog(); | |
| 73 | |
| 74 // Navigate away and wait. | |
| 75 content::TestNavigationObserver nav_observer( | |
| 76 browser()->tab_strip_model()->GetActiveWebContents(), 1); | |
| 77 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | |
| 78 | |
| 79 nav_observer.Wait(); | |
| 80 | |
| 81 OpenMediaRouterDialog(); | |
| 82 } | |
| 83 | |
| 84 } // namespace media_router | |
| OLD | NEW |