How to use grey_scrollInDirection method of performAction class

Best EarlGrey code snippet using performAction.grey_scrollInDirection

FTRScrollViewTest.m

Source:FTRScrollViewTest.m Github

copy

Full Screen

...27- (void)testScrollToTopEdge {28 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(),29 grey_sufficientlyVisible(), nil);30 [[[EarlGrey selectElementWithMatcher:matcher]31 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)32 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]33 assertWithMatcher:grey_sufficientlyVisible()];34 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]35 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];36 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]37 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];38}39- (void)testScrollToBottomEdge {40 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]41 performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)]42 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeBottom)];43}44- (void)testScrollToRightEdge {45 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]46 performAction:grey_scrollToContentEdge(kGREYContentEdgeRight)]47 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeRight)];48}49- (void)testScrollToLeftEdge {50 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]51 performAction:grey_scrollToContentEdge(kGREYContentEdgeRight)];52 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]53 performAction:grey_scrollToContentEdge(kGREYContentEdgeLeft)]54 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];55}56- (void)testScrollToLeftEdgeWithCustomStartPoint {57 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]58 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeLeft, 0.5, 0.5)];59 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]60 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];61}62- (void)testScrollToRightEdgeWithCustomStartPoint {63 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]64 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeRight, 0.5, 0.5)];65 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]66 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeRight)];67}68- (void)testScrollToTopEdgeWithCustomStartPoint {69 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]70 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeTop, 0.5, 0.5)];71 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]72 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];73}74- (void)testScrollToBottomEdgeWithCustomStartPoint {75 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]76 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeBottom, 0.5, 0.5)];77 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]78 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeBottom)];79}80- (void)testScrollToTopWorksWithPositiveInsets {81 // Scroll down.82 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(),83 grey_sufficientlyVisible(), nil);84 [[[EarlGrey selectElementWithMatcher:matcher]85 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)86 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]87 assertWithMatcher:grey_sufficientlyVisible()];88 // Add positive insets using this format {top,left,bottom,right}89 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]90 performAction:grey_typeText(@"{100,0,0,0}\n")];91 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]92 performAction:grey_turnSwitchOn(YES)];93 // Scroll to top and verify.94 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]95 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];96 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]97 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];98}99- (void)testScrollToTopWorksWithNegativeInsets {100 // Scroll down.101 id<GREYMatcher> matcher =102 grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(), nil);103 [[[EarlGrey selectElementWithMatcher:matcher]104 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)105 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]106 assertWithMatcher:grey_sufficientlyVisible()];107 // Add positive insets using this format {top,left,bottom,right}108 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]109 performAction:grey_typeText(@"{-100,0,0,0}\n")];110 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]111 performAction:grey_turnSwitchOn(YES)];112 // Scroll to top and verify.113 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]114 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];115 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]116 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];117}118- (void)testSearchActionReturnsNilWhenElementIsNotFound {119 id<GREYMatcher> matcher =120 grey_allOf(grey_accessibilityLabel(@"Unobtainium"), grey_interactable(), nil);121 [[[EarlGrey selectElementWithMatcher:matcher]122 usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, 50)123 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]124 assertWithMatcher:grey_nil()];125}126- (void)testScrollToTopWhenAlreadyAtTheTopWithoutBounce {127 GREYHostApplicationDistantObject *host = GREYHostApplicationDistantObject.sharedInstance;128 id<GREYAction> bounceOff = [host actionForToggleBounces];129 // Verify this test with and without bounce enabled by toggling it.130 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]131 performAction:bounceOff];132 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]133 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];134 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]135 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];136}137- (void)testScrollToTopWhenAlreadyAtTheTopWithBounce {138 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]139 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];140 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]141 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];142}143- (void)testVisibilityOnPartiallyObscuredScrollView {144 GREYHostApplicationDistantObject *host = GREYHostApplicationDistantObject.sharedInstance;145 id<GREYAssertion> assertion = [host assertionWithPartiallyVisible];146 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]147 assert:assertion];148}149- (void)testInfiniteScroll {150 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]151 performAction:grey_scrollInDirection(kGREYDirectionDown, 100)];152}153- (void)testScrollInDirectionCausesExactChangesToContentOffsetInPortraitMode {154 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];155}156- (void)testScrollInDirectionCausesExactChangesToContentOffsetInPortraitUpsideDownMode {157 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortraitUpsideDown error:nil];158 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];159}160- (void)testScrollInDirectionCausesExactChangesToContentOffsetInLandscapeLeftMode {161 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeLeft error:nil];162 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];163}164- (void)testScrollInDirectionCausesExactChangesToContentOffsetInLandscapeRightMode {165 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight error:nil];166 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];167}168// TODO: Because the action is performed outside the main thread, the synchronization // NOLINT169// waits until the scrolling stops, where the scroll view's inertia causes itself170// to move more than needed.171- (void)testScrollInDirectionCausesExactChangesToContentOffsetWithTinyScrollAmounts {172 // Scroll by a fixed amount and verify that the scroll offset has changed by that amount.173 // Go down to (0, 7)174 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]175 performAction:grey_scrollInDirection(kGREYDirectionDown, 7)];176 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]177 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 7)))];178 // Go right to (6, 7)179 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]180 performAction:grey_scrollInDirection(kGREYDirectionRight, 6)];181 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]182 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(6, 7)))];183 // Go up to (6, 4)184 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]185 performAction:grey_scrollInDirection(kGREYDirectionUp, 3)];186 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]187 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(6, 4)))];188 // Go left to (3, 4)189 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]190 performAction:grey_scrollInDirection(kGREYDirectionLeft, 3)];191 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]192 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(3, 4)))];193}194- (void)testScrollToTopWithZeroXOffset {195 // Scroll down.196 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]197 performAction:grey_scrollInDirection(kGREYDirectionDown, 500)];198 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]199 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 500)))];200 // Scroll up using grey_scrollToTop(...) and verify scroll offset is back at 0.201 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]202 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];203 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]204 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 0)))];205}206- (void)testScrollToTopWithNonZeroXOffset {207 // Scroll to (50, 400)208 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]209 performAction:grey_scrollInDirection(kGREYDirectionDown, 400)];210 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]211 performAction:grey_scrollInDirection(kGREYDirectionRight, 50)];212 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]213 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(50, 400)))];214 // Scroll up using grey_scrollToContentEdge(...) and verify scroll offset is back at 0.215 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]216 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];217 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]218 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(50, 0)))];219}220- (void)testScrollingBeyondTheContentViewCausesScrollErrors {221 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]222 performAction:grey_scrollInDirection(kGREYDirectionDown, 100)];223 NSError *scrollError;224 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]225 performAction:grey_scrollInDirection(kGREYDirectionUp, 200)226 error:&scrollError];227 GREYAssertEqualObjects(scrollError.domain, kGREYScrollErrorDomain, @"should be equal");228 GREYAssertEqual(scrollError.code, kGREYScrollReachedContentEdge, @"should be equal");229}230- (void)testSetContentOffsetAnimatedYesWaitsForAnimation {231 [self ftr_setContentOffSet:CGPointMake(0, 100) animated:YES];232 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"SquareElementLabel")]233 assertWithMatcher:grey_sufficientlyVisible()];234}235- (void)testSetContentOffsetAnimatedNoDoesNotWaitForAnimation {236 [self ftr_setContentOffSet:CGPointMake(0, 100) animated:NO];237 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"SquareElementLabel")]238 assertWithMatcher:grey_sufficientlyVisible()];239}240- (void)testSetContentOffsetToSameCGPointDoesNotWait {241 [self ftr_setContentOffSet:CGPointZero animated:YES];242}243- (void)testContentSizeSmallerThanViewSize {244 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Small Content Scroll View")]245 performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];246}247#pragma mark - Private248// Asserts that the scroll actions work accurately in all four directions by verifying the content249// offset changes caused by them.250- (void)ftr_assertScrollInDirectionCausesExactChangesToContentOffset {251 // Scroll by a fixed amount and verify that the scroll offset has changed by that amount.252 // Go down to (0, 99)253 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]254 performAction:grey_scrollInDirection(kGREYDirectionDown, 99)];255 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]256 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 99)))];257 // Go right to (77, 99)258 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]259 performAction:grey_scrollInDirection(kGREYDirectionRight, 77)];260 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]261 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(77, 99)))];262 // Go up to (77, 44)263 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]264 performAction:grey_scrollInDirection(kGREYDirectionUp, 55)];265 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]266 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(77, 44)))];267 // Go left to (33, 44)268 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]269 performAction:grey_scrollInDirection(kGREYDirectionLeft, 44)];270 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]271 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(33, 44)))];272}273// Makes a setContentOffset:animated: call on an element of type UIScrollView.274- (void)ftr_setContentOffSet:(CGPoint)offset animated:(BOOL)animated {275 GREYHostApplicationDistantObject *host = GREYHostApplicationDistantObject.sharedInstance;276 id<GREYAction> action = [host actionForSetScrollViewContentOffSet:offset animated:animated];277 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]278 performAction:action];279}280@end...

Full Screen

Full Screen

ScrollViewTest.m

Source:ScrollViewTest.m Github

copy

Full Screen

...27- (void)testScrollToTopEdge {28 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(),29 grey_sufficientlyVisible(), nil);30 [[[EarlGrey selectElementWithMatcher:matcher]31 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)32 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]33 assertWithMatcher:grey_sufficientlyVisible()];34 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]35 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];36 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]37 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];38}39- (void)testScrollToBottomEdge {40 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]41 performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)]42 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeBottom)];43}44- (void)testScrollToRightEdge {45 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]46 performAction:grey_scrollToContentEdge(kGREYContentEdgeRight)]47 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeRight)];48}49- (void)testScrollToLeftEdge {50 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]51 performAction:grey_scrollToContentEdge(kGREYContentEdgeRight)];52 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]53 performAction:grey_scrollToContentEdge(kGREYContentEdgeLeft)]54 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];55}56- (void)testScrollToLeftEdgeWithCustomStartPoint {57 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]58 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeLeft, 0.5, 0.5)];59 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]60 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];61}62- (void)testScrollToRightEdgeWithCustomStartPoint {63 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]64 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeRight, 0.5, 0.5)];65 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]66 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeRight)];67}68- (void)testScrollToTopEdgeWithCustomStartPoint {69 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]70 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeTop, 0.5, 0.5)];71 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]72 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];73}74- (void)testScrollToBottomEdgeWithCustomStartPoint {75 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]76 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeBottom, 0.5, 0.5)];77 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]78 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeBottom)];79}80- (void)testScrollToTopWorksWithPositiveInsets {81 // Scroll down.82 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(),83 grey_sufficientlyVisible(), nil);84 [[[EarlGrey selectElementWithMatcher:matcher]85 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)86 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]87 assertWithMatcher:grey_sufficientlyVisible()];88 // Add positive insets using this format {top,left,bottom,right}89 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]90 performAction:grey_typeText(@"{100,0,0,0}\n")];91 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]92 performAction:grey_turnSwitchOn(YES)];93 // Scroll to top and verify.94 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]95 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];96 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]97 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];98}99- (void)testScrollToTopWorksWithNegativeInsets {100 // Scroll down.101 id<GREYMatcher> matcher =102 grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(), nil);103 [[[EarlGrey selectElementWithMatcher:matcher]104 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)105 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]106 assertWithMatcher:grey_sufficientlyVisible()];107 // Add positive insets using this format {top,left,bottom,right}108 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]109 performAction:grey_typeText(@"{-100,0,0,0}\n")];110 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]111 performAction:grey_turnSwitchOn(YES)];112 // Scroll to top and verify.113 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]114 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];115 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]116 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];117}118- (void)testSearchActionReturnsNilWhenElementIsNotFound {119 id<GREYMatcher> matcher =120 grey_allOf(grey_accessibilityLabel(@"Unobtainium"), grey_interactable(), nil);121 [[[EarlGrey selectElementWithMatcher:matcher]122 usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, 50)123 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]124 assertWithMatcher:grey_nil()];125}126- (void)testScrollToTopWhenAlreadyAtTheTopWithoutBounce {127 GREYHostApplicationDistantObject *host = GREYHostApplicationDistantObject.sharedInstance;128 id<GREYAction> bounceOff = [host actionForToggleBounces];129 // Verify this test with and without bounce enabled by toggling it.130 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]131 performAction:bounceOff];132 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]133 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];134 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]135 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];136}137- (void)testScrollToTopWhenAlreadyAtTheTopWithBounce {138 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]139 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];140 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]141 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];142}143- (void)testVisibilityOnPartiallyObscuredScrollView {144 GREYHostApplicationDistantObject *host = GREYHostApplicationDistantObject.sharedInstance;145 id<GREYAssertion> assertion = [host assertionWithPartiallyVisible];146 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]147 assert:assertion];148}149- (void)testInfiniteScroll {150 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]151 performAction:grey_scrollInDirection(kGREYDirectionDown, 100)];152}153- (void)testScrollInDirectionCausesExactChangesToContentOffsetInPortraitMode {154 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];155}156- (void)testScrollInDirectionCausesExactChangesToContentOffsetInPortraitUpsideDownMode {157 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortraitUpsideDown error:nil];158 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];159}160- (void)testScrollInDirectionCausesExactChangesToContentOffsetInLandscapeLeftMode {161 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeLeft error:nil];162 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];163}164- (void)testScrollInDirectionCausesExactChangesToContentOffsetInLandscapeRightMode {165 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeRight error:nil];166 [self ftr_assertScrollInDirectionCausesExactChangesToContentOffset];167}168// TODO: Because the action is performed outside the main thread, the synchronization // NOLINT169// waits until the scrolling stops, where the scroll view's inertia causes itself170// to move more than needed.171- (void)testScrollInDirectionCausesExactChangesToContentOffsetWithTinyScrollAmounts {172 // Scroll by a fixed amount and verify that the scroll offset has changed by that amount.173 // Go down to (0, 7)174 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]175 performAction:grey_scrollInDirection(kGREYDirectionDown, 7)];176 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]177 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 7)))];178 // Go right to (6, 7)179 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]180 performAction:grey_scrollInDirection(kGREYDirectionRight, 6)];181 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]182 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(6, 7)))];183 // Go up to (6, 4)184 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]185 performAction:grey_scrollInDirection(kGREYDirectionUp, 3)];186 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]187 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(6, 4)))];188 // Go left to (3, 4)189 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]190 performAction:grey_scrollInDirection(kGREYDirectionLeft, 3)];191 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]192 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(3, 4)))];193}194- (void)testScrollToTopWithZeroXOffset {195 // Scroll down.196 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]197 performAction:grey_scrollInDirection(kGREYDirectionDown, 500)];198 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]199 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 500)))];200 // Scroll up using grey_scrollToTop(...) and verify scroll offset is back at 0.201 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]202 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];203 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]204 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 0)))];205}206- (void)testScrollToTopWithNonZeroXOffset {207 // Scroll to (50, 400)208 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]209 performAction:grey_scrollInDirection(kGREYDirectionDown, 400)];210 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]211 performAction:grey_scrollInDirection(kGREYDirectionRight, 50)];212 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]213 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(50, 400)))];214 // Scroll up using grey_scrollToContentEdge(...) and verify scroll offset is back at 0.215 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]216 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];217 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]218 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(50, 0)))];219}220- (void)testScrollingBeyondTheContentViewCausesScrollErrors {221 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]222 performAction:grey_scrollInDirection(kGREYDirectionDown, 100)];223 NSError *scrollError;224 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]225 performAction:grey_scrollInDirection(kGREYDirectionUp, 200)226 error:&scrollError];227 GREYAssertEqualObjects(scrollError.domain, kGREYScrollErrorDomain, @"should be equal");228 GREYAssertEqual(scrollError.code, kGREYScrollReachedContentEdge, @"should be equal");229}230- (void)testSetContentOffsetAnimatedYesWaitsForAnimation {231 [self ftr_setContentOffSet:CGPointMake(0, 100) animated:YES];232 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"SquareElementLabel")]233 assertWithMatcher:grey_sufficientlyVisible()];234}235- (void)testSetContentOffsetAnimatedNoDoesNotWaitForAnimation {236 [self ftr_setContentOffSet:CGPointMake(0, 100) animated:NO];237 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"SquareElementLabel")]238 assertWithMatcher:grey_sufficientlyVisible()];239}240- (void)testSetContentOffsetToSameCGPointDoesNotWait {241 [self ftr_setContentOffSet:CGPointZero animated:YES];242}243- (void)testContentSizeSmallerThanViewSize {244 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Small Content Scroll View")]245 performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];246}247#pragma mark - Private248// Asserts that the scroll actions work accurately in all four directions by verifying the content249// offset changes caused by them.250- (void)ftr_assertScrollInDirectionCausesExactChangesToContentOffset {251 // Scroll by a fixed amount and verify that the scroll offset has changed by that amount.252 // Go down to (0, 99)253 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]254 performAction:grey_scrollInDirection(kGREYDirectionDown, 99)];255 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]256 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(0, 99)))];257 // Go right to (77, 99)258 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]259 performAction:grey_scrollInDirection(kGREYDirectionRight, 77)];260 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]261 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(77, 99)))];262 // Go up to (77, 44)263 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]264 performAction:grey_scrollInDirection(kGREYDirectionUp, 55)];265 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]266 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(77, 44)))];267 // Go left to (33, 44)268 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Infinite Scroll View")]269 performAction:grey_scrollInDirection(kGREYDirectionLeft, 44)];270 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]271 assertWithMatcher:grey_text(NSStringFromCGPoint(CGPointMake(33, 44)))];272}273// Makes a setContentOffset:animated: call on an element of type UIScrollView.274- (void)ftr_setContentOffSet:(CGPoint)offset animated:(BOOL)animated {275 GREYHostApplicationDistantObject *host = GREYHostApplicationDistantObject.sharedInstance;276 id<GREYAction> action = [host actionForSetScrollViewContentOffSet:offset animated:animated];277 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]278 performAction:action];279}280@end...

Full Screen

Full Screen

FirebaseAuthEarlGreyTests.m

Source:FirebaseAuthEarlGreyTests.m Github

copy

Full Screen

...63- (void)testSignInExistingUser {64 NSString *email = @"123@abc.com";65 [[[EarlGrey selectElementWithMatcher:grey_allOf(grey_text(@"Sign in with Email/Password"),66 grey_sufficientlyVisible(), nil)]67 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, kShortScrollDistance)68 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),69 nil)] performAction:grey_tap()];70 id<GREYMatcher> comfirmationButtonMatcher =71 grey_allOf(grey_kindOfClass([UILabel class]), grey_accessibilityLabel(@"OK"), nil);72 [[EarlGrey selectElementWithMatcher:73 #warning TODO Add accessibilityIdentifiers for the elements.74 grey_kindOfClass(NSClassFromString(@"_UIAlertControllerView"))]75 performAction:grey_typeText(email)];76 [[EarlGrey selectElementWithMatcher:comfirmationButtonMatcher] performAction:grey_tap()];77 [[EarlGrey78 selectElementWithMatcher:grey_kindOfClass(NSClassFromString(@"_UIAlertControllerView"))]79 performAction:grey_typeText(@"password")];80 [[EarlGrey selectElementWithMatcher:comfirmationButtonMatcher] performAction:grey_tap()];81 [[[EarlGrey82 selectElementWithMatcher:grey_allOf(grey_text(email), grey_sufficientlyVisible(), nil)]83 usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, kShortScrollDistance)84 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),85 nil)] assertWithMatcher:grey_sufficientlyVisible()];86}87/** Test sign in with a valid BYOAuth token retrived from a remote server. */88- (void)testSignInWithValidBYOAuthToken {89 NSError *error;90 NSString *customToken = [NSString stringWithContentsOfURL:[NSURL URLWithString:kCustomTokenUrl]91 encoding:NSUTF8StringEncoding92 error:&error];93 if (!customToken) {94 GREYFail(@"There was an error retrieving the custom token: %@", error);95 }96 [[[EarlGrey selectElementWithMatcher:grey_allOf(grey_text(@"Sign In (BYOAuth)"),97 grey_sufficientlyVisible(), nil)]98 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, kShortScrollDistance)99 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),100 nil)] performAction:grey_tap()];101 [[[EarlGrey selectElementWithMatcher:grey_kindOfClass([UITextView class])]102 performAction:grey_replaceText(customToken)] assertWithMatcher:grey_text(customToken)];103 [[EarlGrey selectElementWithMatcher:grey_text(@"Done")] performAction:grey_tap()];104 [self waitForElementWithText:@"OK" withDelay:kWaitForElementTimeOut];105 [[EarlGrey selectElementWithMatcher:grey_text(@"OK")] performAction:grey_tap()];106 [[[EarlGrey107 selectElementWithMatcher:grey_allOf(grey_text(kTestingAccountUserID),108 grey_sufficientlyVisible(), nil)]109 usingSearchAction:grey_scrollInDirection(kGREYDirectionUp,110 kShortScrollDistance)111 onElementWithMatcher:grey_allOf(grey_scrollView(),112 grey_kindOfClass([UITableView class]),113 nil)]114 assertWithMatcher:grey_sufficientlyVisible()];115}116- (void)testSignInWithInvalidBYOAuthToken {117 [[[EarlGrey selectElementWithMatcher:grey_allOf(grey_text(@"Sign In (BYOAuth)"),118 grey_sufficientlyVisible(), nil)]119 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, kShortScrollDistance)120 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),121 nil)] performAction:grey_tap()];122 [[[EarlGrey selectElementWithMatcher:grey_kindOfClass([UITextView class])]123 performAction:grey_replaceText(kInvalidCustomToken)]124 assertWithMatcher:grey_text(kInvalidCustomToken)];125 [[EarlGrey selectElementWithMatcher:grey_text(@"Done")] performAction:grey_tap()];126 NSString *invalidTokenErrorMessage =127 @"The custom token format is incorrect. Please check the documentation.";128 [self waitForElementWithText:invalidTokenErrorMessage withDelay:kWaitForElementTimeOut];129 [[EarlGrey selectElementWithMatcher:grey_text(@"OK")] performAction:grey_tap()];130}131#pragma mark - Helpers132/** Sign out current account. */133- (void)signOut {...

Full Screen

Full Screen

BYOAuthTests.m

Source:BYOAuthTests.m Github

copy

Full Screen

...33 GREYFail(@"There was an error retrieving the custom token: %@", error);34 }35 [[[EarlGrey selectElementWithMatcher:grey_allOf(grey_text(@"Sign In (BYOAuth)"),36 grey_sufficientlyVisible(), nil)]37 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, kShortScrollDistance)38 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),39 nil)] performAction:grey_tap()];40 [[[EarlGrey selectElementWithMatcher:grey_kindOfClass([UITextView class])]41 performAction:grey_replaceText(customToken)] assertWithMatcher:grey_text(customToken)];42 [[EarlGrey selectElementWithMatcher:grey_text(@"Done")] performAction:grey_tap()];43 [self waitForElementWithText:@"OK" withDelay:kWaitForElementTimeOut];44 [[EarlGrey selectElementWithMatcher:grey_text(@"OK")] performAction:grey_tap()];45 [[[EarlGrey selectElementWithMatcher:grey_allOf(grey_text(kTestingAccountUserID),46 grey_sufficientlyVisible(), nil)]47 usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, kShortScrollDistance)48 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),49 nil)] assertWithMatcher:grey_sufficientlyVisible()];50}51- (void)testSignInWithInvalidBYOAuthToken {52 [[[EarlGrey selectElementWithMatcher:grey_allOf(grey_text(@"Sign In (BYOAuth)"),53 grey_sufficientlyVisible(), nil)]54 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, kShortScrollDistance)55 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),56 nil)] performAction:grey_tap()];57 [[[EarlGrey selectElementWithMatcher:grey_kindOfClass([UITextView class])]58 performAction:grey_replaceText(kInvalidCustomToken)]59 assertWithMatcher:grey_text(kInvalidCustomToken)];60 [[EarlGrey selectElementWithMatcher:grey_text(@"Done")] performAction:grey_tap()];61 NSString *invalidTokenErrorMessage = @"Sign-In Error";62 [self waitForElementWithText:invalidTokenErrorMessage withDelay:kWaitForElementTimeOut];63 [[EarlGrey selectElementWithMatcher:grey_text(@"OK")] performAction:grey_tap()];64}65@end...

