| Index: ios/web/shell/test/page_state_egtest.mm
|
| diff --git a/ios/web/shell/test/page_state_egtest.mm b/ios/web/shell/test/page_state_egtest.mm
|
| index a0d11aaead0a638aa75b5a7d6edc7a5021e3e99f..7c3e1e0c352c09810394e500309782952ccd3704 100644
|
| --- a/ios/web/shell/test/page_state_egtest.mm
|
| +++ b/ios/web/shell/test/page_state_egtest.mm
|
| @@ -28,29 +28,13 @@ const char kLongPage2[] =
|
| "http://ios/web/shell/test/http_server_files/tall_page.html?2";
|
|
|
| // Test scroll offsets.
|
| -const CGFloat kScrollOffset1 = 20.0f;
|
| -const CGFloat kScrollOffset2 = 40.0f;
|
| -
|
| -// Returns a matcher for asserting that element's content offset matches the
|
| -// given |offset|.
|
| -id<GREYMatcher> ContentOffset(CGPoint offset) {
|
| - MatchesBlock matches = ^BOOL(UIScrollView* element) {
|
| - return CGPointEqualToPoint([element contentOffset], offset);
|
| - };
|
| - DescribeToBlock describe = ^(id<GREYDescription> description) {
|
| - [description appendText:@"contentOffset"];
|
| - };
|
| - return grey_allOf(
|
| - grey_kindOfClass([UIScrollView class]),
|
| - [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
|
| - descriptionBlock:describe],
|
| - nil);
|
| -}
|
| +const CGFloat kOffset1 = 20.0f;
|
| +const CGFloat kOffset2 = 40.0f;
|
|
|
| // Waits for the web view scroll view is scrolled to |y_offset|.
|
| void WaitForOffset(CGFloat y_offset) {
|
| - CGPoint content_offset = CGPointMake(0.0, y_offset);
|
| - NSString* content_offset_string = NSStringFromCGPoint(content_offset);
|
| + CGPoint offset = CGPointMake(0.0, y_offset);
|
| + NSString* content_offset_string = NSStringFromCGPoint(offset);
|
| NSString* name =
|
| [NSString stringWithFormat:@"Wait for scroll view to scroll to %@.",
|
| content_offset_string];
|
| @@ -60,7 +44,7 @@ void WaitForOffset(CGFloat y_offset) {
|
| NSError* error = nil;
|
| [[EarlGrey
|
| selectElementWithMatcher:web::WebViewScrollView()]
|
| - assertWithMatcher:ContentOffset(content_offset)
|
| + assertWithMatcher:grey_scrollViewContentOffset(offset)
|
| error:&error];
|
| return (error == nil);
|
| }];
|
| @@ -90,28 +74,28 @@ using web::test::HttpServer;
|
|
|
| // Scroll the first page and verify the offset.
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| - performAction:grey_scrollInDirection(kGREYDirectionDown, kScrollOffset1)];
|
| + performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset1)];
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| - assertWithMatcher:ContentOffset(CGPointMake(0, kScrollOffset1))];
|
| + assertWithMatcher:grey_scrollViewContentOffset(CGPointMake(0, kOffset1))];
|
|
|
| // Load second URL, which is also a long page.
|
| [ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage2)];
|
|
|
| // Scroll the second page and verify the offset.
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| - performAction:grey_scrollInDirection(kGREYDirectionDown, kScrollOffset2)];
|
| + performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset2)];
|
| [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
|
| - assertWithMatcher:ContentOffset(CGPointMake(0, kScrollOffset2))];
|
| + assertWithMatcher:grey_scrollViewContentOffset(CGPointMake(0, kOffset2))];
|
|
|
| // Go back and verify that the first page offset has been restored.
|
| [[EarlGrey selectElementWithMatcher:web::BackButton()]
|
| performAction:grey_tap()];
|
| - WaitForOffset(kScrollOffset1);
|
| + WaitForOffset(kOffset1);
|
|
|
| // Go forward and verify that the second page offset has been restored.
|
| [[EarlGrey selectElementWithMatcher:web::ForwardButton()]
|
| performAction:grey_tap()];
|
| - WaitForOffset(kScrollOffset2);
|
| + WaitForOffset(kOffset2);
|
| }
|
|
|
| @end
|
|
|