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

Side by Side Diff: ios/chrome/browser/web/forms_egtest.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: mistake 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 unified diff | Download patch
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 <XCTest/XCTest.h> 5 #import <XCTest/XCTest.h>
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "components/strings/grit/components_strings.h" 10 #include "components/strings/grit/components_strings.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 std::unique_ptr<web::DataResponseProvider> provider( 86 std::unique_ptr<web::DataResponseProvider> provider(
87 new HtmlResponseProvider(responses)); 87 new HtmlResponseProvider(responses));
88 web::test::SetUpHttpServer(std::move(provider)); 88 web::test::SetUpHttpServer(std::move(provider));
89 } 89 }
90 90
91 // Submits the html form and verifies the destination url. 91 // Submits the html form and verifies the destination url.
92 - (void)submitForm { 92 - (void)submitForm {
93 chrome_test_util::TapWebViewElementWithId(kSubmitButton); 93 chrome_test_util::TapWebViewElementWithId(kSubmitButton);
94 94
95 GURL url = web::test::HttpServer::MakeUrl(kPrintFormDataUrl); 95 GURL url = web::test::HttpServer::MakeUrl(kPrintFormDataUrl);
96 id<GREYMatcher> URLMatcher = chrome_test_util::omniboxText(url.GetContent()); 96 id<GREYMatcher> URLMatcher = chrome_test_util::OmniboxText(url.GetContent());
97 [[EarlGrey selectElementWithMatcher:URLMatcher] 97 [[EarlGrey selectElementWithMatcher:URLMatcher]
98 assertWithMatcher:grey_notNil()]; 98 assertWithMatcher:grey_notNil()];
99 } 99 }
100 100
101 // Waits for the |expectedResponse| within the web view. 101 // Waits for the |expectedResponse| within the web view.
102 - (void)waitForExpectedResponse:(std::string)expectedResponse { 102 - (void)waitForExpectedResponse:(std::string)expectedResponse {
103 [[GREYCondition 103 [[GREYCondition
104 conditionWithName:@"Waiting for webview to display resulting text." 104 conditionWithName:@"Waiting for webview to display resulting text."
105 block:^BOOL { 105 block:^BOOL {
106 id<GREYMatcher> webViewMatcher = 106 id<GREYMatcher> webViewMatcher =
107 chrome_test_util::webViewContainingText( 107 chrome_test_util::WebViewContainingText(
108 expectedResponse); 108 expectedResponse);
109 NSError* error = nil; 109 NSError* error = nil;
110 [[EarlGrey selectElementWithMatcher:webViewMatcher] 110 [[EarlGrey selectElementWithMatcher:webViewMatcher]
111 assertWithMatcher:grey_notNil() 111 assertWithMatcher:grey_notNil()
112 error:&error]; 112 error:&error];
113 return error == nil; 113 return error == nil;
114 }] waitWithTimeout:5]; 114 }] waitWithTimeout:5];
115 } 115 }
116 116
117 // Waits for view with Tab History accessibility ID. 117 // Waits for view with Tab History accessibility ID.
(...skipping 25 matching lines...) Expand all
143 base::scoped_nsobject<GenericChromeCommand> backCommand( 143 base::scoped_nsobject<GenericChromeCommand> backCommand(
144 [[GenericChromeCommand alloc] initWithTag:IDC_BACK]); 144 [[GenericChromeCommand alloc] initWithTag:IDC_BACK]);
145 chrome_test_util::RunCommandWithActiveViewController(backCommand); 145 chrome_test_util::RunCommandWithActiveViewController(backCommand);
146 146
147 [ChromeEarlGrey waitForPageToFinishLoading]; 147 [ChromeEarlGrey waitForPageToFinishLoading];
148 } 148 }
149 149
150 // Open back navigation history. 150 // Open back navigation history.
151 - (void)openBackHistory { 151 - (void)openBackHistory {
152 id<GREYMatcher> back = 152 id<GREYMatcher> back =
153 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK); 153 chrome_test_util::ButtonWithAccessibilityLabelId(IDS_ACCNAME_BACK);
Eugene But (OOO till 7-30) 2017/01/23 19:39:04 Could you please use existing matcher from chrome_
baxley 2017/01/24 22:18:49 Done.
154 [[EarlGrey selectElementWithMatcher:back] performAction:grey_longPress()]; 154 [[EarlGrey selectElementWithMatcher:back] performAction:grey_longPress()];
155 } 155 }
156 156
157 // Navigates forward to a previous webpage. 157 // Navigates forward to a previous webpage.
158 // TODO(crbug.com/638674): Evaluate if this can move to shared code 158 // TODO(crbug.com/638674): Evaluate if this can move to shared code
159 - (void)goForward { 159 - (void)goForward {
160 base::scoped_nsobject<GenericChromeCommand> forwardCommand( 160 base::scoped_nsobject<GenericChromeCommand> forwardCommand(
161 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]); 161 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]);
162 chrome_test_util::RunCommandWithActiveViewController(forwardCommand); 162 chrome_test_util::RunCommandWithActiveViewController(forwardCommand);
163 163
164 [ChromeEarlGrey waitForPageToFinishLoading]; 164 [ChromeEarlGrey waitForPageToFinishLoading];
165 } 165 }
166 166
167 // Accepts the warning that the form POST data will be resent. 167 // Accepts the warning that the form POST data will be resent.
168 - (void)confirmResendWarning { 168 - (void)confirmResendWarning {
169 id<GREYMatcher> resendWarning = 169 id<GREYMatcher> resendWarning =
170 chrome_test_util::buttonWithAccessibilityLabelId( 170 chrome_test_util::ButtonWithAccessibilityLabelId(
171 IDS_HTTP_POST_WARNING_RESEND); 171 IDS_HTTP_POST_WARNING_RESEND);
172 [[EarlGrey selectElementWithMatcher:resendWarning] 172 [[EarlGrey selectElementWithMatcher:resendWarning]
173 performAction:grey_longPress()]; 173 performAction:grey_longPress()];
174 } 174 }
175 175
176 // Tests whether the request data is resent correctly. 176 // Tests whether the request data is resent correctly.
177 - (void)testFormsResendPostData { 177 - (void)testFormsResendPostData {
178 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)]; 178 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)];
179 179
180 [self submitForm]; 180 [self submitForm];
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 initWithMatchesBlock:^BOOL(UIView* view) { 252 initWithMatchesBlock:^BOOL(UIView* view) {
253 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"]; 253 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"];
254 } 254 }
255 descriptionBlock:^(id<GREYDescription> description) { 255 descriptionBlock:^(id<GREYDescription> description) {
256 [description appendText:@"class prefixed with UIDimmingView"]; 256 [description appendText:@"class prefixed with UIDimmingView"];
257 }]); 257 }]);
258 [[EarlGrey selectElementWithMatcher:matcher] 258 [[EarlGrey selectElementWithMatcher:matcher]
259 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))]; 259 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))];
260 } else { 260 } else {
261 // On handset, dismiss via the cancel button. 261 // On handset, dismiss via the cancel button.
262 [[EarlGrey selectElementWithMatcher:chrome_test_util::cancelButton()] 262 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()]
263 performAction:grey_tap()]; 263 performAction:grey_tap()];
264 } 264 }
265 // Check that the POST is changed to a GET 265 // Check that the POST is changed to a GET
266 [self waitForExpectedResponse:"GET"]; 266 [self waitForExpectedResponse:"GET"];
267 } 267 }
268 268
269 // Tests that a POST followed by a redirect does not show the popup. 269 // Tests that a POST followed by a redirect does not show the popup.
270 - (void)testFormsDontResendPostDataAfterRedirect { 270 - (void)testFormsDontResendPostDataAfterRedirect {
271 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRedirectFormUrl)]; 271 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRedirectFormUrl)];
272 // Submit the form, which redirects before printing the data. 272 // Submit the form, which redirects before printing the data.
273 [self submitForm]; 273 [self submitForm];
274 // Check that the redirect changes the POST to a GET. 274 // Check that the redirect changes the POST to a GET.
275 [self waitForExpectedResponse:"GET"]; 275 [self waitForExpectedResponse:"GET"];
276 [self reloadPage]; 276 [self reloadPage];
277 277
278 // Check that the popup did not show 278 // Check that the popup did not show
279 id<GREYMatcher> resendWarning = 279 id<GREYMatcher> resendWarning =
280 chrome_test_util::buttonWithAccessibilityLabelId( 280 chrome_test_util::ButtonWithAccessibilityLabelId(
281 IDS_HTTP_POST_WARNING_RESEND); 281 IDS_HTTP_POST_WARNING_RESEND);
282 [[EarlGrey selectElementWithMatcher:resendWarning] 282 [[EarlGrey selectElementWithMatcher:resendWarning]
283 assertWithMatcher:grey_nil()]; 283 assertWithMatcher:grey_nil()];
284 284
285 [self waitForExpectedResponse:"GET"]; 285 [self waitForExpectedResponse:"GET"];
286 } 286 }
287 287
288 @end 288 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698