Full Screen

Full Screen

FIRAuthE2eTests.m

Source:FIRAuthE2eTests.m Github

copy

Full Screen

...20- (void)testSignInExistingUser {21 NSString *email = @"123@abc.com";22 [[[EarlGrey selectElementWithMatcher:grey_allOf(grey_text(@"Sign in with Email/Password"),23 grey_sufficientlyVisible(), nil)]24 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, kShortScrollDistance)25 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),26 nil)] performAction:grey_tap()];27 id<GREYMatcher> comfirmationButtonMatcher =28 grey_allOf(grey_kindOfClass([UILabel class]), grey_accessibilityLabel(@"OK"), nil);29 [[EarlGrey selectElementWithMatcher:30#warning TODO Add accessibilityIdentifiers for the elements.31 grey_kindOfClass(NSClassFromString(@"_UIAlertControllerView"))]32 performAction:grey_typeText(email)];33 [[EarlGrey selectElementWithMatcher:comfirmationButtonMatcher] performAction:grey_tap()];34 [[EarlGrey35 selectElementWithMatcher:grey_kindOfClass(NSClassFromString(@"_UIAlertControllerView"))]36 performAction:grey_typeText(@"password")];37 [[EarlGrey selectElementWithMatcher:comfirmationButtonMatcher] performAction:grey_tap()];38 [[[EarlGrey39 selectElementWithMatcher:grey_allOf(grey_text(email), grey_sufficientlyVisible(), nil)]40 usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, kShortScrollDistance)41 onElementWithMatcher:grey_allOf(grey_scrollView(), grey_kindOfClass([UITableView class]),42 nil)] assertWithMatcher:grey_sufficientlyVisible()];43}44@end...

Full Screen

Full Screen

grey_scrollInDirection

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"table")] performAction:grey_scrollInDirection(kGREYDirectionUp, 100)];2[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"table")] performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];3EarlGrey.selectElement(with: grey_accessibilityID("table")).perform(grey_scrollInDirection(kGREYDirectionUp, 100))4EarlGrey.selectElement(with: grey_accessibilityID("table")).perform(grey_scrollToContentEdge(kGREYContentEdgeTop))5EarlGrey.selectElement(with: grey_accessibilityID("table")).perform(grey_scrollInDirection(kGREYDirectionUp, 100))6EarlGrey.selectElement(with: grey_accessibilityID("table")).perform(grey_scrollToContentEdge(kGREYContentEdgeTop))7[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"table")] performAction:grey_scrollInDirection(kGREYDirectionUp, 100)];8[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"table")] performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];9[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"table")] performAction:grey_scrollInDirection(kGREYDirectionUp, 100)];10[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"table")] performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];11EarlGrey.selectElement(with: grey_accessibilityID("table")).perform(grey_scrollInDirection

Full Screen

Full Screen

grey_scrollInDirection

Using AI Code Generation

copy

Full Screen

1GREYActionBlock *actionBlock = [GREYActionBlock actionWithName:@"scroll" constraints:grey_not(grey_systemAlertViewShown()) performBlock:^BOOL (id element, NSError *__strong *errorOrNil) {2 return [element grey_scrollInDirection:kGREYDirectionDown amount:70];3}];4[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:actionBlock];5- (BOOL)grey_scrollInDirection:(GREYDirection)direction amount:(CGFloat)amount {6 GREYFatalAssertWithMessage(direction != kGREYDirectionUnknown,7 @"Cannot scroll in unknown direction");8 GREYFatalAssertWithMessage(amount > 0, @"Cannot scroll with negative amount");9 GREYFatalAssertMainThread();10 GREYFatalAssertNotVisible(self);11 CGPoint startPoint, endPoint;12 [self grey_startPoint:&startPoint endPoint:&endPoint forDirection:direction amount:amount];13 NSTimeInterval duration = [self grey_scrollDurationForDistance:amount];14 withSpeed:amount / duration];15}16- (void)grey_startPoint:(CGPoint *)startPoint17 endPoint:(CGPoint *)endPoint18 forDirection:(GREYDirection)direction19 amount:(CGFloat)amount {20 CGRect elementFrame = [self grey_frameInScreen];21 switch (direction) {22 *startPoint = CGPointMake(CGRectGetMidX(elementFrame), CGRectGetMaxY(elementFrame));23 *endPoint = CGPointMake(CGRectGetMidX(elementFrame), CGRectGetMaxY(elementFrame) - amount);24 break;25 *startPoint = CGPointMake(CGRectGetMidX(elementFrame), CGRectGetMinY(elementFrame));26 *endPoint = CGPointMake(CGRectGetMidX(elementFrame), CGRectGetMinY(elementFrame) + amount);27 break;28 *startPoint = CGPointMake(CGRectGetMaxX(elementFrame), CGRectGetMidY(elementFrame));29 *endPoint = CGPointMake(CGRectGetMaxX(elementFrame) - amount, CGRectGetMid

Full Screen

Full Screen

grey_scrollInDirection

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myID")] performAction:grey_scrollInDirection(kGREYDirectionDown, 100)];2GREY_EXPORT id<GREYAction> grey_scrollInDirection(grey_content_edge_t edge, CGFloat distance);3id<GREYAction> grey_scrollInDirection(grey_content_edge_t edge, CGFloat distance) {4 return [GREYScrollAction actionWithDirection:edge distance:distance duration:0.2];5}6+ (instancetype)actionWithDirection:(grey_content_edge_t)edge7 distance:(CGFloat)distance8 duration:(CFTimeInterval)duration;9+ (instancetype)actionWithDirection:(grey_content_edge_t)edge10 distance:(CGFloat)distance11 duration:(CFTimeInterval)duration {12 return [[self alloc] initWithDirection:edge distance:distance duration:duration];13}14- (instancetype)initWithDirection:(grey_content_edge_t)edge15 distance:(CGFloat)distance16 duration:(CFTimeInterval)duration {17 NSAssert(duration > 0, @"Duration must be greater than 0");18 NSString *name = [NSString stringWithFormat:@"Scroll %@ by %f", NSStringFromGREYContentEdge(edge), distance];19 self = [super initWithName:name constraints:grey_interactable()];20 if (self) {21 _edge = edge;22 _distance = distance;23 _duration = duration;24 }25 return self;26}27- (BOOL)perform:(id)element error:(__strong NSError **)errorOrNil {28 GREYThrowOnNilParameter(element);29 GREYThrowOnNilParameter(errorOrNil);30 GREYScrollInDirection(element, _edge, _distance, _duration);31 return YES;32}

Full Screen

Full Screen

grey_scrollInDirection

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollInDirection(kGREYDirectionUp, 100)];2+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction3 amount:(CGFloat)amount;4+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction5 amount:(CGFloat)amount {6 scrollStartEdge:kGREYContentEdgeTop];7}8- (instancetype)init NS_UNAVAILABLE;9- (instancetype)initWithDirection:(GREYDirection)direction10 amount:(CGFloat)amount11 scrollStartEdge:(GREYContentEdge)scrollStartEdge12 NS_DESIGNATED_INITIALIZER;13@implementation GREYScrollAction {14 GREYDirection _direction;15 CGFloat _amount;16 GREYContentEdge _scrollStartEdge;17}18- (instancetype)initWithDirection:(GREYDirection)direction19 amount:(CGFloat)amount

Full Screen

Full Screen

grey_scrollInDirection

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@”tableview”)] performAction:grey_scrollInDirection(kGREYDirectionDown, 100)];2+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction3 distance:(CGFloat)distance;4+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction5 distance:(CGFloat)distance;6+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction7 distance:(CGFloat)distance {8 return [GREYScrollAction actionWithDirection:direction distance:distance];9}10- (instancetype)init NS_UNAVAILABLE;11+ (instancetype)actionWithDirection:(GREYDirection)direction distance:(CGFloat)distance;12@implementation GREYScrollAction {13 GREYDirection _direction;14 CGFloat _distance;15}16+ (instancetype)actionWithDirection:(GREYDirection)direction distance:(CGFloat)distance {17 return [[[self class] alloc] initWithDirection:direction distance:distance];18}19- (instancetype)initWithDirection:(GREYDirection)direction distance:(CGFloat)distance {20 NSAssert(distance > 0, @"Distance must be greater than 0");21 NSAssert(direction != kGREYDirectionNone, @"Direction must not be kGREYDirectionNone");22 NSString *name = [NSString stringWithFormat:@"Scroll %@ %g points", NSStringFromGREYDirection(direction), distance];

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful