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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/extensions/extension_action_test_util.h" | 8 #include "chrome/browser/extensions/extension_action_test_util.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_toolbar_model.h" | |
12 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
14 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" | 13 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" |
15 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | 14 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" |
16 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 15 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
17 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 16 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
18 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" | 17 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" |
19 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 18 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 19 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
20 #include "chrome/test/base/interactive_test_utils.h" | 20 #include "chrome/test/base/interactive_test_utils.h" |
21 #include "extensions/common/feature_switch.h" | 21 #include "extensions/common/feature_switch.h" |
22 #import "ui/events/test/cocoa_test_event_utils.h" | 22 #import "ui/events/test/cocoa_test_event_utils.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // Returns the center point for a particular |view|. | 26 // Returns the center point for a particular |view|. |
27 NSPoint GetCenterPoint(NSView* view) { | 27 NSPoint GetCenterPoint(NSView* view) { |
28 NSWindow* window = [view window]; | 28 NSWindow* window = [view window]; |
29 NSScreen* screen = [window screen]; | 29 NSScreen* screen = [window screen]; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Test that opening a context menu works for both actions on the main bar and | 154 // Test that opening a context menu works for both actions on the main bar and |
155 // actions in the overflow menu. | 155 // actions in the overflow menu. |
156 IN_PROC_BROWSER_TEST_F(BrowserActionButtonUiTest, | 156 IN_PROC_BROWSER_TEST_F(BrowserActionButtonUiTest, |
157 ContextMenusOnMainAndOverflow) { | 157 ContextMenusOnMainAndOverflow) { |
158 // Add an extension with a browser action. | 158 // Add an extension with a browser action. |
159 scoped_refptr<const extensions::Extension> extension = | 159 scoped_refptr<const extensions::Extension> extension = |
160 extensions::extension_action_test_util::CreateActionExtension( | 160 extensions::extension_action_test_util::CreateActionExtension( |
161 "browser_action", | 161 "browser_action", |
162 extensions::extension_action_test_util::BROWSER_ACTION); | 162 extensions::extension_action_test_util::BROWSER_ACTION); |
163 extension_service()->AddExtension(extension.get()); | 163 extension_service()->AddExtension(extension.get()); |
164 extensions::ExtensionToolbarModel* model = | 164 ToolbarActionsModel* model = ToolbarActionsModel::Get(profile()); |
165 extensions::ExtensionToolbarModel::Get(profile()); | |
166 ASSERT_EQ(1u, model->toolbar_items().size()); | 165 ASSERT_EQ(1u, model->toolbar_items().size()); |
167 | 166 |
168 ToolbarController* toolbarController = | 167 ToolbarController* toolbarController = |
169 [[BrowserWindowController | 168 [[BrowserWindowController |
170 browserWindowControllerForWindow:browser()-> | 169 browserWindowControllerForWindow:browser()-> |
171 window()->GetNativeWindow()] | 170 window()->GetNativeWindow()] |
172 toolbarController]; | 171 toolbarController]; |
173 ASSERT_TRUE(toolbarController); | 172 ASSERT_TRUE(toolbarController); |
174 | 173 |
175 BrowserActionsController* actionsController = | 174 BrowserActionsController* actionsController = |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 base::Bind(&ClickOnOverflowedAction, | 229 base::Bind(&ClickOnOverflowedAction, |
231 base::Unretained(toolbarController), | 230 base::Unretained(toolbarController), |
232 runLoop.QuitClosure())); | 231 runLoop.QuitClosure())); |
233 runLoop.Run(); | 232 runLoop.Run(); |
234 // The menu should have opened. Note that the menu opened on the main bar's | 233 // The menu should have opened. Note that the menu opened on the main bar's |
235 // action button, not the overflow's. Since Cocoa doesn't support running | 234 // action button, not the overflow's. Since Cocoa doesn't support running |
236 // a menu-within-a-menu, this is what has to happen. | 235 // a menu-within-a-menu, this is what has to happen. |
237 EXPECT_TRUE([menuHelper menuOpened]); | 236 EXPECT_TRUE([menuHelper menuOpened]); |
238 } | 237 } |
239 } | 238 } |
OLD | NEW |