Best EarlGrey code snippet using performAction.grey_pinchSlowInDirectionAndAngle
BasicInteractionTest.m
Source:BasicInteractionTest.m
...85 */86- (void)testZoomingOutwardFromScrollView {87 [self openTestViewNamed:@"Zooming Scroll View"];88 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"ZoomingScrollView")]89 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward,90 kGREYPinchAngleDefault)];91 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"ZoomingScrollView")]92 performAction:grey_tap()];93 [[EarlGrey selectElementWithMatcher:grey_text(@"EarlGrey TestApp")] performAction:grey_tap()];94}95/**96 * Check zooming into a scroll view.97 */98- (void)testZoomingIntoScrollView {99 [self openTestViewNamed:@"Zooming Scroll View"];100 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"ZoomingScrollView")]101 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionInward,102 kGREYPinchAngleDefault)];103 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"ZoomingScrollView")]104 performAction:grey_tap()];105 [[EarlGrey selectElementWithMatcher:grey_text(@"EarlGrey TestApp")] performAction:grey_tap()];106}107/**108 * Tap on a button five times and ensure that it went through by checking a label that is changed109 * on a button press.110 */111- (void)testTappingOnSimpleTapView {112 [self openTestViewNamed:@"Simple Tap View"];113 for (int i = 0; i < 20; i++) {114 NSString *text = [NSString stringWithFormat:@"Num Clicks: %d", i];115 [[EarlGrey selectElementWithMatcher:grey_text(text)]...
FTRGestureTest.m
Source:FTRGestureTest.m
...210 kGREYPinchAngleDefault)];211 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"gesture")]212 assertWithMatcher:grey_text(@"pinch out")];213 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Grey Box")]214 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionInward,215 kGREYPinchAngleDefault)];216 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"gesture")]217 assertWithMatcher:grey_text(@"pinch in")];218}219@end...
GestureTest.m
Source:GestureTest.m
...203 kGREYPinchAngleDefault)];204 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"gesture")]205 assertWithMatcher:grey_text(@"pinch out")];206 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Grey Box")]207 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionInward,208 kGREYPinchAngleDefault)];209 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"gesture")]210 assertWithMatcher:grey_text(@"pinch in")];211}212@end...
PinchViewTest.m
Source:PinchViewTest.m
...39}40- (void)testImageViewFrameSizeOnZoomingSlowOutward {41 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];42 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]43 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward,44 kGREYPinchAngleDefault)];45 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];46 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size47 andFinalSize:_imageViewFrameAfterPinch.size48 areOrdered:NSOrderedAscending];49}50- (void)testImageViewFrameSizeOnZoomingFastInward {51 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];52 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]53 performAction:grey_pinchFastInDirectionAndAngle(kGREYPinchDirectionInward,54 kGREYPinchAngleDefault)];55 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];56 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size57 andFinalSize:_imageViewFrameAfterPinch.size58 areOrdered:NSOrderedDescending];59}60- (void)testImageViewFrameSizeOnZoomingSlowInward {61 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];62 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]63 performAction:grey_pinchFastInDirectionAndAngle(kGREYPinchDirectionInward,64 kGREYPinchAngleDefault)];65 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];66 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size67 andFinalSize:_imageViewFrameAfterPinch.size68 areOrdered:NSOrderedDescending];69}70- (void)testImageViewFrameSizeOnZoomingInwardWithZeroAngle {71 double defaultPinchAngle = 0;72 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];73 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]74 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionInward,75 defaultPinchAngle)];76 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];77 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size78 andFinalSize:_imageViewFrameAfterPinch.size79 areOrdered:NSOrderedDescending];80}81- (void)testImageViewFrameSizeOnZoomingInwardWithNegativeAngle {82 double defaultPinchAngle = (-90.0 * M_PI / 180.0);83 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];84 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]85 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionInward,86 defaultPinchAngle)];87 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];88 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size89 andFinalSize:_imageViewFrameAfterPinch.size90 areOrdered:NSOrderedDescending];91}92- (void)testImageViewFrameSizeOnZoomingInwardWithAngle {93 double defaultPinchAngle = (30.0 * M_PI / 180.0);94 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];95 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]96 performAction:grey_pinchFastInDirectionAndAngle(kGREYPinchDirectionInward,97 defaultPinchAngle)];98 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];99 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size...
FTRPinchViewTest.m
Source:FTRPinchViewTest.m
...40}41- (void)testImageViewFrameSizeOnZoomingSlowOutward {42 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];43 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]44 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward,45 kGREYPinchAngleDefault)];46 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];47 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size48 andFinalSize:_imageViewFrameAfterPinch.size49 areOrdered:NSOrderedAscending];50}51- (void)testImageViewFrameSizeOnZoomingFastInward {52 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];53 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]54 performAction:grey_pinchFastInDirectionAndAngle(kGREYPinchDirectionInward,55 kGREYPinchAngleDefault)];56 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];57 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size58 andFinalSize:_imageViewFrameAfterPinch.size59 areOrdered:NSOrderedDescending];60}61- (void)testImageViewFrameSizeOnZoomingSlowInward {62 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];63 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]64 performAction:grey_pinchFastInDirectionAndAngle(kGREYPinchDirectionInward,65 kGREYPinchAngleDefault)];66 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];67 [self ftr_assertThatInitialSize:_imageViewFrameBeforePinch.size68 andFinalSize:_imageViewFrameAfterPinch.size69 areOrdered:NSOrderedDescending];70}71- (void)testImageViewFrameSizeOnZoomingInwardWithZeroAngle {72 double defaultPinchAngle = 0;73 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];74 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]75 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionInward,76 defaultPinchAngle)];77 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];78}79- (void)testImageViewFrameSizeOnZoomingInwardWithNegativeAngle {80 double defaultPinchAngle = (-90.0 * M_PI / 180.0);81 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];82 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]83 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionInward,84 defaultPinchAngle)];85 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];86}87- (void)testImageViewFrameSizeOnZoomingInwardWithAngle {88 double defaultPinchAngle = (30.0 * M_PI / 180.0);89 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];90 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Image View")]91 performAction:grey_pinchFastInDirectionAndAngle(kGREYPinchDirectionInward,92 defaultPinchAngle)];93 _imageViewFrameAfterPinch = [self ftr_imageViewFrame];94}95- (void)testImageViewFrameSizeOnZoomingOutwardWithAngle {96 double defaultPinchAngle = (180.0 * M_PI / 180.0);97 _imageViewFrameBeforePinch = [self ftr_imageViewFrame];...
grey_pinchSlowInDirectionAndAngle
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_keyWindow()] performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 90.0)];2+ (id<GREYAction>)grey_pinchSlowInDirectionAndAngle:(GREYPinchDirection)direction angle:(CGFloat)angle;3+ (id<GREYAction>)grey_pinchSlowInDirectionAndAngle:(GREYPinchDirection)direction angle:(CGFloat)angle {4 constraints:grey_allOf(grey_not(grey_systemAlertViewShown()),5 grey_interactable(),6 grey_kindOfClass([UIWindow class]),7 grey_respondsToSelector(@selector(pinchSlowInDirection:angle:)),8 performBlock:^BOOL(id element, __strong NSError **errorOrNil) {9 [element pinchSlowInDirection:direction angle:angle];10 return YES;11 }];12}13- (id<GREYAction>)grey_pinchSlowInDirectionAndAngle:(GREYPinchDirection)direction angle:(CGFloat)angle;14- (id<GREYAction>)grey_pinchSlowInDirectionAndAngle:(GREYPinchDirection)direction angle:(CGFloat)angle {15 return [GREYActions grey_pinchSlowInDirectionAndAngle:direction angle:angle];16}17- (id<GREYAction>)grey_pinchSlowInDirectionAndAngle:(GREYPinchDirection)direction angle:(CGFloat)angle {18 return [GREYActions grey_pinchSlowInDirectionAndAngle:direction angle:angle];19}
grey_pinchSlowInDirectionAndAngle
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"label")] performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0)];2GREY_EXPORT id<GREYAction> grey_pinchSlowInDirectionAndAngle(GREYPinchDirection direction, CGFloat angle);3id<GREYAction> grey_pinchSlowInDirectionAndAngle(GREYPinchDirection direction, CGFloat angle) {4 return grey_actionBlockWithName(@"pinchSlowInDirectionAndAngle",5 ^(id element, __strong NSError **errorOrNil) {6 return [element grey_pinchSlowInDirection:direction angle:angle error:errorOrNil];7 });8}9- (BOOL)grey_pinchSlowInDirection:(GREYPinchDirection)direction10 angle:(CGFloat)angle11 error:(__strong NSError **)errorOrNil {12 if (![self grey_isVisible:errorOrNil]) {13 return NO;14 }15 return [self grey_pinchSlowInDirection:direction angle:angle error:errorOrNil];16}17- (BOOL)grey_pinchSlowInDirection:(GREYPinchDirection)direction18 angle:(CGFloat)angle19 error:(__strong NSError **)errorOrNil {20 CGPoint start, end;21 if (![self grey_calculatePinchStart:&start end:&end direction:direction error:errorOrNil]) {22 return NO;23 }24 __block BOOL success = NO;25 GREYPerformBlockInBackground(^{26 error:errorOrNil];27 });28 return success;29}30- (BOOL)grey_performPinchWithStart:(CGPoint)start31 end:(CGPoint)end32 angle:(CGFloat)angle33 error:(__strong NSError **)error
grey_pinchSlowInDirectionAndAngle
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"pinchView")]2performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0)];3GREYActionBlock *pinchAction = grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0);4[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"pinchView")] performAction:pinchAction];5GREYActionBlock *pinchAction = grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0);6[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"pinchView")] performAction:pinchAction];7GREYActionBlock *pinchAction = grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0);8[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"pinchView")] performAction:pinchAction];9GREYActionBlock *pinchAction = grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0);10[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"pinchView")] performAction:pinchAction];11GREYActionBlock *pinchAction = grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0);12[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"pinchView")] performAction:pinchAction];13GREYActionBlock *pinchAction = grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 0);
grey_pinchSlowInDirectionAndAngle
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"view")]2 performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 45)];3[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"view")]4 performAction:grey_actionForPinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 45)];5+ (id<GREYAction>)actionForPinchSlowInDirectionAndAngle:(GREYPinchDirection)direction6 angle:(double)angle {7 constraints:grey_not(grey_systemAlertViewShown())8 performActionBlock:^BOOL (id element, NSError *__strong *errorOrNil) {9 angle:angle];10 }];11}12+ (BOOL)grey_pinchSlowInDirectionAndAngle:(GREYPinchDirection)direction13 element:(id)element14 error:(__strong NSError **)error15 angle:(double)angle {16 if (![element isKindOfClass:[UIView class]]) {17 NSString *description = [NSString stringWithFormat:@"Cannot pinch on element: %@", element];18 I_GREYPopulateErrorNotedOrLog(error, kGREYInteractionErrorDomain,19 kGREYInteractionActionFailedErrorCode, description);20 return NO;21 }22 UIView *view = (UIView *)element;23 CGPoint center = CGPointMake(CGRectGetMidX(view.bounds), CGRectGetMidY(view.bounds));24 CGPoint start;25 if (direction == kGREYPinchDirectionOutward) {26 start = CGPointMake(CGRectGetMinX(view.bounds), CGRectGetMinY(view.bounds));27 } else {28 start = CGPointMake(CGRectGetMaxX(view.bounds), CGRectGetMaxY(view.bounds));29 }
grey_pinchSlowInDirectionAndAngle
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 90.0)];2[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_pinchFastInDirectionAndAngle(kGREYPinchDirectionOutward, 90.0)];3[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_pinchSlowInDirection(kGREYPinchDirectionOutward)];4[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_pinchFastInDirection(kGREYPinchDirectionOutward)];5[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_rotateSlowInDirection(kGREYDirectionLeft)];6[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_rotateFastInDirection(kGREYDirectionLeft)];7[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_scrollInDirection(kGREYDirectionLeft, 100)];8[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_scrollToContentEdge(kGREYContentEdgeLeft)];9[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")] performAction:grey_swipeFastInDirection(kGREYDirectionLeft)];
grey_pinchSlowInDirectionAndAngle
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"PinchMe")] performAction:grey_pinchSlowInDirectionAndAngle(kGREYPinchDirectionOutward, 90)];2[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"ScrollMe")] performAction:grey_scrollInDirection(kGREYDirectionUp, 100)];3[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TapMe")] performAction:grey_tap()];4[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TapMe")] performAction:grey_tapAtPoint(CGPointMake(100, 100))];5[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TapMe")] performAction:grey_tapFast()];6[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TapMe")] performAction:grey_tapWithNumberOfTaps(2)];7[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TapMe")] performAction:grey_tapWithNumberOfTapsAtPoint(2, CGPointMake(100, 100))];8[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TypeMe")]
grey_pinchSlowInDirectionAndAngle
Using AI Code Generation
1performAction *action = [[performAction alloc] init];2[action grey_pinchSlowInDirectionAndAngle:kGREYPinchDirectionOutwards angle:angle];3- (id<GREYAction>)grey_pinchSlowInDirectionAndAngle:(GREYPinchDirection)direction4 angle:(double)angle {5 return [GREYActions actionForPinchSlowInDirection:direction angle:angle];6}7+ (id<GREYAction>)actionForPinchSlowInDirection:(GREYPinchDirection)direction8 angle:(double)angle {9 return [GREYActions actionForPinchSlowInDirection:direction angle:angle velocity:1];10}11+ (id<GREYAction>)actionForPinchSlowInDirection:(GREYPinchDirection)direction12 angle:(double)angle13 velocity:(double)velocity {14 duration:kGREYPinchSlowActionDuration];15}16- (instancetype)initWithDirection:(GREYPinchDirection)direction17 angle:(double)angle18 velocity:(double)velocity19 duration:(CFTimeInterval)duration {20 constraints:grey_not(grey_systemAlertViewShown())];21 if (self) {22 _direction = direction;23 _angle = angle;24 _velocity = velocity;25 _duration = duration;26 }27 return self;28}29- (BOOL)perform:(id)element error:(__strong NSError **)error {30 if (![self satisfiesConstraintsForElement:element error:error]) {31 return NO;32 }33 GREYThrowOnFailedConditionWithMessage([element isKindOfClass:[UIView class]],
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!