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

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

Issue 2173543002: [ios] Removed web_shell_ prefix from EG tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged Created 4 years, 4 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 | « ios/web/shell/test/web_shell_navigation_egtest.mm ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <CoreGraphics/CoreGraphics.h>
6 #import <EarlGrey/EarlGrey.h>
7 #import <Foundation/Foundation.h>
8 #import <XCTest/XCTest.h>
9
10 #import "ios/web/public/test/http_server.h"
11 #include "ios/web/public/test/http_server_util.h"
12 #include "ios/web/shell/test/app/navigation_test_util.h"
13 #import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
14 #import "ios/web/shell/test/earl_grey/shell_matchers.h"
15
16 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support."
18 #endif
19
20 namespace {
21
22 // URLs for test pages.
23 const char kLongPage1[] =
24 "http://ios/web/shell/test/http_server_files/tall_page.html";
25 const char kLongPage2[] =
26 "http://ios/web/shell/test/http_server_files/tall_page.html?2";
27
28 // Test scroll offsets.
29 const CGFloat kScrollOffset1 = 20.0f;
30 const CGFloat kScrollOffset2 = 40.0f;
31
32 // Returns a matcher for asserting that element's content offset matches the
33 // given |offset|.
34 id<GREYMatcher> contentOffset(CGPoint offset) {
35 MatchesBlock matches = ^BOOL(UIScrollView* element) {
36 return CGPointEqualToPoint([element contentOffset], offset);
37 };
38 DescribeToBlock describe = ^(id<GREYDescription> description) {
39 [description appendText:@"contentOffset"];
40 };
41 return grey_allOf(
42 grey_kindOfClass([UIScrollView class]),
43 [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
44 descriptionBlock:describe],
45 nil);
46 }
47
48 } // namespace
49
50 using web::shell_test_util::LoadUrl;
51 using web::test::HttpServer;
52 using web::webViewContainingText;
53
54 // Page state test cases for the web shell.
55 @interface CRWWebShellPageStateTest : ShellBaseTestCase
56
57 @end
58
59 @implementation CRWWebShellPageStateTest
60
61 // Tests that page scroll position of a page is restored upon returning to the
62 // page via the back/forward buttons.
63 - (void)testScrollPositionRestoring {
64 web::test::SetUpFileBasedHttpServer();
65
66 // Load first URL which is a long page.
67 LoadUrl(HttpServer::MakeUrl(kLongPage1));
68 // TODO(crbug.com/629116): Remove this once |LoadUrl| waits for the load
69 // completion.
70 [[EarlGrey selectElementWithMatcher:webViewContainingText("List of numbers")]
71 assertWithMatcher:grey_notNil()];
72
73 // Scroll the first page and verify the offset.
74 [[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
75 performAction:grey_scrollInDirection(kGREYDirectionDown, kScrollOffset1)];
76 [[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
77 assertWithMatcher:contentOffset(CGPointMake(0, kScrollOffset1))];
78
79 // Load second URL, which is also a long page.
80 GURL URL2 = HttpServer::MakeUrl(kLongPage2);
81 LoadUrl(URL2);
82 // TODO(crbug.com/629116): Remove these once |LoadUrl| waits for the load
83 // completion.
84 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2.spec())]
85 assertWithMatcher:grey_notNil()];
86 [[EarlGrey selectElementWithMatcher:webViewContainingText("List of numbers")]
87 assertWithMatcher:grey_notNil()];
88
89 // Scroll the second page and verify the offset.
90 [[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
91 performAction:grey_scrollInDirection(kGREYDirectionDown, kScrollOffset2)];
92 [[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
93 assertWithMatcher:contentOffset(CGPointMake(0, kScrollOffset2))];
94
95 // Go back and verify that the first page offset has been restored.
96 [[EarlGrey selectElementWithMatcher:web::backButton()]
97 performAction:grey_tap()];
98 [[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
99 assertWithMatcher:contentOffset(CGPointMake(0, kScrollOffset1))];
100
101 // Go forward and verify that the second page offset has been restored.
102 [[EarlGrey selectElementWithMatcher:web::forwardButton()]
103 performAction:grey_tap()];
104 [[EarlGrey selectElementWithMatcher:web::webViewScrollView()]
105 assertWithMatcher:contentOffset(CGPointMake(0, kScrollOffset2))];
106 }
107
108 @end
OLDNEW
« no previous file with comments | « ios/web/shell/test/web_shell_navigation_egtest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698