15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <utility>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#import <objc/objc-class.h>
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace cocoa_test_event_utils {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Create synthetic mouse events for testing. Currently these are very
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// basic, flesh out as needed.  Points are all in window coordinates;
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// where the window is not specified, coordinate system is undefined
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// (but will be repeated when the event is queried).
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* MouseEventWithType(NSEventType type, NSUInteger modifiers);
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* MouseEventAtPoint(NSPoint point, NSEventType type,
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           NSUInteger modifiers);
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* LeftMouseDownAtPoint(NSPoint point);
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* LeftMouseDownAtPointInWindow(NSPoint point, NSWindow* window);
25f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)NSEvent* RightMouseDownAtPoint(NSPoint point);
26f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)NSEvent* RightMouseDownAtPointInWindow(NSPoint point, NSWindow* window);
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Return a mouse down and an up event with the given |clickCount| at
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |view|'s midpoint.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::pair<NSEvent*, NSEvent*> MouseClickInView(NSView* view,
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                               NSUInteger clickCount);
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns a key event with the given character.
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* KeyEventWithCharacter(unichar c);
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns a key event with the given type and modifier flags.
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* KeyEventWithType(NSEventType event_type, NSUInteger modifiers);
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns a key event with the given key code, type, and modifier flags.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* KeyEventWithKeyCode(unsigned short key_code,
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             unichar c,
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             NSEventType event_type,
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             NSUInteger modifiers);
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns a mouse enter/exit event with the given type.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* EnterExitEventWithType(NSEventType event_type);
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Return an "other" event with the given type.
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSEvent* OtherEventWithType(NSEventType event_type);
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace cocoa_test_event_utils
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // UI_EVENTS_TEST_COCOA_TEST_EVENT_UTILS_H_
54