Skip to content

Commit

Permalink
Internal Commit Uploaded
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 643104022
  • Loading branch information
mobile-devx-github-bot committed Jun 13, 2024
1 parent d220a47 commit 665aa42
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions AppFramework/Additions/UIGestureRecognizer+GREYApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ + (void)load {
gDisabledGestureRecognizers = nil;
GREYSwizzler *swizzler = [[GREYSwizzler alloc] init];
BOOL swizzled = [swizzler swizzleClass:self
replaceInstanceMethod:NSSelectorFromString(@"_setDirty")
withMethod:@selector(greyswizzled_setDirty)];
GREYFatalAssertWithMessage(swizzled, @"Failed to swizzle UIGestureRecognizer _setDirty");

swizzled = [swizzler swizzleClass:self
replaceInstanceMethod:NSSelectorFromString(@"_resetGestureRecognizer")
withMethod:@selector(greyswizzled_resetGestureRecognizer)];
GREYFatalAssertWithMessage(swizzled,
Expand All @@ -59,21 +54,6 @@ + (void)load {

#pragma mark - Swizzled Implementation

- (void)greyswizzled_setDirty {
INVOKE_ORIGINAL_IMP(void, @selector(greyswizzled_setDirty));
BOOL isAKeyboardPinchGestureOnIPad =
([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad &&
[self isKindOfClass:gKeyboardPinchGestureRecognizerClass]);
if (!isAKeyboardPinchGestureOnIPad && self.state != UIGestureRecognizerStateFailed) {
GREYAppStateTrackerObject *object =
TRACK_STATE_FOR_OBJECT(kGREYPendingGestureRecognition, self);
object.objectDescription =
[NSString stringWithFormat:@"%@\n Delegate: %@\n", object.objectDescription, self.delegate];
objc_setAssociatedObject(self, @selector(greyswizzled_setState:), object,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
}

- (void)greyswizzled_resetGestureRecognizer {
GREYAppStateTrackerObject *object =
objc_getAssociatedObject(self, @selector(greyswizzled_setState:));
Expand All @@ -90,6 +70,18 @@ - (void)greyswizzled_setState:(UIGestureRecognizerState)state {
objc_getAssociatedObject(self, @selector(greyswizzled_setState:));
UNTRACK_STATE_FOR_OBJECT(kGREYPendingGestureRecognition, object);
objc_setAssociatedObject(self, @selector(greyswizzled_setState:), nil, OBJC_ASSOCIATION_ASSIGN);
} else {
BOOL isAKeyboardPinchGestureOnIPad =
([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad &&
[self isKindOfClass:gKeyboardPinchGestureRecognizerClass]);
if (!isAKeyboardPinchGestureOnIPad && self.state != UIGestureRecognizerStateFailed) {
GREYAppStateTrackerObject *object =
TRACK_STATE_FOR_OBJECT(kGREYPendingGestureRecognition, self);
object.objectDescription = [NSString
stringWithFormat:@"%@\n Delegate: %@\n", object.objectDescription, self.delegate];
objc_setAssociatedObject(self, @selector(greyswizzled_setState:), object,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
}
INVOKE_ORIGINAL_IMP1(void, @selector(greyswizzled_setState:), state);
}
Expand Down

0 comments on commit 665aa42

Please sign in to comment.