How to use grey_scrollToContentEdge method of performAction class

Best EarlGrey code snippet using performAction.grey_scrollToContentEdge

FTRScrollViewTest.m

Source:FTRScrollViewTest.m Github

copy

Full Screen

...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)];...

Full Screen

Full Screen

ScrollViewTest.m

Source:ScrollViewTest.m Github

copy

Full Screen

...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)];...

Full Screen

Full Screen

FTRUITableViewTest.m

Source:FTRUITableViewTest.m Github

copy

Full Screen

...56 [[self ftr_scrollToCellAtIndex:20 byScrollingInAmounts:200 InDirection:kGREYDirectionDown]57 assertWithMatcher:grey_notNil()];58 // Scroll to top and verify that we are at the top.59 [[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]60 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)]61 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];62}63- (void)testScrollToTopWithPositiveInsets {64 // Add positive insets using this format {top,left,bottom,right}65 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets value")]66 performAction:grey_typeText(@"{100,0,0,0}\n")];67 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]68 performAction:grey_turnSwitchOn(YES)];69 // Scroll down.70 [[self ftr_scrollToCellAtIndex:20 byScrollingInAmounts:200 InDirection:kGREYDirectionDown]71 assertWithMatcher:grey_notNil()];72 // Scroll to top and verify that we are at the top.73 [[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]74 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)]75 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];76}77- (void)testScrollToTopWithNegativeInsets {78 // Add negative insets using this format {top,left,bottom,right}79 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets value")]80 performAction:grey_typeText(@"{-100,0,0,0}\n")];81 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]82 performAction:grey_turnSwitchOn(YES)];83 // Scroll down.84 [[self ftr_scrollToCellAtIndex:20 byScrollingInAmounts:200 InDirection:kGREYDirectionDown]85 assertWithMatcher:grey_notNil()];86 // Scroll to top and verify that we are at the top.87 [[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]88 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)]89 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];90}91- (void)testScrollToTopWhenAlreadyAtTheTopWithoutBounce {92 GREYActionBlock *bounceOff =93 [[GREYActionBlock alloc] initWithName:@"toggleBounces"94 constraints:grey_kindOfClass([UIScrollView class])95 performBlock:^BOOL(UIScrollView *scrollView,96 NSError *__strong *error) {97 GREYAssertTrue(scrollView.bounces, @"Bounce must be set or this test is same as "98 @"testScrollToTopWhenAlreadyAtTheTopWithBounce");99 scrollView.bounces = NO;100 return YES;101 }];102 // Verify this test with and without bounce enabled by toggling it.103 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]104 performAction:bounceOff];105 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]106 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];107 // Verify that top most cell is visible.108 [[EarlGrey selectElementWithMatcher:[self ftr_matcherForCellAtIndex:0]]109 assertWithMatcher:grey_sufficientlyVisible()];110}111- (void)testScrollToTopWhenAlreadyAtTheTopWithBounce {112 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]113 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];114 // Verify that top most cell is visible.115 [[EarlGrey selectElementWithMatcher:[self ftr_matcherForCellAtIndex:0]]116 assertWithMatcher:grey_sufficientlyVisible()];117}118- (void)testTableViewVisibleWhenScrolled {119 [[[[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]120 assertWithMatcher:grey_sufficientlyVisible()]121 performAction:grey_swipeFastInDirection(kGREYDirectionUp)]122 performAction:grey_swipeFastInDirection(kGREYDirectionUp)]123 assertWithMatcher:grey_sufficientlyVisible()];124}125- (void)testFrameworkSynchronizesWithScrolling {126 MatchesBlock matchesNotScrolling = ^BOOL(UIScrollView *element) {127 return !element.dragging && !element.decelerating;...

Full Screen

Full Screen

UITableViewTest.m

Source:UITableViewTest.m Github

copy

Full Screen

