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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 base::RunLoop runLoop; | 43 base::RunLoop runLoop; |
44 ui_controls::SendMouseMoveNotifyWhenDone( | 44 ui_controls::SendMouseMoveNotifyWhenDone( |
45 centerPoint.x, centerPoint.y, runLoop.QuitClosure()); | 45 centerPoint.x, centerPoint.y, runLoop.QuitClosure()); |
46 runLoop.Run(); | 46 runLoop.Run(); |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 // A simple helper menu delegate that will keep track of if a menu is opened, | 51 // A simple helper menu delegate that will keep track of if a menu is opened, |
52 // and closes them immediately (which is useful because message loops with | 52 // and closes them immediately (which is useful because message loops with |
53 // menus open in cocoa don't play nicely with testing). | 53 // menus open in Cocoa don't play nicely with testing). |
54 @interface MenuHelper : NSObject<NSMenuDelegate> { | 54 @interface MenuHelper : NSObject<NSMenuDelegate> { |
55 // Whether or not a menu has been opened. This can be reset so the helper can | 55 // Whether or not a menu has been opened. This can be reset so the helper can |
56 // be used multiple times. | 56 // be used multiple times. |
57 BOOL menuOpened_; | 57 BOOL menuOpened_; |
58 } | 58 } |
59 | 59 |
60 // Bare-bones init. | 60 // Bare-bones init. |
61 - (id)init; | 61 - (id)init; |
62 | 62 |
63 @property(nonatomic, assign) BOOL menuOpened; | 63 @property(nonatomic, assign) BOOL menuOpened; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // Move the mouse over the wrench button. | 196 // Move the mouse over the wrench button. |
197 NSView* wrenchButton = [toolbarController wrenchButton]; | 197 NSView* wrenchButton = [toolbarController wrenchButton]; |
198 ASSERT_TRUE(wrenchButton); | 198 ASSERT_TRUE(wrenchButton); |
199 MoveMouseToCenter(wrenchButton); | 199 MoveMouseToCenter(wrenchButton); |
200 | 200 |
201 { | 201 { |
202 // No menu yet (on the browser action). | 202 // No menu yet (on the browser action). |
203 EXPECT_FALSE([menuHelper menuOpened]); | 203 EXPECT_FALSE([menuHelper menuOpened]); |
204 base::RunLoop runLoop; | 204 base::RunLoop runLoop; |
205 // Click on the wrench menu, and pass in a callback to continue the test | 205 // Click on the wrench menu, and pass in a callback to continue the test |
206 // in ClickOnOverflowedAction (Due to the blocking nature of cocoa menus, | 206 // in ClickOnOverflowedAction (Due to the blocking nature of Cocoa menus, |
207 // passing in runLoop.QuitClosure() is not sufficient here.) | 207 // passing in runLoop.QuitClosure() is not sufficient here.) |
208 ui_controls::SendMouseEventsNotifyWhenDone( | 208 ui_controls::SendMouseEventsNotifyWhenDone( |
209 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 209 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
210 base::Bind(&ClickOnOverflowedAction, | 210 base::Bind(&ClickOnOverflowedAction, |
211 base::Unretained(toolbarController), | 211 base::Unretained(toolbarController), |
212 runLoop.QuitClosure())); | 212 runLoop.QuitClosure())); |
213 runLoop.Run(); | 213 runLoop.Run(); |
214 // The menu should have opened. Note that the menu opened on the main bar's | 214 // The menu should have opened. Note that the menu opened on the main bar's |
215 // action button, not the overflow's. Since cocoa doesn't support running | 215 // action button, not the overflow's. Since Cocoa doesn't support running |
216 // a menu-within-a-menu, this is what has to happen. | 216 // a menu-within-a-menu, this is what has to happen. |
217 EXPECT_TRUE([menuHelper menuOpened]); | 217 EXPECT_TRUE([menuHelper menuOpened]); |
218 } | 218 } |
219 } | 219 } |
OLD | NEW |