Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Side by Side Diff: ui/events/test/cocoa_test_event_utils.h

Issue 2226933004: Mac: Share kScrollbarPixelsPerCocoaTick between ui:: and blink:: events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for r411201 Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/cocoa/events_mac_unittest.mm ('k') | ui/events/test/cocoa_test_event_utils.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <utility> 11 #include <utility>
12 12
13 #include "ui/events/keycodes/dom/dom_key.h" 13 #include "ui/events/keycodes/dom/dom_key.h"
14 #include "ui/events/keycodes/keyboard_codes.h" 14 #include "ui/events/keycodes/keyboard_codes.h"
15 15
16 namespace cocoa_test_event_utils { 16 namespace cocoa_test_event_utils {
17 17
18 // Converts |window_point| in |window| coordinates (origin at bottom left of
19 // window frame) to a point in global display coordinates for a CGEvent (origin
20 // at top left of primary screen).
21 CGPoint ScreenPointFromWindow(NSPoint window_point, NSWindow* window);
22
23 // Converts |event| to an NSEvent with a timestamp from ui::EventTimeForNow(),
24 // and attaches |window| to it.
25 NSEvent* AttachWindowToCGEvent(CGEventRef event, NSWindow* window);
26
18 // Create synthetic mouse events for testing. Currently these are very 27 // Create synthetic mouse events for testing. Currently these are very
19 // basic, flesh out as needed. Points are all in window coordinates; 28 // basic, flesh out as needed. Points are all in window coordinates;
20 // where the window is not specified, coordinate system is undefined 29 // where the window is not specified, coordinate system is undefined
21 // (but will be repeated when the event is queried). 30 // (but will be repeated when the event is queried).
22 NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type, 31 NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type,
23 NSUInteger modifiers); 32 NSUInteger modifiers);
24 NSEvent* MouseEventWithType(NSEventType type, NSUInteger modifiers); 33 NSEvent* MouseEventWithType(NSEventType type, NSUInteger modifiers);
25 NSEvent* MouseEventAtPointInWindow(NSPoint point, 34 NSEvent* MouseEventAtPointInWindow(NSPoint point,
26 NSEventType type, 35 NSEventType type,
27 NSWindow* window, 36 NSWindow* window,
28 NSUInteger clickCount); 37 NSUInteger clickCount);
29 NSEvent* RightMouseDownAtPoint(NSPoint point); 38 NSEvent* RightMouseDownAtPoint(NSPoint point);
30 NSEvent* RightMouseDownAtPointInWindow(NSPoint point, NSWindow* window); 39 NSEvent* RightMouseDownAtPointInWindow(NSPoint point, NSWindow* window);
31 NSEvent* LeftMouseDownAtPoint(NSPoint point); 40 NSEvent* LeftMouseDownAtPoint(NSPoint point);
32 NSEvent* LeftMouseDownAtPointInWindow(NSPoint point, NSWindow* window); 41 NSEvent* LeftMouseDownAtPointInWindow(NSPoint point, NSWindow* window);
33 42
34 // 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
35 // |view|'s midpoint. 44 // |view|'s midpoint.
36 std::pair<NSEvent*, NSEvent*> MouseClickInView(NSView* view, 45 std::pair<NSEvent*, NSEvent*> MouseClickInView(NSView* view,
37 NSUInteger clickCount); 46 NSUInteger clickCount);
38 47
39 // 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
40 // |view|'s midpoint. 49 // |view|'s midpoint.
41 std::pair<NSEvent*, NSEvent*> RightMouseClickInView(NSView* view, 50 std::pair<NSEvent*, NSEvent*> RightMouseClickInView(NSView* view,
42 NSUInteger clickCount); 51 NSUInteger clickCount);
43 52
53 // Creates a test scroll event. Currently only events for a "real" mouse wheel
54 // are supported (-hasPreciseScrollingDeltas is NO). If |window| is nil,
55 // |location| is assumed to be AppKit screen coordinates (origin in bottom left
56 // of primary screen).
57 // TODO(tapted): Add event phase arguments to support trackpad scrolls also.
58 NSEvent* TestScrollEvent(NSPoint location,
59 NSWindow* window,
60 CGFloat delta_x,
61 CGFloat delta_y);
62
44 // Returns a key event with the given character. 63 // Returns a key event with the given character.
45 NSEvent* KeyEventWithCharacter(unichar c); 64 NSEvent* KeyEventWithCharacter(unichar c);
46 65
47 // Returns a key event with the given type and modifier flags. 66 // Returns a key event with the given type and modifier flags.
48 NSEvent* KeyEventWithType(NSEventType event_type, NSUInteger modifiers); 67 NSEvent* KeyEventWithType(NSEventType event_type, NSUInteger modifiers);
49 68
50 // Returns a key event with the given key code, type, and modifier flags. 69 // Returns a key event with the given key code, type, and modifier flags.
51 NSEvent* KeyEventWithKeyCode(unsigned short key_code, 70 NSEvent* KeyEventWithKeyCode(unsigned short key_code,
52 unichar c, 71 unichar c,
53 NSEventType event_type, 72 NSEventType event_type,
(...skipping 14 matching lines...) Expand all
68 // Creates a key event in a particular window. 87 // Creates a key event in a particular window.
69 NSEvent* SynthesizeKeyEvent(NSWindow* window, 88 NSEvent* SynthesizeKeyEvent(NSWindow* window,
70 bool keyDown, 89 bool keyDown,
71 ui::KeyboardCode keycode, 90 ui::KeyboardCode keycode,
72 NSUInteger flags, 91 NSUInteger flags,
73 ui::DomKey dom_key = ui::DomKey::NONE); 92 ui::DomKey dom_key = ui::DomKey::NONE);
74 93
75 } // namespace cocoa_test_event_utils 94 } // namespace cocoa_test_event_utils
76 95
77 #endif // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_ 96 #endif // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
OLDNEW
« no previous file with comments | « ui/events/cocoa/events_mac_unittest.mm ('k') | ui/events/test/cocoa_test_event_utils.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698