...55 [[self ftr_scrollToCellAtIndex:20 byScrollingInAmounts:20056 InDirection:kGREYDirectionDown] assertWithMatcher:grey_notNil()];57 // Scroll to top and verify that we are at the top.58 [[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]59 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)]60 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];61}62- (void)testScrollToTopWithPositiveInsets {63 // Add positive insets using this format {top,left,bottom,right}64 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets value")]65 performAction:grey_typeText(@"{100,0,0,0}\n")];66 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]67 performAction:grey_turnSwitchOn(YES)];68 // Scroll down.69 [[self ftr_scrollToCellAtIndex:20 byScrollingInAmounts:20070 InDirection:kGREYDirectionDown] assertWithMatcher:grey_notNil()];71 // Scroll to top and verify that we are at the top.72 [[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]73 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)]74 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];75}76- (void)testScrollToTopWithNegativeInsets {77 // Add negative insets using this format {top,left,bottom,right}78 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets value")]79 performAction:grey_typeText(@"{-100,0,0,0}\n")];80 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"insets toggle")]81 performAction:grey_turnSwitchOn(YES)];82 // Scroll down.83 [[self ftr_scrollToCellAtIndex:20 byScrollingInAmounts:20084 InDirection:kGREYDirectionDown] assertWithMatcher:grey_notNil()];85 // Scroll to top and verify that we are at the top.86 [[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]87 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)]88 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];89}90- (void)testScrollToTopWhenAlreadyAtTheTopWithoutBounce {91 id<GREYAction> bounceOff =92 [GREYHostApplicationDistantObject.sharedInstance actionForTableViewBoundOff];93 // Verify this test with and without bounce enabled by toggling it.94 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]95 performAction:bounceOff];96 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]97 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];98 // Verify that top most cell is visible.99 [[EarlGrey selectElementWithMatcher:[self ftr_matcherForCellAtIndex:0]]100 assertWithMatcher:grey_sufficientlyVisible()];101}102- (void)testScrollToTopWhenAlreadyAtTheTopWithBounce {103 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]104 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];105 // Verify that top most cell is visible.106 [[EarlGrey selectElementWithMatcher:[self ftr_matcherForCellAtIndex:0]]107 assertWithMatcher:grey_sufficientlyVisible()];108}109- (void)testTableViewVisibleWhenScrolled {110 [[[[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"main_table_view")]111 assertWithMatcher:grey_sufficientlyVisible()]112 performAction:grey_swipeFastInDirection(kGREYDirectionUp)]113 performAction:grey_swipeFastInDirection(kGREYDirectionUp)]114 assertWithMatcher:grey_sufficientlyVisible()];115}116- (void)testFrameworkSynchronizesWithScrolling {117 id<GREYMatcher> notScrollingMatcher =118 [GREYHostApplicationDistantObject.sharedInstance matcherForNotScrolling];...

Full Screen

Full Screen

SnackbarInteractionTests.m

Source:SnackbarInteractionTests.m Github

copy

Full Screen

...23 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"back_bar_button")]24 performAction:grey_tap()];25 // Scroll to the top of the main screen26 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"collectionView")]27 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];28}29- (void)testSliding {30 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"collectionView")]31 performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];32 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Snackbar")] performAction:grey_tap()];33 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"CellDemo")] performAction:grey_tap()];34 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Simple Snackbar")]35 performAction:grey_tap()];36 [SnackbarEarlGreyTests returnToMainScreen];37}38@end...

Full Screen

Full Screen

grey_scrollToContentEdge

Using AI Code Generation

copy

Full Screen

