Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: ios/web/shell/test/page_state_egtest.mm

Issue 2637113004: Wait for scroll offset in testScrollPositionRestoring. (Closed)
Patch Set: use condition in egtest Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dd11441d4baa2a30a1f2d26827f22fb95a5d6891..b8e9b09bd9061848768283aaefc37b9a5a4b678a 100644
--- a/ios/web/shell/test/page_state_egtest.mm
+++ b/ios/web/shell/test/page_state_egtest.mm
@@ -47,6 +47,29 @@
nil);
}
+// 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);
+ NSString* name =
+ [NSString stringWithFormat:@"Wait for scroll view to scroll to %@.",
+ content_offset_string];
+ GREYCondition* condition = [GREYCondition
+ conditionWithName:name
+ block:^BOOL {
+ NSError* error = nil;
+ [[EarlGrey
+ selectElementWithMatcher:web::webViewScrollView()]
+ assertWithMatcher:contentOffset(content_offset)
+ error:&error];
+ return (error == nil);
+ }];
+ NSString* error_text =
+ [NSString stringWithFormat:@"Scroll view did not scroll to %@",
+ content_offset_string];
+ GREYAssert([condition waitWithTimeout:10], error_text);
+}
+
} // namespace
using web::test::HttpServer;
@@ -60,10 +83,6 @@ @implementation PageStateTestCase
// Tests that page scroll position of a page is restored upon returning to the
// page via the back/forward buttons.
- (void)testScrollPositionRestoring {
- // TODO(crbug.com/670700): Re-enable this test.
- if (!base::ios::IsRunningOnIOS10OrLater()) {
- EARL_GREY_TEST_DISABLED(@"Test disabled on pre-iOS 10");
- }
web::test::SetUpFileBasedHttpServer();
// Load first URL which is a long page.
@@ -87,12 +106,14 @@ - (void)testScrollPositionRestoring {
// Go back and verify that the first page offset has been restored.
[[EarlGrey selectElementWithMatcher:web::backButton()]
performAction:grey_tap()];
+ WaitForOffset(kScrollOffset1);
[[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
Eugene But (OOO till 7-30) 2017/01/18 18:36:02 Do you still need this?
kkhorimoto 2017/01/18 18:44:47 Nope
assertWithMatcher:contentOffset(CGPointMake(0, kScrollOffset1))];
// Go forward and verify that the second page offset has been restored.
[[EarlGrey selectElementWithMatcher:web::forwardButton()]
performAction:grey_tap()];
+ WaitForOffset(kScrollOffset2);
[[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
Eugene But (OOO till 7-30) 2017/01/18 18:36:01 ditto
kkhorimoto 2017/01/18 18:44:47 Done.
assertWithMatcher:contentOffset(CGPointMake(0, kScrollOffset2))];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698