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

Side by Side Diff: ios/web/shell/test/page_state_egtest.mm

Issue 2805573002: Fixed PageStateTest.testScrollPositionRestoring flake. (Closed)
Patch Set: baxley's comments 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <CoreGraphics/CoreGraphics.h> 5 #import <CoreGraphics/CoreGraphics.h>
6 #import <EarlGrey/EarlGrey.h> 6 #import <EarlGrey/EarlGrey.h>
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #import <XCTest/XCTest.h> 8 #import <XCTest/XCTest.h>
9 9
10 #include "base/ios/ios_util.h" 10 #include "base/ios/ios_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 assertWithMatcher:grey_scrollViewContentOffset(offset) 46 assertWithMatcher:grey_scrollViewContentOffset(offset)
47 error:&error]; 47 error:&error];
48 return (error == nil); 48 return (error == nil);
49 }]; 49 }];
50 NSString* error_text = 50 NSString* error_text =
51 [NSString stringWithFormat:@"Scroll view did not scroll to %@", 51 [NSString stringWithFormat:@"Scroll view did not scroll to %@",
52 content_offset_string]; 52 content_offset_string];
53 GREYAssert([condition waitWithTimeout:10], error_text); 53 GREYAssert([condition waitWithTimeout:10], error_text);
54 } 54 }
55 55
56 // Loads the long page at |url|, scrolls to the top, and waits for the offset to
57 // be {0, 0} before returning.
58 void LoadLongPageAndScrollToTop(const GURL& url) {
Eugene But (OOO till 7-30) 2017/04/19 22:48:27 "And" word in a method name is kind of a red flag.
kkhorimoto 2017/04/19 23:43:10 Done.
59 // Load the page and swipe down.
60 [ShellEarlGrey loadURL:url];
61 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
62 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];
63 // Waits for the {0, 0} offset.
64 WaitForOffset(0.0);
65 }
66
56 } // namespace 67 } // namespace
57 68
58 using web::test::HttpServer; 69 using web::test::HttpServer;
59 70
60 // Page state test cases for the web shell. 71 // Page state test cases for the web shell.
61 @interface PageStateTestCase : WebShellTestCase 72 @interface PageStateTestCase : WebShellTestCase
62 @end 73 @end
63 74
64 @implementation PageStateTestCase 75 @implementation PageStateTestCase
65 76
66 // Tests that page scroll position of a page is restored upon returning to the 77 // Tests that page scroll position of a page is restored upon returning to the
67 // page via the back/forward buttons. 78 // page via the back/forward buttons.
68 // TODO(crbug.com/702410): This test flakily fails when it scrolls too far down 79 - (void)testScrollPositionRestoring {
69 // the page.
70 - (void)FLAKY_testScrollPositionRestoring {
71 web::test::SetUpFileBasedHttpServer(); 80 web::test::SetUpFileBasedHttpServer();
72 81
73 // Load first URL which is a long page.
74 [ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage1)];
75
76 // Scroll the first page and verify the offset. 82 // Scroll the first page and verify the offset.
83 LoadLongPageAndScrollToTop(HttpServer::MakeUrl(kLongPage1));
77 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()] 84 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
78 performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset1)]; 85 performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset1)];
79 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()] 86 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
80 assertWithMatcher:grey_scrollViewContentOffset(CGPointMake(0, kOffset1))]; 87 assertWithMatcher:grey_scrollViewContentOffset(CGPointMake(0, kOffset1))];
81 88
82 // Load second URL, which is also a long page.
83 [ShellEarlGrey loadURL:HttpServer::MakeUrl(kLongPage2)];
84
85 // Scroll the second page and verify the offset. 89 // Scroll the second page and verify the offset.
90 LoadLongPageAndScrollToTop(HttpServer::MakeUrl(kLongPage2));
86 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()] 91 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
87 performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset2)]; 92 performAction:grey_scrollInDirection(kGREYDirectionDown, kOffset2)];
88 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()] 93 [[EarlGrey selectElementWithMatcher:web::WebViewScrollView()]
89 assertWithMatcher:grey_scrollViewContentOffset(CGPointMake(0, kOffset2))]; 94 assertWithMatcher:grey_scrollViewContentOffset(CGPointMake(0, kOffset2))];
90 95
91 // Go back and verify that the first page offset has been restored. 96 // Go back and verify that the first page offset has been restored.
92 [[EarlGrey selectElementWithMatcher:web::BackButton()] 97 [[EarlGrey selectElementWithMatcher:web::BackButton()]
93 performAction:grey_tap()]; 98 performAction:grey_tap()];
94 WaitForOffset(kOffset1); 99 WaitForOffset(kOffset1);
95 100
96 // Go forward and verify that the second page offset has been restored. 101 // Go forward and verify that the second page offset has been restored.
97 [[EarlGrey selectElementWithMatcher:web::ForwardButton()] 102 [[EarlGrey selectElementWithMatcher:web::ForwardButton()]
98 performAction:grey_tap()]; 103 performAction:grey_tap()];
99 WaitForOffset(kOffset2); 104 WaitForOffset(kOffset2);
100 } 105 }
101 106
102 @end 107 @end
OLDNEW
« 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