diff options
Diffstat (limited to 'ui/events/test/cocoa_test_event_utils.mm')
-rw-r--r-- | ui/events/test/cocoa_test_event_utils.mm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ui/events/test/cocoa_test_event_utils.mm b/ui/events/test/cocoa_test_event_utils.mm index b27cd12..bbc7ac3 100644 --- a/ui/events/test/cocoa_test_event_utils.mm +++ b/ui/events/test/cocoa_test_event_utils.mm @@ -72,10 +72,10 @@ NSEvent* MouseEventWithType(NSEventType type, NSUInteger modifiers) { return MouseEventAtPoint(NSZeroPoint, type, modifiers); } -static NSEvent* MouseEventAtPointInWindow(NSPoint point, - NSEventType type, - NSWindow* window, - NSUInteger clickCount) { +NSEvent* MouseEventAtPointInWindow(NSPoint point, + NSEventType type, + NSWindow* window, + NSUInteger clickCount) { return [NSEvent mouseEventWithType:type location:point modifierFlags:0 @@ -114,6 +114,17 @@ std::pair<NSEvent*,NSEvent*> MouseClickInView(NSView* view, return std::make_pair(down, up); } +std::pair<NSEvent*, NSEvent*> RightMouseClickInView(NSView* view, + NSUInteger clickCount) { + const NSRect bounds = [view convertRect:[view bounds] toView:nil]; + const NSPoint mid_point = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); + NSEvent* down = MouseEventAtPointInWindow(mid_point, NSRightMouseDown, + [view window], clickCount); + NSEvent* up = MouseEventAtPointInWindow(mid_point, NSRightMouseUp, + [view window], clickCount); + return std::make_pair(down, up); +} + NSEvent* KeyEventWithCharacter(unichar c) { return KeyEventWithKeyCode(0, c, NSKeyDown, 0); } |