Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc

Issue 2721953002: [Media Router] Add "Hide in menu/Show in toolbar" option to Cast toolbar icon (Closed)
Patch Set: Address Jennifer's and Mike's comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/toolbar/media_router_contextual_menu_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/extensions/browser_action_test_util.h" 8 #include "chrome/browser/extensions/browser_action_test_util.h"
9 #include "chrome/browser/media/router/media_router_ui_service.h" 9 #include "chrome/browser/media/router/media_router_ui_service.h"
10 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" 10 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 nav_observer.last_navigation_url().spec()); 82 nav_observer.last_navigation_url().spec());
83 nav_observer.StopWatchingNewWebContents(); 83 nav_observer.StopWatchingNewWebContents();
84 } 84 }
85 85
86 MediaRouterAction* GetMediaRouterAction() { 86 MediaRouterAction* GetMediaRouterAction() {
87 return MediaRouterDialogControllerImpl::GetOrCreateForWebContents( 87 return MediaRouterDialogControllerImpl::GetOrCreateForWebContents(
88 browser()->tab_strip_model()->GetActiveWebContents()) 88 browser()->tab_strip_model()->GetActiveWebContents())
89 ->action(); 89 ->action();
90 } 90 }
91 91
92 ui::SimpleMenuModel* GetActionContextMenu() {
93 return static_cast<ui::SimpleMenuModel*>(
94 GetMediaRouterAction()->GetContextMenu());
95 }
96
92 void ExecuteMediaRouterAction(AppMenuButton* app_menu_button) { 97 void ExecuteMediaRouterAction(AppMenuButton* app_menu_button) {
93 EXPECT_TRUE(app_menu_button->IsMenuShowing()); 98 EXPECT_TRUE(app_menu_button->IsMenuShowing());
94 GetMediaRouterAction()->ExecuteAction(true); 99 GetMediaRouterAction()->ExecuteAction(true);
95 } 100 }
96 101
97 bool ActionExists() { 102 bool ActionExists() {
98 return ToolbarActionsModel::Get(browser()->profile()) 103 return ToolbarActionsModel::Get(browser()->profile())
99 ->HasComponentAction( 104 ->HasComponentAction(
100 ComponentToolbarActionsFactory::kMediaRouterActionId); 105 ComponentToolbarActionsFactory::kMediaRouterActionId);
101 } 106 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_TRUE(ActionExists()); 322 EXPECT_TRUE(ActionExists());
318 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), 323 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(),
319 std::vector<MediaRoute::Id>()); 324 std::vector<MediaRoute::Id>());
320 EXPECT_FALSE(ActionExists()); 325 EXPECT_FALSE(ActionExists());
321 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); 326 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>());
322 EXPECT_TRUE(ActionExists()); 327 EXPECT_TRUE(ActionExists());
323 browser2->window()->Close(); 328 browser2->window()->Close();
324 EXPECT_TRUE(ActionExists()); 329 EXPECT_TRUE(ActionExists());
325 } 330 }
326 331
332 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, UpdateActionLocation) {
333 SetAlwaysShowActionPref(true);
334
335 // Get the index for "Hide in Chrome menu" / "Show in toolbar" menu item.
336 const int command_index = GetActionContextMenu()->GetIndexOfCommandId(
337 IDC_MEDIA_ROUTER_SHOW_IN_TOOLBAR);
338
339 // Start out with the action visible on the main bar.
340 EXPECT_TRUE(
341 toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction()));
342 GetActionContextMenu()->ActivatedAt(command_index);
343
344 // The action should get hidden in the overflow menu.
345 EXPECT_FALSE(
346 toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction()));
347 GetActionContextMenu()->ActivatedAt(command_index);
348
349 // The action should be back on the main bar.
350 EXPECT_TRUE(
351 toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction()));
352 }
353
327 } // namespace media_router 354 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/media_router_contextual_menu_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698