Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / events / test / cocoa_test_event_utils.h
blobea29e4b56f5de1981ea786c9e90321ddcbc4d0a1
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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
6 #define UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
8 #include <utility>
10 #import <objc/objc-class.h>
12 #include "base/basictypes.h"
13 #include "ui/events/keycodes/keyboard_codes.h"
15 namespace cocoa_test_event_utils {
17 // Create synthetic mouse events for testing. Currently these are very
18 // basic, flesh out as needed. Points are all in window coordinates;
19 // where the window is not specified, coordinate system is undefined
20 // (but will be repeated when the event is queried).
21 NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type,
22 NSUInteger modifiers);
23 NSEvent* MouseEventWithType(NSEventType type, NSUInteger modifiers);
24 NSEvent* MouseEventAtPointInWindow(NSPoint point,
25 NSEventType type,
26 NSWindow* window,
27 NSUInteger clickCount);
28 NSEvent* RightMouseDownAtPoint(NSPoint point);
29 NSEvent* RightMouseDownAtPointInWindow(NSPoint point, NSWindow* window);
30 NSEvent* LeftMouseDownAtPoint(NSPoint point);
31 NSEvent* LeftMouseDownAtPointInWindow(NSPoint point, NSWindow* window);
33 // Return a mouse down and an up event with the given |clickCount| at
34 // |view|'s midpoint.
35 std::pair<NSEvent*, NSEvent*> MouseClickInView(NSView* view,
36 NSUInteger clickCount);
38 // Return a right mouse down and an up event with the given |clickCount| at
39 // |view|'s midpoint.
40 std::pair<NSEvent*, NSEvent*> RightMouseClickInView(NSView* view,
41 NSUInteger clickCount);
43 // Returns a key event with the given character.
44 NSEvent* KeyEventWithCharacter(unichar c);
46 // Returns a key event with the given type and modifier flags.
47 NSEvent* KeyEventWithType(NSEventType event_type, NSUInteger modifiers);
49 // Returns a key event with the given key code, type, and modifier flags.
50 NSEvent* KeyEventWithKeyCode(unsigned short key_code,
51 unichar c,
52 NSEventType event_type,
53 NSUInteger modifiers);
55 // Returns a mouse enter/exit event with the given type.
56 NSEvent* EnterExitEventWithType(NSEventType event_type);
58 // Return an "other" event with the given type.
59 NSEvent* OtherEventWithType(NSEventType event_type);
61 // Time interval since system startup. Tests shouldn't rely on this.
62 NSTimeInterval TimeIntervalSinceSystemStartup();
64 // Creates a key event in a particular window.
65 NSEvent* SynthesizeKeyEvent(NSWindow* window,
66 bool keyDown,
67 ui::KeyboardCode keycode,
68 NSUInteger flags);
70 } // namespace cocoa_test_event_utils
72 #endif // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_