|
12 | 12 | #import "FBLogger.h"
|
13 | 13 | #import "XCUIElement.h"
|
14 | 14 |
|
15 |
| -@implementation XCUIElement (FBSwiping) |
16 |
| - |
17 |
| -- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity |
18 |
| -{ |
| 15 | +void swipeWithDirection(NSObject *target, NSString *direction, NSNumber* _Nullable velocity) { |
19 | 16 | double velocityValue = .0;
|
20 | 17 | if (nil != velocity) {
|
21 | 18 | velocityValue = [velocity doubleValue];
|
22 | 19 | }
|
23 | 20 |
|
24 | 21 | if (velocityValue > 0) {
|
25 |
| - SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@WithVelocity:", direction.lowercaseString.capitalizedString]); |
26 |
| - NSMethodSignature *signature = [self methodSignatureForSelector:selector]; |
| 22 | + SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@WithVelocity:", |
| 23 | + direction.lowercaseString.capitalizedString]); |
| 24 | + NSMethodSignature *signature = [target methodSignatureForSelector:selector]; |
27 | 25 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
28 | 26 | [invocation setSelector:selector];
|
29 | 27 | [invocation setArgument:&velocityValue atIndex:2];
|
30 |
| - [invocation invokeWithTarget:self]; |
| 28 | + [invocation invokeWithTarget:target]; |
31 | 29 | } else {
|
32 |
| - SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@", direction.lowercaseString.capitalizedString]); |
33 |
| - NSMethodSignature *signature = [self methodSignatureForSelector:selector]; |
| 30 | + SEL selector = NSSelectorFromString([NSString stringWithFormat:@"swipe%@", |
| 31 | + direction.lowercaseString.capitalizedString]); |
| 32 | + NSMethodSignature *signature = [target methodSignatureForSelector:selector]; |
34 | 33 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
|
35 | 34 | [invocation setSelector:selector];
|
36 |
| - [invocation invokeWithTarget:self]; |
| 35 | + [invocation invokeWithTarget:target]; |
37 | 36 | }
|
38 | 37 | }
|
39 | 38 |
|
| 39 | +@implementation XCUIElement (FBSwiping) |
| 40 | + |
| 41 | +- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity |
| 42 | +{ |
| 43 | + swipeWithDirection(self, direction, velocity); |
| 44 | +} |
| 45 | + |
| 46 | +@end |
| 47 | + |
| 48 | +#if !TARGET_OS_TV |
| 49 | +@implementation XCUICoordinate (FBSwiping) |
| 50 | + |
| 51 | +- (void)fb_swipeWithDirection:(NSString *)direction velocity:(nullable NSNumber*)velocity |
| 52 | +{ |
| 53 | + swipeWithDirection(self, direction, velocity); |
| 54 | +} |
| 55 | + |
40 | 56 | @end
|
| 57 | +#endif |
0 commit comments