| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | 23 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" |
| 24 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 24 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
| 25 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 25 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 26 #include "chrome/browser/ui/global_error/global_error.h" | 26 #include "chrome/browser/ui/global_error/global_error.h" |
| 27 #include "chrome/browser/ui/global_error/global_error_service.h" | 27 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 28 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 28 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 29 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 30 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" | 30 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
| 31 #include "chrome/test/base/interactive_test_utils.h" | 31 #include "chrome/test/base/interactive_test_utils.h" |
| 32 #include "extensions/common/feature_switch.h" | 32 #include "extensions/common/feature_switch.h" |
| 33 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 33 #import "ui/events/test/cocoa_test_event_utils.h" | 34 #import "ui/events/test/cocoa_test_event_utils.h" |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 const int kMenuPadding = 26; | 38 const int kMenuPadding = 26; |
| 38 | 39 |
| 39 // A simple error class that has a menu item. | 40 // A simple error class that has a menu item. |
| 40 class MenuError : public GlobalError { | 41 class MenuError : public GlobalError { |
| 41 public: | 42 public: |
| 42 MenuError() {} | 43 MenuError() {} |
| (...skipping 25 matching lines...) Expand all Loading... |
| 68 NSPoint GetCenterPoint(NSView* view) { | 69 NSPoint GetCenterPoint(NSView* view) { |
| 69 NSWindow* window = [view window]; | 70 NSWindow* window = [view window]; |
| 70 NSScreen* screen = [window screen]; | 71 NSScreen* screen = [window screen]; |
| 71 DCHECK(screen); | 72 DCHECK(screen); |
| 72 | 73 |
| 73 // Converts the center position of the view into the coordinates accepted | 74 // Converts the center position of the view into the coordinates accepted |
| 74 // by ui_controls methods. | 75 // by ui_controls methods. |
| 75 NSRect bounds = [view bounds]; | 76 NSRect bounds = [view bounds]; |
| 76 NSPoint center = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); | 77 NSPoint center = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); |
| 77 center = [view convertPoint:center toView:nil]; | 78 center = [view convertPoint:center toView:nil]; |
| 78 center = [window convertBaseToScreen:center]; | 79 center = ui::ConvertPointFromWindowToScreen(window, center); |
| 79 return NSMakePoint(center.x, [screen frame].size.height - center.y); | 80 return NSMakePoint(center.x, [screen frame].size.height - center.y); |
| 80 } | 81 } |
| 81 | 82 |
| 82 // Moves the mouse (synchronously) to the center of the given |view|. | 83 // Moves the mouse (synchronously) to the center of the given |view|. |
| 83 void MoveMouseToCenter(NSView* view) { | 84 void MoveMouseToCenter(NSView* view) { |
| 84 NSPoint centerPoint = GetCenterPoint(view); | 85 NSPoint centerPoint = GetCenterPoint(view); |
| 85 base::RunLoop runLoop; | 86 base::RunLoop runLoop; |
| 86 ui_controls::SendMouseMoveNotifyWhenDone( | 87 ui_controls::SendMouseMoveNotifyWhenDone( |
| 87 centerPoint.x, centerPoint.y, runLoop.QuitClosure()); | 88 centerPoint.x, centerPoint.y, runLoop.QuitClosure()); |
| 88 runLoop.Run(); | 89 runLoop.Run(); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 base::scoped_nsobject<MenuWatcher> menuWatcher( | 524 base::scoped_nsobject<MenuWatcher> menuWatcher( |
| 524 [[MenuWatcher alloc] initWithController:appMenuController()]); | 525 [[MenuWatcher alloc] initWithController:appMenuController()]); |
| 525 [menuWatcher setOpenClosure: | 526 [menuWatcher setOpenClosure: |
| 526 base::Bind(&AddExtensionWithMenuOpen, | 527 base::Bind(&AddExtensionWithMenuOpen, |
| 527 base::Unretained(toolbarController()), extension_service(), | 528 base::Unretained(toolbarController()), extension_service(), |
| 528 runLoop.QuitClosure())]; | 529 runLoop.QuitClosure())]; |
| 529 ui_controls::SendMouseEvents(ui_controls::LEFT, | 530 ui_controls::SendMouseEvents(ui_controls::LEFT, |
| 530 ui_controls::DOWN | ui_controls::UP); | 531 ui_controls::DOWN | ui_controls::UP); |
| 531 runLoop.Run(); | 532 runLoop.Run(); |
| 532 } | 533 } |
| OLD | NEW |