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 "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_action_test_util.h" | 10 #include "chrome/browser/extensions/extension_action_test_util.h" |
11 #include "chrome/browser/extensions/extension_browsertest.h" | 11 #include "chrome/browser/extensions/extension_browsertest.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h" |
14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
15 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" | 16 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" |
16 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | 17 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" |
17 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 18 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
18 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 19 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
19 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" | |
20 #include "chrome/browser/ui/global_error/global_error.h" | 20 #include "chrome/browser/ui/global_error/global_error.h" |
21 #include "chrome/browser/ui/global_error/global_error_service.h" | 21 #include "chrome/browser/ui/global_error/global_error_service.h" |
22 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 22 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
23 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 23 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
24 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" | 24 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
25 #include "chrome/test/base/interactive_test_utils.h" | 25 #include "chrome/test/base/interactive_test_utils.h" |
26 #include "extensions/common/feature_switch.h" | 26 #include "extensions/common/feature_switch.h" |
27 #import "ui/events/test/cocoa_test_event_utils.h" | 27 #import "ui/events/test/cocoa_test_event_utils.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 const int kMenuPadding = 26; | 31 const int kMenuPadding = 26; |
32 | 32 |
33 // A simple error class that has a menu item. | 33 // A simple error class that has a menu item. |
34 class MenuError : public GlobalError { | 34 class MenuError : public GlobalError { |
35 public: | 35 public: |
36 MenuError() {} | 36 MenuError() {} |
37 ~MenuError() override {} | 37 ~MenuError() override {} |
38 | 38 |
39 bool HasMenuItem() override { return true; } | 39 bool HasMenuItem() override { return true; } |
40 int MenuItemCommandID() override { | 40 int MenuItemCommandID() override { |
41 // An arbitrary high id so that it's not taken. | 41 // An arbitrary high id so that it's not taken. |
42 return 65536; | 42 return 65536; |
43 } | 43 } |
44 base::string16 MenuItemLabel() override { | 44 base::string16 MenuItemLabel() override { |
45 const char kErrorMessage[] = | 45 const char kErrorMessage[] = |
46 "This is a really long error message that will cause the wrench menu " | 46 "This is a really long error message that will cause the app menu " |
47 "to have increased width"; | 47 "to have increased width"; |
48 return base::ASCIIToUTF16(kErrorMessage); | 48 return base::ASCIIToUTF16(kErrorMessage); |
49 } | 49 } |
50 void ExecuteMenuItem(Browser* browser) override {} | 50 void ExecuteMenuItem(Browser* browser) override {} |
51 | 51 |
52 bool HasBubbleView() override { return false; } | 52 bool HasBubbleView() override { return false; } |
53 bool HasShownBubbleView() override { return false; } | 53 bool HasShownBubbleView() override { return false; } |
54 void ShowBubbleView(Browser* browser) override {} | 54 void ShowBubbleView(Browser* browser) override {} |
55 GlobalErrorBubbleViewBase* GetBubbleView() override { return nullptr; } | 55 GlobalErrorBubbleViewBase* GetBubbleView() override { return nullptr; } |
56 | 56 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ~BrowserActionButtonUiTest() override {} | 129 ~BrowserActionButtonUiTest() override {} |
130 | 130 |
131 void SetUpOnMainThread() override { | 131 void SetUpOnMainThread() override { |
132 ExtensionBrowserTest::SetUpOnMainThread(); | 132 ExtensionBrowserTest::SetUpOnMainThread(); |
133 toolbarController_ = | 133 toolbarController_ = |
134 [[BrowserWindowController | 134 [[BrowserWindowController |
135 browserWindowControllerForWindow:browser()-> | 135 browserWindowControllerForWindow:browser()-> |
136 window()->GetNativeWindow()] | 136 window()->GetNativeWindow()] |
137 toolbarController]; | 137 toolbarController]; |
138 ASSERT_TRUE(toolbarController_); | 138 ASSERT_TRUE(toolbarController_); |
139 wrenchMenuController_ = [toolbarController_ wrenchMenuController]; | 139 appMenuController_ = [toolbarController_ appMenuController]; |
140 model_ = ToolbarActionsModel::Get(profile()); | 140 model_ = ToolbarActionsModel::Get(profile()); |
141 } | 141 } |
142 | 142 |
143 void SetUpCommandLine(base::CommandLine* command_line) override { | 143 void SetUpCommandLine(base::CommandLine* command_line) override { |
144 ExtensionBrowserTest::SetUpCommandLine(command_line); | 144 ExtensionBrowserTest::SetUpCommandLine(command_line); |
145 enable_redesign_.reset(new extensions::FeatureSwitch::ScopedOverride( | 145 enable_redesign_.reset(new extensions::FeatureSwitch::ScopedOverride( |
146 extensions::FeatureSwitch::extension_action_redesign(), true)); | 146 extensions::FeatureSwitch::extension_action_redesign(), true)); |
147 ToolbarActionsBar::disable_animations_for_testing_ = true; | 147 ToolbarActionsBar::disable_animations_for_testing_ = true; |
148 } | 148 } |
149 | 149 |
150 void TearDownOnMainThread() override { | 150 void TearDownOnMainThread() override { |
151 enable_redesign_.reset(); | 151 enable_redesign_.reset(); |
152 ToolbarActionsBar::disable_animations_for_testing_ = false; | 152 ToolbarActionsBar::disable_animations_for_testing_ = false; |
153 ExtensionBrowserTest::TearDownOnMainThread(); | 153 ExtensionBrowserTest::TearDownOnMainThread(); |
154 } | 154 } |
155 | 155 |
156 ToolbarController* toolbarController() { return toolbarController_; } | 156 ToolbarController* toolbarController() { return toolbarController_; } |
157 WrenchMenuController* wrenchMenuController() { return wrenchMenuController_; } | 157 AppMenuController* appMenuController() { return appMenuController_; } |
158 ToolbarActionsModel* model() { return model_; } | 158 ToolbarActionsModel* model() { return model_; } |
159 NSView* wrenchButton() { return [toolbarController_ wrenchButton]; } | 159 NSView* wrenchButton() { return [toolbarController_ wrenchButton]; } |
160 | 160 |
161 private: | 161 private: |
162 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_redesign_; | 162 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_redesign_; |
163 | 163 |
164 ToolbarController* toolbarController_ = nil; | 164 ToolbarController* toolbarController_ = nil; |
165 WrenchMenuController* wrenchMenuController_ = nil; | 165 AppMenuController* appMenuController_ = nil; |
166 ToolbarActionsModel* model_ = nullptr; | 166 ToolbarActionsModel* model_ = nullptr; |
167 | 167 |
168 DISALLOW_COPY_AND_ASSIGN(BrowserActionButtonUiTest); | 168 DISALLOW_COPY_AND_ASSIGN(BrowserActionButtonUiTest); |
169 }; | 169 }; |
170 | 170 |
171 // Simulates a clicks on the action button in the overflow menu, and runs | 171 // Simulates a clicks on the action button in the overflow menu, and runs |
172 // |closure| upon completion. | 172 // |closure| upon completion. |
173 void ClickOnOverflowedAction(ToolbarController* toolbarController, | 173 void ClickOnOverflowedAction(ToolbarController* toolbarController, |
174 const base::Closure& closure) { | 174 const base::Closure& closure) { |
175 WrenchMenuController* wrenchMenuController = | 175 AppMenuController* appMenuController = |
176 [toolbarController wrenchMenuController]; | 176 [toolbarController appMenuController]; |
177 // The wrench menu should start as open (since that's where the overflowed | 177 // The app menu should start as open (since that's where the overflowed |
178 // actions are). | 178 // actions are). |
179 EXPECT_TRUE([wrenchMenuController isMenuOpen]); | 179 EXPECT_TRUE([appMenuController isMenuOpen]); |
180 BrowserActionsController* overflowController = | 180 BrowserActionsController* overflowController = |
181 [wrenchMenuController browserActionsController]; | 181 [appMenuController browserActionsController]; |
182 | 182 |
183 ASSERT_TRUE(overflowController); | 183 ASSERT_TRUE(overflowController); |
184 BrowserActionButton* actionButton = | 184 BrowserActionButton* actionButton = |
185 [overflowController buttonWithIndex:0]; | 185 [overflowController buttonWithIndex:0]; |
186 // The action should be attached to a superview. | 186 // The action should be attached to a superview. |
187 EXPECT_TRUE([actionButton superview]); | 187 EXPECT_TRUE([actionButton superview]); |
188 | 188 |
189 // ui_controls:: methods don't play nice when there is an open menu (like the | 189 // ui_controls:: methods don't play nice when there is an open menu (like the |
190 // wrench menu). Instead, simulate a right click by feeding the event directly | 190 // app menu). Instead, simulate a right click by feeding the event directly to |
191 // to the button. | 191 // the button. |
192 NSPoint centerPoint = GetCenterPoint(actionButton); | 192 NSPoint centerPoint = GetCenterPoint(actionButton); |
193 NSEvent* mouseEvent = cocoa_test_event_utils::RightMouseDownAtPointInWindow( | 193 NSEvent* mouseEvent = cocoa_test_event_utils::RightMouseDownAtPointInWindow( |
194 centerPoint, [actionButton window]); | 194 centerPoint, [actionButton window]); |
195 [actionButton rightMouseDown:mouseEvent]; | 195 [actionButton rightMouseDown:mouseEvent]; |
196 | 196 |
197 // This should close the wrench menu. | 197 // This should close the app menu. |
198 EXPECT_FALSE([wrenchMenuController isMenuOpen]); | 198 EXPECT_FALSE([appMenuController isMenuOpen]); |
199 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 199 base::MessageLoop::current()->PostTask(FROM_HERE, closure); |
200 } | 200 } |
201 | 201 |
202 // Verifies that the action is "popped out" of overflow; that is, it is visible | 202 // Verifies that the action is "popped out" of overflow; that is, it is visible |
203 // on the main bar, and is set as the popped out action on the controlling | 203 // on the main bar, and is set as the popped out action on the controlling |
204 // ToolbarActionsBar. | 204 // ToolbarActionsBar. |
205 void CheckActionIsPoppedOut(BrowserActionsController* actionsController, | 205 void CheckActionIsPoppedOut(BrowserActionsController* actionsController, |
206 BrowserActionButton* actionButton) { | 206 BrowserActionButton* actionButton) { |
207 EXPECT_EQ([actionsController containerView], [actionButton superview]); | 207 EXPECT_EQ([actionsController containerView], [actionButton superview]); |
208 EXPECT_EQ([actionButton viewController], | 208 EXPECT_EQ([actionButton viewController], |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 // Reset the menu helper so we can use it again. | 256 // Reset the menu helper so we can use it again. |
257 [menuHelper setMenuOpened:NO]; | 257 [menuHelper setMenuOpened:NO]; |
258 [menuHelper setVerify:base::Bind( | 258 [menuHelper setVerify:base::Bind( |
259 CheckActionIsPoppedOut, actionsController, actionButton)]; | 259 CheckActionIsPoppedOut, actionsController, actionButton)]; |
260 | 260 |
261 // Shrink the visible count to be 0. This should hide the action button. | 261 // Shrink the visible count to be 0. This should hide the action button. |
262 model()->SetVisibleIconCount(0); | 262 model()->SetVisibleIconCount(0); |
263 EXPECT_EQ(nil, [actionButton superview]); | 263 EXPECT_EQ(nil, [actionButton superview]); |
264 | 264 |
265 // Move the mouse over the wrench button. | 265 // Move the mouse over the app button. |
266 MoveMouseToCenter(wrenchButton()); | 266 MoveMouseToCenter(wrenchButton()); |
267 | 267 |
268 { | 268 { |
269 // No menu yet (on the browser action). | 269 // No menu yet (on the browser action). |
270 EXPECT_FALSE([menuHelper menuOpened]); | 270 EXPECT_FALSE([menuHelper menuOpened]); |
271 base::RunLoop runLoop; | 271 base::RunLoop runLoop; |
272 // Click on the wrench menu, and pass in a callback to continue the test | 272 // Click on the app menu, and pass in a callback to continue the test in |
273 // in ClickOnOverflowedAction (Due to the blocking nature of Cocoa menus, | 273 // ClickOnOverflowedAction (Due to the blocking nature of Cocoa menus, |
274 // passing in runLoop.QuitClosure() is not sufficient here.) | 274 // passing in runLoop.QuitClosure() is not sufficient here.) |
275 ui_controls::SendMouseEventsNotifyWhenDone( | 275 ui_controls::SendMouseEventsNotifyWhenDone( |
276 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 276 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
277 base::Bind(&ClickOnOverflowedAction, | 277 base::Bind(&ClickOnOverflowedAction, |
278 base::Unretained(toolbarController()), | 278 base::Unretained(toolbarController()), |
279 runLoop.QuitClosure())); | 279 runLoop.QuitClosure())); |
280 runLoop.Run(); | 280 runLoop.Run(); |
281 // The menu should have opened. Note that the menu opened on the main bar's | 281 // The menu should have opened. Note that the menu opened on the main bar's |
282 // action button, not the overflow's. Since Cocoa doesn't support running | 282 // action button, not the overflow's. Since Cocoa doesn't support running |
283 // a menu-within-a-menu, this is what has to happen. | 283 // a menu-within-a-menu, this is what has to happen. |
284 EXPECT_TRUE([menuHelper menuOpened]); | 284 EXPECT_TRUE([menuHelper menuOpened]); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 // Checks the layout of the overflow bar in the wrench menu. | 288 // Checks the layout of the overflow bar in the app menu. |
289 void CheckWrenchMenuLayout(ToolbarController* toolbarController, | 289 void CheckWrenchMenuLayout(ToolbarController* toolbarController, |
290 int overflowStartIndex, | 290 int overflowStartIndex, |
291 const std::string& error_message, | 291 const std::string& error_message, |
292 const base::Closure& closure) { | 292 const base::Closure& closure) { |
293 WrenchMenuController* wrenchMenuController = | 293 AppMenuController* appMenuController = |
294 [toolbarController wrenchMenuController]; | 294 [toolbarController appMenuController]; |
295 // The wrench menu should start as open (since that's where the overflowed | 295 // The app menu should start as open (since that's where the overflowed |
296 // actions are). | 296 // actions are). |
297 EXPECT_TRUE([wrenchMenuController isMenuOpen]) << error_message; | 297 EXPECT_TRUE([appMenuController isMenuOpen]) << error_message; |
298 BrowserActionsController* overflowController = | 298 BrowserActionsController* overflowController = |
299 [wrenchMenuController browserActionsController]; | 299 [appMenuController browserActionsController]; |
300 ASSERT_TRUE(overflowController) << error_message; | 300 ASSERT_TRUE(overflowController) << error_message; |
301 | 301 |
302 ToolbarActionsBar* overflowBar = [overflowController toolbarActionsBar]; | 302 ToolbarActionsBar* overflowBar = [overflowController toolbarActionsBar]; |
303 BrowserActionsContainerView* overflowContainer = | 303 BrowserActionsContainerView* overflowContainer = |
304 [overflowController containerView]; | 304 [overflowController containerView]; |
305 NSMenu* menu = [wrenchMenuController menu]; | 305 NSMenu* menu = [appMenuController menu]; |
306 | 306 |
307 // The overflow container should be within the bounds of the wrench menu, as | 307 // The overflow container should be within the bounds of the app menu, as |
308 // should its parents. | 308 // should its parents. |
309 int menu_width = [menu size].width; | 309 int menu_width = [menu size].width; |
310 NSRect frame = [overflowContainer frame]; | 310 NSRect frame = [overflowContainer frame]; |
311 // The container itself should be indented in the menu. | 311 // The container itself should be indented in the menu. |
312 EXPECT_GT(NSMinX(frame), 0) << error_message; | 312 EXPECT_GT(NSMinX(frame), 0) << error_message; |
313 // Hierarchy: The overflow container is owned by two different views in the | 313 // Hierarchy: The overflow container is owned by two different views in the |
314 // wrench menu. Each superview should start at 0 in the x-axis.. | 314 // app menu. Each superview should start at 0 in the x-axis. |
315 EXPECT_EQ(0, NSMinX([[overflowContainer superview] frame])) << error_message; | 315 EXPECT_EQ(0, NSMinX([[overflowContainer superview] frame])) << error_message; |
316 EXPECT_EQ(0, NSMinX([[[overflowContainer superview] superview] frame])) << | 316 EXPECT_EQ(0, NSMinX([[[overflowContainer superview] superview] frame])) << |
317 error_message; | 317 error_message; |
318 // The overflow container should fully fit in the wrench menu, including the | 318 // The overflow container should fully fit in the app menu, including the |
319 // space taken away for padding, and should have its desired size. | 319 // space taken away for padding, and should have its desired size. |
320 EXPECT_LE(NSWidth(frame), menu_width - kMenuPadding) << error_message; | 320 EXPECT_LE(NSWidth(frame), menu_width - kMenuPadding) << error_message; |
321 EXPECT_EQ(NSWidth(frame), overflowBar->GetPreferredSize().width()) << | 321 EXPECT_EQ(NSWidth(frame), overflowBar->GetPreferredSize().width()) << |
322 error_message; | 322 error_message; |
323 | 323 |
324 // Every button that has an index lower than the overflow start index (i.e., | 324 // Every button that has an index lower than the overflow start index (i.e., |
325 // every button on the main toolbar) should not be attached to a view. | 325 // every button on the main toolbar) should not be attached to a view. |
326 for (int i = 0; i < overflowStartIndex; ++i) { | 326 for (int i = 0; i < overflowStartIndex; ++i) { |
327 BrowserActionButton* button = [overflowController buttonWithIndex:i]; | 327 BrowserActionButton* button = [overflowController buttonWithIndex:i]; |
328 EXPECT_FALSE([button superview]) << error_message; | 328 EXPECT_FALSE([button superview]) << error_message; |
(...skipping 12 matching lines...) Expand all Loading... |
341 EXPECT_TRUE([button superview]) << error_message; | 341 EXPECT_TRUE([button superview]) << error_message; |
342 EXPECT_TRUE(NSContainsRect([overflowContainer bounds], [button frame])) << | 342 EXPECT_TRUE(NSContainsRect([overflowContainer bounds], [button frame])) << |
343 error_message; | 343 error_message; |
344 for (NSUInteger j = 0; j < i; ++j) { | 344 for (NSUInteger j = 0; j < i; ++j) { |
345 EXPECT_FALSE( | 345 EXPECT_FALSE( |
346 NSContainsRect([[overflowController buttonWithIndex:j] frame], | 346 NSContainsRect([[overflowController buttonWithIndex:j] frame], |
347 [button frame])) << error_message; | 347 [button frame])) << error_message; |
348 } | 348 } |
349 } | 349 } |
350 | 350 |
351 // Close the wrench menu. | 351 // Close the app menu. |
352 [wrenchMenuController cancel]; | 352 [appMenuController cancel]; |
353 EXPECT_FALSE([wrenchMenuController isMenuOpen]) << error_message; | 353 EXPECT_FALSE([appMenuController isMenuOpen]) << error_message; |
354 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 354 base::MessageLoop::current()->PostTask(FROM_HERE, closure); |
355 } | 355 } |
356 | 356 |
357 // Tests the layout of the overflow container in the wrench menu. | 357 // Tests the layout of the overflow container in the app menu. |
358 IN_PROC_BROWSER_TEST_F(BrowserActionButtonUiTest, TestOverflowContainerLayout) { | 358 IN_PROC_BROWSER_TEST_F(BrowserActionButtonUiTest, TestOverflowContainerLayout) { |
359 // Add a bunch of extensions - enough to trigger multiple rows in the overflow | 359 // Add a bunch of extensions - enough to trigger multiple rows in the overflow |
360 // menu. | 360 // menu. |
361 const int kNumExtensions = 12; | 361 const int kNumExtensions = 12; |
362 for (int i = 0; i < kNumExtensions; ++i) { | 362 for (int i = 0; i < kNumExtensions; ++i) { |
363 scoped_refptr<const extensions::Extension> extension = | 363 scoped_refptr<const extensions::Extension> extension = |
364 extensions::extension_action_test_util::CreateActionExtension( | 364 extensions::extension_action_test_util::CreateActionExtension( |
365 base::StringPrintf("extension%d", i), | 365 base::StringPrintf("extension%d", i), |
366 extensions::extension_action_test_util::BROWSER_ACTION); | 366 extensions::extension_action_test_util::BROWSER_ACTION); |
367 extension_service()->AddExtension(extension.get()); | 367 extension_service()->AddExtension(extension.get()); |
368 } | 368 } |
369 ASSERT_EQ(kNumExtensions, static_cast<int>(model()->toolbar_items().size())); | 369 ASSERT_EQ(kNumExtensions, static_cast<int>(model()->toolbar_items().size())); |
370 | 370 |
371 // A helper function to open the wrench menu and call the check function. | 371 // A helper function to open the app menu and call the check function. |
372 auto resizeAndActivateWrench = [this](int visible_count, | 372 auto resizeAndActivateWrench = [this](int visible_count, |
373 const std::string& error_message) { | 373 const std::string& error_message) { |
374 model()->SetVisibleIconCount(kNumExtensions - visible_count); | 374 model()->SetVisibleIconCount(kNumExtensions - visible_count); |
375 MoveMouseToCenter(wrenchButton()); | 375 MoveMouseToCenter(wrenchButton()); |
376 | 376 |
377 { | 377 { |
378 base::RunLoop runLoop; | 378 base::RunLoop runLoop; |
379 // Click on the wrench menu, and pass in a callback to continue the test | 379 // Click on the app menu, and pass in a callback to continue the test in |
380 // in CheckWrenchMenuLayout (due to the blocking nature of Cocoa menus, | 380 // CheckWrenchMenuLayout (due to the blocking nature of Cocoa menus, |
381 // passing in runLoop.QuitClosure() is not sufficient here.) | 381 // passing in runLoop.QuitClosure() is not sufficient here.) |
382 ui_controls::SendMouseEventsNotifyWhenDone( | 382 ui_controls::SendMouseEventsNotifyWhenDone( |
383 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 383 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
384 base::Bind(&CheckWrenchMenuLayout, | 384 base::Bind(&CheckWrenchMenuLayout, |
385 base::Unretained(toolbarController()), | 385 base::Unretained(toolbarController()), |
386 kNumExtensions - visible_count, | 386 kNumExtensions - visible_count, |
387 error_message, | 387 error_message, |
388 runLoop.QuitClosure())); | 388 runLoop.QuitClosure())); |
389 runLoop.Run(); | 389 runLoop.Run(); |
390 } | 390 } |
391 }; | 391 }; |
392 | 392 |
393 // Test the layout with gradually more extensions hidden. | 393 // Test the layout with gradually more extensions hidden. |
394 for (int i = 1; i <= kNumExtensions; ++i) | 394 for (int i = 1; i <= kNumExtensions; ++i) |
395 resizeAndActivateWrench(i, base::StringPrintf("Normal: %d", i)); | 395 resizeAndActivateWrench(i, base::StringPrintf("Normal: %d", i)); |
396 | 396 |
397 // Adding a global error adjusts the wrench menu size, and has been known | 397 // Adding a global error adjusts the app menu size, and has been known to mess |
398 // to mess up the overflow container's bounds (crbug.com/511326). | 398 // up the overflow container's bounds (crbug.com/511326). |
399 GlobalErrorService* error_service = | 399 GlobalErrorService* error_service = |
400 GlobalErrorServiceFactory::GetForProfile(profile()); | 400 GlobalErrorServiceFactory::GetForProfile(profile()); |
401 error_service->AddGlobalError(new MenuError()); | 401 error_service->AddGlobalError(new MenuError()); |
402 | 402 |
403 // It's probably excessive to test every level of the overflow here. Test | 403 // It's probably excessive to test every level of the overflow here. Test |
404 // having all actions overflowed, some actions overflowed, and one action | 404 // having all actions overflowed, some actions overflowed, and one action |
405 // overflowed. | 405 // overflowed. |
406 resizeAndActivateWrench(kNumExtensions, "GlobalError Full"); | 406 resizeAndActivateWrench(kNumExtensions, "GlobalError Full"); |
407 resizeAndActivateWrench(kNumExtensions / 2, "GlobalError Half"); | 407 resizeAndActivateWrench(kNumExtensions / 2, "GlobalError Half"); |
408 resizeAndActivateWrench(1, "GlobalError One"); | 408 resizeAndActivateWrench(1, "GlobalError One"); |
409 } | 409 } |
OLD | NEW |