OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/test/cocoa_test_event_utils.h" | 7 #include "ui/base/test/cocoa_test_event_utils.h" |
8 | 8 |
9 ScopedClassSwizzler::ScopedClassSwizzler(Class target, Class source, | 9 ScopedClassSwizzler::ScopedClassSwizzler(Class target, Class source, |
10 SEL selector) { | 10 SEL selector) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 NSUInteger clickCount) { | 76 NSUInteger clickCount) { |
77 const NSRect bounds = [view convertRect:[view bounds] toView:nil]; | 77 const NSRect bounds = [view convertRect:[view bounds] toView:nil]; |
78 const NSPoint mid_point = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); | 78 const NSPoint mid_point = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); |
79 NSEvent* down = MouseEventAtPointInWindow(mid_point, NSLeftMouseDown, | 79 NSEvent* down = MouseEventAtPointInWindow(mid_point, NSLeftMouseDown, |
80 [view window], clickCount); | 80 [view window], clickCount); |
81 NSEvent* up = MouseEventAtPointInWindow(mid_point, NSLeftMouseUp, | 81 NSEvent* up = MouseEventAtPointInWindow(mid_point, NSLeftMouseUp, |
82 [view window], clickCount); | 82 [view window], clickCount); |
83 return std::make_pair(down, up); | 83 return std::make_pair(down, up); |
84 } | 84 } |
85 | 85 |
| 86 NSEvent* KeyEventWithCharacter(unichar c) { |
| 87 NSString* chars = [NSString stringWithCharacters:&c length:1]; |
| 88 return [NSEvent keyEventWithType:NSKeyDown |
| 89 location:NSZeroPoint |
| 90 modifierFlags:0 |
| 91 timestamp:0.0 |
| 92 windowNumber:0 |
| 93 context:nil |
| 94 characters:chars |
| 95 charactersIgnoringModifiers:chars |
| 96 isARepeat:NO |
| 97 keyCode:0]; |
| 98 } |
| 99 |
86 } // namespace cocoa_test_event_utils | 100 } // namespace cocoa_test_event_utils |
OLD | NEW |