1GREYElementInteraction *interaction = [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 200) onElementWithMatcher:grey_kindOfClass([UIScrollView class])];2[interaction performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];3- (id)perform:(id)element error:(__strong NSError **)errorOrNil {4 if (![element isKindOfClass:[UIScrollView class]]) {5 NSStringFromClass([element class])];6 GREYPopulateErrorNotedOrLog(errorOrNil, kGREYInteractionErrorDomain,7 kGREYInteractionActionFailedErrorCode, reason);8 return nil;9 }10 UIScrollView *scrollView = (UIScrollView *)element;11 return [self grey_scrollToContentEdge:scrollView error:errorOrNil];12}13- (id)grey_scrollToContentEdge:(UIScrollView *)scrollView error:(__strong NSError **)errorOrNil {14 CGPoint contentOffset = [self grey_contentOffsetForEdge:scrollView];15 [scrollView setContentOffset:contentOffset animated:YES];16 return scrollView;17}18- (CGPoint)grey_contentOffsetForEdge:(UIScrollView *)scrollView {19 CGPoint contentOffset = CGPointZero;20 switch (_edge) {21 contentOffset = CGPointMake(0, -scrollView.contentInset.top);22 break;23 CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height +24 scrollView.contentInset.bottom);25 break;26 contentOffset = CGPointMake(-scrollView.contentInset.left, 0);27 break;28 CGPointMake(scrollView.contentSize.width - scrollView.bounds.size.width +29 0);

Full Screen

Full Screen

grey_scrollToContentEdge

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"id")] performAction:grey_scrollToContentEdge(GREYContentEdgeTop)];2+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge;3+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge {4 return [GREYActionBlock actionWithName:[NSString stringWithFormat:@"Scroll to %@", GREYStringFromContentEdge(edge)]5 constraints:grey_respondsToSelector(@selector(scrollView))6 performBlock:^BOOL(id element, __strong NSError *__strong *errorOrNil) {7 UIScrollView *scrollView = (UIScrollView *)element;8 CGPoint contentOffset = scrollView.contentOffset;9 CGRect contentFrame = scrollView.bounds;10 contentFrame.origin = contentOffset;11 toView:scrollView.superview];12 toView:scrollView.superview];13 CGFloat distance = 0;14 switch (edge) {15 distance = CGRectGetMinY(elementRect) - CGRectGetMinY(visibleRect);16 break;17 distance = CGRectGetMinX(elementRect) - CGRectGetMinX(visibleRect);18 break;19 distance = CGRectGetMaxY(visibleRect) - CGRectGetMaxY(elementRect);20 break;21 distance = CGRectGetMaxX(visibleRect) - CGRectGetMaxX(elementRect);22 break;23 }24 if (distance <= 0) {25 return YES;26 }27 contentOffset.y += distance;28 [scrollView setContentOffset:contentOffset animated:YES];29 return YES;30 }];31}32NSString *GREYStringFromContentEdge(GREYContentEdge edge);33NSString *GREYStringFromContentEdge(GREYContentEdge edge) {34 switch (edge) {

Full Screen

Full Screen

grey_scrollToContentEdge

Using AI Code Generation

copy

Full Screen

1[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-ScrollViews")]2 .usingSearchAction(grey_scrollToContentEdge(GREYContentEdgeTop), grey_swipeFastInDirection(kGREYDirectionUp))3 .performAction();4[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-ScrollViews")]5 .usingSearchAction(grey_scrollInDirection(kGREYDirectionUp, 200), grey_swipeFastInDirection(kGREYDirectionUp))6 .performAction();7[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-ScrollViews")]8 .usingSearchAction(grey_scrollToContentEdge(GREYContentEdgeTop), grey_swipeFastInDirection(kGREYDirectionUp))9 .performAction();10[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-ScrollViews")]11 .usingSearchAction(grey_scrollToContentEdge(GREYContentEdgeTop), grey_swipeFastInDirection(kGREYDirectionUp))12 .performAction();13[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-ScrollViews")]14 .usingSearchAction(grey_scrollToContentEdge(GREYContentEdgeTop), grey_swipeFastInDirection(kGREYDirectionUp))15 .performAction();16[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-ScrollViews")]17 .usingSearchAction(grey_scrollToContentEdge(GREYContentEdgeTop), grey_swipeFastInDirection(kGREYDirectionUp))18 .performAction();19[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-ScrollViews")]20 .usingSearchAction(grey_scrollToContentEdge(GREYContentEdgeTop), grey_swipeFastInDirection(kGREYDirectionUp))21 .performAction();

Full Screen

Full Screen

grey_scrollToContentEdge

Using AI Code Generation

copy

Full Screen

1#define GREY_SCROLL_TO_EDGE(edge) [GREYActions grey_scrollToContentEdge:edge]2#define GREY_SCROLL_TO_EDGE_IN_DIRECTION(edge, direction) [GREYActions grey_scrollToContentEdge:edge inDirection:direction]3#define GREY_SCROLL_IN_DIRECTION(direction, amount) [GREYActions grey_scrollInDirection:direction amount:amount]4+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge;5+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge6 inDirection:(GREYDirection)direction;7+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction8 amount:(CGFloat)amount;9#import "GREYActions.h"10#import "GREYActionBlock.h"11#import "GREYElementInteraction.h"12+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge {13 return [self grey_scrollToContentEdge:edge inDirection:kGREYDirectionDown];14}15+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge16 inDirection:(GREYDirection)direction {17 constraints:grey_kindOfClass([UIScrollView class])18 performBlock:^BOOL(UIScrollView *element, NSError *__strong *errorOrNil) {19 return [element grey_scrollToContentEdge:edge inDirection:direction];20 }];21}22+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction23 amount:(CGFloat)amount {24 constraints:grey_kindOfClass([UIScrollView class])25 performBlock:^BOOL(UIScrollView *element, NSError *__strong *errorOrNil) {26 return [element grey_scrollInDirection:direction amount:amount];27 }];28}

Full Screen

Full Screen

grey_scrollToContentEdge

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"ScrollToEdge")]2 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];3+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge;4+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge {5 constraints:grey_not(grey_systemAlertViewShown())6 performBlock:^BOOL (id element, NSError *__strong *errorOrNil) {7 UIScrollView *scrollView = nil;8 if ([element isKindOfClass:[UIScrollView class]]) {9 scrollView = element;10 } else if ([element isKindOfClass:[UIWebView class]]) {11 scrollView = [(UIWebView *)element scrollView];12 } else {13 element];14 NSDictionary *glossary = @{kErrorDetailElementKey : element};15 GREYPopulateErrorNotedOrLog(errorOrNil,16 glossary);17 return NO;18 }19 CGPoint contentOffset = scrollView.contentOffset;20 switch (edge) {21 contentOffset.y = -scrollView.contentInset.top;22 break;23 scrollView.contentInset.bottom;24 break;25 contentOffset.x = -scrollView.contentInset.left;26 break;27 scrollView.contentInset.right;28 break;29 }30 [scrollView setContentOffset:contentOffset animated:YES];31 return YES;32 }];33}34typedef NS_ENUM(NSInteger, GREYContentEdge) {35};36+ (id<

Full Screen

Full Screen

grey_scrollToContentEdge

Using AI Code Generation

copy

Full Screen

1if (grey_scrollToContentEdge(UIGestureRecognizerDirectionLeft)) {2 NSLog(@"Scrolled to left edge");3} else {4 NSLog(@"Couldn't scroll to left edge");5}6+ (id)grey_scrollToContentEdge:(UIGestureRecognizerDirection)direction {7 constraints:grey_interactable()8 performBlock:^BOOL (id element, __strong NSError **errorOrNil) {9 if (![element isKindOfClass:[UIScrollView class]]) {10 NSString *errorDescription = @"Element is not a UIScrollView";11 *errorOrNil = GREYErrorMake(kGREYInteractionErrorDomain,12 errorDescription);13 return NO;14 }15 UIScrollView *scrollView = (UIScrollView *)element;16 CGPoint contentOffset = scrollView.contentOffset;17 CGSize contentSize = scrollView.contentSize;18 CGSize frameSize = scrollView.frame.size;19 switch (direction) {20 contentOffset.x = -scrollView.contentInset.left;21 break;22 contentOffset.x = contentSize.width - frameSize.width + scrollView.contentInset.right;23 break;24 contentOffset.y = -scrollView.contentInset.top;25 break;26 contentOffset.y = contentSize.height - frameSize.height + scrollView.contentInset.bottom;27 break;28 break;29 }30 [scrollView setContentOffset:contentOffset animated:YES];31 return YES;32 }];33}34#define GREY_SCROLL_TO_EDGE(edge) [GREYActions grey_scrollToContentEdge:edge]35#define GREY_SCROLL_TO_EDGE_IN_DIRECTION(edge, direction) [GREYActions grey_scrollToContentEdge:edge inDirection:direction]36#define GREY_SCROLL_IN_DIRECTION(direction, amount) [GREYActions grey_scrollInDirection:direction amount:amount]37+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge;38+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge39 inDirection:(GREYDirection)direction;40+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction41 amount:(CGFloat)amount;42#import "GREYActions.h"43#import "GREYActionBlock.h"44#import "GREYElementInteraction.h"45+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge {46 return [self grey_scrollToContentEdge:edge inDirection:kGREYDirectionDown];47}48+ (id<GREYAction>)grey_scrollToContentEdge:(GREYContentEdge)edge49 inDirection:(GREYDirection)direction {50 constraints:grey_kindOfClass([UIScrollView class])51 performBlock:^BOOL(UIScrollView *element, NSError *__strong *errorOrNil) {52 return [element grey_scrollToContentEdge:edge inDirection:direction];53 }];54}55+ (id<GREYAction>)grey_scrollInDirection:(GREYDirection)direction56 amount:(CGFloat)amount {57 constraints:grey_kindOfClass([UIScrollView class])58 performBlock:^BOOL(UIScrollView *element, NSError *__strong *errorOrNil) {59 return [element grey_scrollInDirection:direction amount:amount];60 }];61}

