Add coordinate space to event streams and streamline tests
[WebKit-https.git] / Tools / WebKitTestRunner / ios / HIDEventGenerator.h
1 /*
2  * Copyright (C) 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #import "UIKitSPI.h"
27
28 #import <CoreGraphics/CGGeometry.h>
29
30 // Keys for sendEventStream:completionBlock:.
31 extern NSString* const TopLevelEventInfoKey;
32 extern NSString* const HIDEventInputType;
33 extern NSString* const HIDEventTimeOffsetKey;
34 extern NSString* const HIDEventTouchesKey;
35 extern NSString* const HIDEventPhaseKey;
36 extern NSString* const HIDEventInterpolateKey;
37 extern NSString* const HIDEventTimestepKey;
38 extern NSString* const HIDEventCoordinateSpaceKey;
39 extern NSString* const HIDEventStartEventKey;
40 extern NSString* const HIDEventEndEventKey;
41 extern NSString* const HIDEventTouchIDKey;
42 extern NSString* const HIDEventPressureKey;
43 extern NSString* const HIDEventXKey;
44 extern NSString* const HIDEventYKey;
45 extern NSString* const HIDEventTwistKey;
46 extern NSString* const HIDEventMajorRadiusKey;
47 extern NSString* const HIDEventMinorRadiusKey;
48
49 // Values for HIDEventInputType.
50 extern NSString* const HIDEventInputTypeHand;
51 extern NSString* const HIDEventInputTypeFinger;
52 extern NSString* const HIDEventInputTypeStylus;
53
54 // Values for HIDEventCoordinateSpaceKey.
55 extern NSString* const HIDEventCoordinateSpaceTypeGlobal;
56 extern NSString* const HIDEventCoordinateSpaceTypeContent;
57
58 extern NSString* const HIDEventInterpolationTypeLinear;
59 extern NSString* const HIDEventInterpolationTypeSimpleCurve;
60
61 // Values for HIDEventPhaseKey.
62 extern NSString* const HIDEventPhaseBegan;
63 extern NSString* const HIDEventPhaseMoved;
64 extern NSString* const HIDEventPhaseEnded;
65 extern NSString* const HIDEventPhaseCanceled;
66
67
68 @interface HIDEventGenerator : NSObject
69
70 + (HIDEventGenerator *)sharedHIDEventGenerator;
71
72 // Touches
73 - (void)touchDown:(CGPoint)location touchCount:(NSUInteger)count completionBlock:(void (^)(void))completionBlock;
74 - (void)liftUp:(CGPoint)location touchCount:(NSUInteger)count completionBlock:(void (^)(void))completionBlock;
75
76 // Stylus
77 - (void)stylusDownAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock;
78 - (void)stylusMoveToPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock;
79 - (void)stylusUpAtPoint:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
80 - (void)stylusTapAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock;
81
82 // Taps
83 - (void)tap:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
84 - (void)doubleTap:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
85 - (void)twoFingerTap:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
86
87 // Long Press
88 - (void)longPress:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
89
90 // Drags
91 - (void)dragWithStartPoint:(CGPoint)startLocation endPoint:(CGPoint)endLocation duration:(double)seconds completionBlock:(void (^)(void))completionBlock;
92
93 // Pinches
94 - (void)pinchCloseWithStartPoint:(CGPoint)startLocation endPoint:(CGPoint)endLocation duration:(double)seconds completionBlock:(void (^)(void))completionBlock;
95 - (void)pinchOpenWithStartPoint:(CGPoint)startLocation endPoint:(CGPoint)endLocation duration:(double)seconds completionBlock:(void (^)(void))completionBlock;
96
97 // Event stream
98 - (void)sendEventStream:(NSDictionary *)eventInfo completionBlock:(void (^)(void))completionBlock;
99
100 - (void)markerEventReceived:(IOHIDEventRef)event;
101
102 // Keyboard
103 - (void)keyPress:(NSString *)character completionBlock:(void (^)(void))completionBlock;
104 - (void)keyDown:(NSString *)character completionBlock:(void (^)(void))completionBlock;
105 - (void)keyUp:(NSString *)character completionBlock:(void (^)(void))completionBlock;
106
107 @end