e7a9e98fc3af66286226d3a595c03d903461ad50
[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 // Values for touch counts, etc, to keep debug code in sync
68
69 extern NSUInteger const HIDMaxTouchCount;
70
71 @interface HIDEventGenerator : NSObject
72
73 + (HIDEventGenerator *)sharedHIDEventGenerator;
74
75 // Touches
76 - (void)touchDown:(CGPoint)location touchCount:(NSUInteger)count completionBlock:(void (^)(void))completionBlock;
77 - (void)liftUp:(CGPoint)location touchCount:(NSUInteger)count completionBlock:(void (^)(void))completionBlock;
78
79 // Stylus
80 - (void)stylusDownAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock;
81 - (void)stylusMoveToPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock;
82 - (void)stylusUpAtPoint:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
83 - (void)stylusTapAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock;
84
85 // Taps
86 - (void)tap:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
87 - (void)doubleTap:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
88 - (void)twoFingerTap:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
89
90 // Long Press
91 - (void)longPress:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
92
93 // Drags
94 - (void)dragWithStartPoint:(CGPoint)startLocation endPoint:(CGPoint)endLocation duration:(double)seconds completionBlock:(void (^)(void))completionBlock;
95
96 // Pinches
97 - (void)pinchCloseWithStartPoint:(CGPoint)startLocation endPoint:(CGPoint)endLocation duration:(double)seconds completionBlock:(void (^)(void))completionBlock;
98 - (void)pinchOpenWithStartPoint:(CGPoint)startLocation endPoint:(CGPoint)endLocation duration:(double)seconds completionBlock:(void (^)(void))completionBlock;
99
100 // Event stream
101 - (void)sendEventStream:(NSDictionary *)eventInfo completionBlock:(void (^)(void))completionBlock;
102
103 - (void)markerEventReceived:(IOHIDEventRef)event;
104 - (BOOL)checkForOutstandingCallbacks;
105
106 // Keyboard
107 - (void)keyPress:(NSString *)character completionBlock:(void (^)(void))completionBlock;
108 - (void)keyDown:(NSString *)character completionBlock:(void (^)(void))completionBlock;
109 - (void)keyUp:(NSString *)character completionBlock:(void (^)(void))completionBlock;
110
111 @end