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

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

Issue 2805573002: Fixed PageStateTest.testScrollPositionRestoring flake. (Closed)
Patch Set: rename function Created 3 years, 8 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 ab9a244f1f4bb00b8a0e0236bbf2bd8d9909064d..08ffddd7d41bd328d969c654925488669099ad98 100644
--- a/ios/web/shell/test/page_state_egtest.mm
+++ b/ios/web/shell/test/page_state_egtest.mm
@@ -53,6 +53,17 @@ void WaitForOffset(CGFloat y_offset) {
GREYAssert([condition waitWithTimeout:10], error_text);
}
+// Loads the long page at |url|, scrolls to the top, and waits for the offset to
+// be {0, 0} before returning.
+void ScrollLongPageToTop(const GURL& url) {
+ // Load the page and swipe down.
+ [ShellEarlGrey loadURL:url];
+ [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
+ performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];
+ // Waits for the {0, 0} offset.
+ WaitForOffset(0.0);
+}
+
} // namespace
using web::test::HttpServer;
@@ -65,24 +76,18 @@ @implementation PageStateTestCase
// Tests that page scroll position of a page is restored upon returning to the
// page via the back/forward buttons.
-// TODO(crbug.com/702410): This test flakily fails when it scrolls too far down
-// the page.
-- (void)FLAKY_testScrollPositionRestoring {
+- (void)testScrollPositionRestoring {
web::test::SetUpFileBasedHttpServer();
- // Load first URL which is a long page.
- [ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage1)];
-
// Scroll the first page and verify the offset.
+ ScrollLongPageToTop(HttpServer::MakeUrl(kLongPage1));
[[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset1)];
[[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
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.
+ ScrollLongPageToTop(HttpServer::MakeUrl(kLongPage2));
[[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset2)];
[[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
« 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