summaryrefslogtreecommitdiff
path: root/platform/ios/test/MGLMockGestureRecognizers.m
blob: c818805174156a3d75c136cad65d64734864fd7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

#import "MGLMockGestureRecognizers.h"
#import "objc/runtime.h"

@implementation UIPinchGestureRecognizerMock
@synthesize velocity;
@synthesize state;
- (CGPoint)locationInView:(nullable UIView *)view { return self.locationInViewOverride; }
@end

@implementation UIRotationGestureRecognizerMock
- (CGPoint)locationInView:(nullable UIView*)view { return view.center; }
@synthesize state;
@end

@implementation UITapGestureRecognizerMock

+ (void)load {
    method_exchangeImplementations(class_getInstanceMethod(self, @selector(state)),
                                   class_getInstanceMethod(self, @selector(mockState)));
}

- (UIGestureRecognizerState)mockState {
    return UIGestureRecognizerStateRecognized;
}

- (UIView *)view {
    return self.mockTappedView;
}

- (CGPoint)locationInView:(UIView *)view {
    return self.mockTappedPoint;
}

@end

@implementation UILongPressGestureRecognizerMock
@synthesize state;

- (CGPoint)locationInView:(UIView *)view {
    return self.mockTappedPoint;
}
@end

@implementation UIPanGestureRecognizerMock
@synthesize state;
@synthesize numberOfTouches;

- (CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view {
    if (touchIndex) {
        return self.secondFingerPoint;
    }
    return self.firstFingerPoint;
}
@end