| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/threading/thread_task_runner_handle.h" | 6 #include "base/threading/thread_task_runner_handle.h" |
| 7 #include "chrome/browser/extensions/browser_action_test_util.h" | 7 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 11 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" | |
| 12 #include "chrome/browser/ui/toolbar/media_router_action.h" | 11 #include "chrome/browser/ui/toolbar/media_router_action.h" |
| 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" | 12 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
| 14 #include "chrome/browser/ui/views/frame/browser_view.h" | 13 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 15 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" | 14 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
| 16 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 15 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 17 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" | 16 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
| 18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 19 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 BrowserActionsContainer* browser_actions_container = | 36 BrowserActionsContainer* browser_actions_container = |
| 38 BrowserView::GetBrowserViewForBrowser(browser()) | 37 BrowserView::GetBrowserViewForBrowser(browser()) |
| 39 ->toolbar() | 38 ->toolbar() |
| 40 ->browser_actions(); | 39 ->browser_actions(); |
| 41 ASSERT_TRUE(browser_actions_container); | 40 ASSERT_TRUE(browser_actions_container); |
| 42 | 41 |
| 43 browser_action_test_util_.reset(new BrowserActionTestUtil(browser(), | 42 browser_action_test_util_.reset(new BrowserActionTestUtil(browser(), |
| 44 false)); | 43 false)); |
| 45 media_router_action_.reset(new MediaRouterAction(browser(), | 44 media_router_action_.reset(new MediaRouterAction(browser(), |
| 46 browser_action_test_util_->GetToolbarActionsBar())); | 45 browser_action_test_util_->GetToolbarActionsBar())); |
| 47 // Toggle the "always show" setting on. | |
| 48 media_router_action_->ToggleVisibilityPreference(); | |
| 49 | 46 |
| 50 toolbar_action_view_widget_ = new views::Widget(); | 47 toolbar_action_view_widget_ = new views::Widget(); |
| 51 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 48 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 52 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 49 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 53 toolbar_action_view_widget_->Init(params); | 50 toolbar_action_view_widget_->Init(params); |
| 54 toolbar_action_view_widget_->Show(); | 51 toolbar_action_view_widget_->Show(); |
| 55 | 52 |
| 56 // Sets delegate on |media_router_action_|. | 53 // Sets delegate on |media_router_action_|. |
| 57 toolbar_action_view_ = new ToolbarActionView(media_router_action_.get(), | 54 toolbar_action_view_ = new ToolbarActionView(media_router_action_.get(), |
| 58 browser_actions_container); | 55 browser_actions_container); |
| 59 toolbar_action_view_widget_->SetContentsView(toolbar_action_view_); | 56 toolbar_action_view_widget_->SetContentsView(toolbar_action_view_); |
| 60 } | 57 } |
| 61 | 58 |
| 62 void TearDownOnMainThread() override { | 59 void TearDownOnMainThread() override { |
| 63 toolbar_action_view_widget_->Close(); | 60 toolbar_action_view_widget_->Close(); |
| 64 // Toggle the "always show" setting off. | |
| 65 media_router_action_->ToggleVisibilityPreference(); | |
| 66 media_router_action_.reset(); | 61 media_router_action_.reset(); |
| 67 browser_action_test_util_.reset(); | 62 browser_action_test_util_.reset(); |
| 68 InProcessBrowserTest::TearDownOnMainThread(); | 63 InProcessBrowserTest::TearDownOnMainThread(); |
| 69 } | 64 } |
| 70 | 65 |
| 71 void OpenMediaRouterDialogAndWaitForNewWebContents() { | 66 void OpenMediaRouterDialogAndWaitForNewWebContents() { |
| 72 content::TestNavigationObserver nav_observer(NULL); | 67 content::TestNavigationObserver nav_observer(NULL); |
| 73 nav_observer.StartWatchingNewWebContents(); | 68 nav_observer.StartWatchingNewWebContents(); |
| 74 | 69 |
| 75 AppMenuButton* app_menu_button = | 70 AppMenuButton* app_menu_button = |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 125 |
| 131 // Navigate away. | 126 // Navigate away. |
| 132 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 127 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 133 | 128 |
| 134 // The navigation should have removed the previously created dialog. | 129 // The navigation should have removed the previously created dialog. |
| 135 // We expect a new dialog WebContents to be created by calling this. | 130 // We expect a new dialog WebContents to be created by calling this. |
| 136 OpenMediaRouterDialogAndWaitForNewWebContents(); | 131 OpenMediaRouterDialogAndWaitForNewWebContents(); |
| 137 } | 132 } |
| 138 | 133 |
| 139 } // namespace media_router | 134 } // namespace media_router |
| OLD | NEW |