Chromium Code Reviews| Index: chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc |
| diff --git a/chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc b/chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dec552dda92fe52349aa968513de2c0032e7c738 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc |
| @@ -0,0 +1,84 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_commands.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/browser/ui/toolbar/media_router_action.h" |
| +#include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
| +#include "chrome/browser/ui/views/frame/browser_view.h" |
| +#include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| +#include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
| +#include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "content/public/test/test_navigation_observer.h" |
| +#include "content/public/test/test_utils.h" |
| + |
| +namespace media_router { |
| + |
| +class MediaRouterUIBrowserTest : public InProcessBrowserTest { |
| + public: |
| + MediaRouterUIBrowserTest() {} |
| + ~MediaRouterUIBrowserTest() override {} |
| + |
| + void SetUpOnMainThread() override { |
| + InProcessBrowserTest::SetUpOnMainThread(); |
| + |
| + 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.
|
| + BrowserView::GetBrowserViewForBrowser(browser()) |
| + ->toolbar() |
| + ->browser_actions(); |
| + ASSERT_TRUE(main_bar); |
| + |
| + mr_action_.reset(new MediaRouterAction); |
| + |
| + // Sets delegate on |mr_action_|. |
| + toolbar_action_view_.reset(new ToolbarActionView( |
| + mr_action_.get(), browser()->profile(), main_bar)); |
| + } |
| + |
| + void OpenMediaRouterDialog() { |
| + content::TestNavigationObserver nav_observer(NULL); |
| + nav_observer.StartWatchingNewWebContents(); |
| + mr_action_->ExecuteAction(true); |
| + nav_observer.Wait(); |
| + nav_observer.StopWatchingNewWebContents(); |
| + } |
| + |
| + protected: |
| + // Must be initialized after |InProcessBrowserTest::SetUpOnMainThread|. |
| + 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.
|
| + |
| + // ToolbarActionView constructed to set the delegate on |mr_action|. |
| + scoped_ptr<ToolbarActionView> toolbar_action_view_; |
| +}; |
| + |
| +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
|
| + // We start off at about:blank page. |
| + // Make sure there is 1 tab and media router is enabled. |
| + ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| + |
| + OpenMediaRouterDialog(); |
| + |
| + // Reload the browser and wait. |
| + content::TestNavigationObserver reload_observer( |
| + browser()->tab_strip_model()->GetActiveWebContents()); |
| + chrome::Reload(browser(), CURRENT_TAB); |
| + reload_observer.Wait(); |
| + |
| + OpenMediaRouterDialog(); |
| + |
| + // Navigate away and wait. |
| + content::TestNavigationObserver nav_observer( |
| + browser()->tab_strip_model()->GetActiveWebContents(), 1); |
| + ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| + |
| + nav_observer.Wait(); |
| + |
| + OpenMediaRouterDialog(); |
| +} |
| + |
| +} // namespace media_router |