Full Screen

Full Screen

grey_scrollToContentEdge

Using AI Code Generation

copy

Full Screen

1if (grey_scrollToContentEdge(UIGestureRecognizerDirectionLeft)) {2 NSLog(@"Scrolled to left edge");3} else {4 NSLog(@"Couldn't scroll to left edge");5}6+ (id)grey_scrollToContentEdge:(UIGestureRecognizerDirection)direction {7 constraints:grey_interactable()8 performBlock:^BOOL (id element, __strong NSError **errorOrNil) {9 if (![element isKindOfClass:[UIScrollView class]]) {10 NSString *errorDescription = @"Element is not a UIScrollView";11 *errorOrNil = GREYErrorMake(kGREYInteractionErrorDomain,12 errorDescription);13 return NO;14 }15 UIScrollView *scrollView = (UIScrollView *)element;16 CGPoint contentOffset = scrollView.contentOffset;17 CGSize contentSize = scrollView.contentSize;18 CGSize frameSize = scrollView.frame.size;19 switch (direction) {20 contentOffset.x = -scrollView.contentInset.left;21 break;22 contentOffset.x = contentSize.width - frameSize.width + scrollView.contentInset.right;23 break;24 contentOffset.y = -scrollView.contentInset.top;25 break;26 contentOffset.y = contentSize.height - frameSize.height + scrollView.contentInset.bottom;27 break;28 break;29 }30 [scrollView setContentOffset:contentOffset animated:YES];31 return YES;32 }];33}

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