OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ | 5 #ifndef UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ |
6 #define UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ | 6 #define UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #import <objc/objc-class.h> | 9 #import <objc/objc-class.h> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Return a mouse down and an up event with the given |clickCount| at | 43 // Return a mouse down and an up event with the given |clickCount| at |
44 // |view|'s midpoint. | 44 // |view|'s midpoint. |
45 std::pair<NSEvent*, NSEvent*> MouseClickInView(NSView* view, | 45 std::pair<NSEvent*, NSEvent*> MouseClickInView(NSView* view, |
46 NSUInteger clickCount); | 46 NSUInteger clickCount); |
47 | 47 |
48 // Return a right mouse down and an up event with the given |clickCount| at | 48 // Return a right mouse down and an up event with the given |clickCount| at |
49 // |view|'s midpoint. | 49 // |view|'s midpoint. |
50 std::pair<NSEvent*, NSEvent*> RightMouseClickInView(NSView* view, | 50 std::pair<NSEvent*, NSEvent*> RightMouseClickInView(NSView* view, |
51 NSUInteger clickCount); | 51 NSUInteger clickCount); |
52 | 52 |
53 // Creates a test scroll event. Currently only events for a "real" mouse wheel | 53 // Creates a test scroll event. |has_precise_deltas| determines the value of |
54 // are supported (-hasPreciseScrollingDeltas is NO). If |window| is nil, | 54 // -[NSEvent hasPreciseScrollingDeltas] - usually NO for a mouse wheel and YES |
55 // |location| is assumed to be AppKit screen coordinates (origin in bottom left | 55 // for a trackpad. If |window| is nil, |location| is assumed to be AppKit screen |
56 // of primary screen). | 56 // coordinates (origin in bottom left of primary screen). |
57 // TODO(tapted): Add event phase arguments to support trackpad scrolls also. | |
58 NSEvent* TestScrollEvent(NSPoint location, | 57 NSEvent* TestScrollEvent(NSPoint location, |
59 NSWindow* window, | 58 NSWindow* window, |
60 CGFloat delta_x, | 59 CGFloat delta_x, |
61 CGFloat delta_y); | 60 CGFloat delta_y, |
| 61 bool has_precise_deltas, |
| 62 NSEventPhase event_phase, |
| 63 NSEventPhase momentum_phase); |
62 | 64 |
63 // Returns a key event with the given character. | 65 // Returns a key event with the given character. |
64 NSEvent* KeyEventWithCharacter(unichar c); | 66 NSEvent* KeyEventWithCharacter(unichar c); |
65 | 67 |
66 // Returns a key event with the given type and modifier flags. | 68 // Returns a key event with the given type and modifier flags. |
67 NSEvent* KeyEventWithType(NSEventType event_type, NSUInteger modifiers); | 69 NSEvent* KeyEventWithType(NSEventType event_type, NSUInteger modifiers); |
68 | 70 |
69 // Returns a key event with the given key code, type, and modifier flags. | 71 // Returns a key event with the given key code, type, and modifier flags. |
70 NSEvent* KeyEventWithKeyCode(unsigned short key_code, | 72 NSEvent* KeyEventWithKeyCode(unsigned short key_code, |
71 unichar c, | 73 unichar c, |
(...skipping 15 matching lines...) Expand all Loading... |
87 // Creates a key event in a particular window. | 89 // Creates a key event in a particular window. |
88 NSEvent* SynthesizeKeyEvent(NSWindow* window, | 90 NSEvent* SynthesizeKeyEvent(NSWindow* window, |
89 bool keyDown, | 91 bool keyDown, |
90 ui::KeyboardCode keycode, | 92 ui::KeyboardCode keycode, |
91 NSUInteger flags, | 93 NSUInteger flags, |
92 ui::DomKey dom_key = ui::DomKey::NONE); | 94 ui::DomKey dom_key = ui::DomKey::NONE); |
93 | 95 |
94 } // namespace cocoa_test_event_utils | 96 } // namespace cocoa_test_event_utils |
95 | 97 |
96 #endif // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ | 98 #endif // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ |
OLD | NEW |