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

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

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: build.gn and rebase 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 24 matching lines...) Expand all
142 - (void)goBack { 142 - (void)goBack {
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 [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
153 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK); 153 performAction:grey_longPress()];
154 [[EarlGrey selectElementWithMatcher:back] performAction:grey_longPress()];
155 } 154 }
156 155
157 // Navigates forward to a previous webpage. 156 // Navigates forward to a previous webpage.
158 // TODO(crbug.com/638674): Evaluate if this can move to shared code 157 // TODO(crbug.com/638674): Evaluate if this can move to shared code
159 - (void)goForward { 158 - (void)goForward {
160 base::scoped_nsobject<GenericChromeCommand> forwardCommand( 159 base::scoped_nsobject<GenericChromeCommand> forwardCommand(
161 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]); 160 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]);
162 chrome_test_util::RunCommandWithActiveViewController(forwardCommand); 161 chrome_test_util::RunCommandWithActiveViewController(forwardCommand);
163 162
164 [ChromeEarlGrey waitForPageToFinishLoading]; 163 [ChromeEarlGrey waitForPageToFinishLoading];
165 } 164 }
166 165
167 // Accepts the warning that the form POST data will be resent. 166 // Accepts the warning that the form POST data will be resent.
168 - (void)confirmResendWarning { 167 - (void)confirmResendWarning {
169 id<GREYMatcher> resendWarning = 168 id<GREYMatcher> resendWarning =
170 chrome_test_util::buttonWithAccessibilityLabelId( 169 chrome_test_util::ButtonWithAccessibilityLabelId(
171 IDS_HTTP_POST_WARNING_RESEND); 170 IDS_HTTP_POST_WARNING_RESEND);
172 [[EarlGrey selectElementWithMatcher:resendWarning] 171 [[EarlGrey selectElementWithMatcher:resendWarning]
173 performAction:grey_longPress()]; 172 performAction:grey_longPress()];
174 } 173 }
175 174
176 // Tests whether the request data is resent correctly. 175 // Tests whether the request data is resent correctly.
177 - (void)testFormsResendPostData { 176 - (void)testFormsResendPostData {
178 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)]; 177 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFormUrl)];
179 178
180 [self submitForm]; 179 [self submitForm];
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 initWithMatchesBlock:^BOOL(UIView* view) { 251 initWithMatchesBlock:^BOOL(UIView* view) {
253 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"]; 252 return [NSStringFromClass([view class]) hasPrefix:@"UIDimmingView"];
254 } 253 }
255 descriptionBlock:^(id<GREYDescription> description) { 254 descriptionBlock:^(id<GREYDescription> description) {
256 [description appendText:@"class prefixed with UIDimmingView"]; 255 [description appendText:@"class prefixed with UIDimmingView"];
257 }]); 256 }]);
258 [[EarlGrey selectElementWithMatcher:matcher] 257 [[EarlGrey selectElementWithMatcher:matcher]
259 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))]; 258 performAction:grey_tapAtPoint(CGPointMake(50.0f, 50.0f))];
260 } else { 259 } else {
261 // On handset, dismiss via the cancel button. 260 // On handset, dismiss via the cancel button.
262 [[EarlGrey selectElementWithMatcher:chrome_test_util::cancelButton()] 261 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()]
263 performAction:grey_tap()]; 262 performAction:grey_tap()];
264 } 263 }
265 // Check that the POST is changed to a GET 264 // Check that the POST is changed to a GET
266 [self waitForExpectedResponse:"GET"]; 265 [self waitForExpectedResponse:"GET"];
267 } 266 }
268 267
269 // Tests that a POST followed by a redirect does not show the popup. 268 // Tests that a POST followed by a redirect does not show the popup.
270 - (void)testFormsDontResendPostDataAfterRedirect { 269 - (void)testFormsDontResendPostDataAfterRedirect {
271 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRedirectFormUrl)]; 270 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRedirectFormUrl)];
272 // Submit the form, which redirects before printing the data. 271 // Submit the form, which redirects before printing the data.
273 [self submitForm]; 272 [self submitForm];
274 // Check that the redirect changes the POST to a GET. 273 // Check that the redirect changes the POST to a GET.
275 [self waitForExpectedResponse:"GET"]; 274 [self waitForExpectedResponse:"GET"];
276 [self reloadPage]; 275 [self reloadPage];
277 276
278 // Check that the popup did not show 277 // Check that the popup did not show
279 id<GREYMatcher> resendWarning = 278 id<GREYMatcher> resendWarning =
280 chrome_test_util::buttonWithAccessibilityLabelId( 279 chrome_test_util::ButtonWithAccessibilityLabelId(
281 IDS_HTTP_POST_WARNING_RESEND); 280 IDS_HTTP_POST_WARNING_RESEND);
282 [[EarlGrey selectElementWithMatcher:resendWarning] 281 [[EarlGrey selectElementWithMatcher:resendWarning]
283 assertWithMatcher:grey_nil()]; 282 assertWithMatcher:grey_nil()];
284 283
285 [self waitForExpectedResponse:"GET"]; 284 [self waitForExpectedResponse:"GET"];
286 } 285 }
287 286
288 @end 287 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/child_window_open_by_dom_egtest.mm ('k') | ios/chrome/browser/web/http_auth_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698