| OLD | NEW |
| 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/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "components/strings/grit/components_strings.h" | 8 #include "components/strings/grit/components_strings.h" |
| 9 #include "ios/chrome/browser/ui/ui_util.h" | 9 #include "ios/chrome/browser/ui/ui_util.h" |
| 10 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 10 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 11 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 11 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 12 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 12 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 13 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 13 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 14 #import "ios/testing/earl_grey/disabled_test_macros.h" | 14 #import "ios/testing/earl_grey/disabled_test_macros.h" |
| 15 #import "ios/web/public/test/http_server.h" | 15 #import "ios/web/public/test/http_server.h" |
| 16 #include "ios/web/public/test/http_server_util.h" | 16 #include "ios/web/public/test/http_server_util.h" |
| 17 | 17 |
| 18 using chrome_test_util::BackButton; |
| 19 using chrome_test_util::ForwardButton; |
| 20 |
| 18 namespace { | 21 namespace { |
| 19 | 22 |
| 20 const char* kHistoryTestUrl = | 23 const char* kHistoryTestUrl = |
| 21 "http://ios/testing/data/http_server_files/history.html"; | 24 "http://ios/testing/data/http_server_files/history.html"; |
| 22 const char* kNonPushedUrl = | 25 const char* kNonPushedUrl = |
| 23 "http://ios/testing/data/http_server_files/pony.html"; | 26 "http://ios/testing/data/http_server_files/pony.html"; |
| 24 const char* kReplaceStateHashWithObjectURL = | 27 const char* kReplaceStateHashWithObjectURL = |
| 25 "http://ios/testing/data/http_server_files/history.html#replaceWithObject"; | 28 "http://ios/testing/data/http_server_files/history.html#replaceWithObject"; |
| 26 const char* kPushStateHashStringURL = | 29 const char* kPushStateHashStringURL = |
| 27 "http://ios/testing/data/http_server_files/history.html#string"; | 30 "http://ios/testing/data/http_server_files/history.html#string"; |
| 28 const char* kReplaceStateHashStringURL = | 31 const char* kReplaceStateHashStringURL = |
| 29 "http://ios/testing/data/http_server_files/history.html#replace"; | 32 "http://ios/testing/data/http_server_files/history.html#replace"; |
| 30 const char* kPushStatePathURL = | 33 const char* kPushStatePathURL = |
| 31 "http://ios/testing/data/http_server_files/path"; | 34 "http://ios/testing/data/http_server_files/path"; |
| 32 const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | 35 const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; |
| 33 | 36 |
| 34 // Matcher for the navigate forward button. | |
| 35 id<GREYMatcher> forwardButton() { | |
| 36 return chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_FORWARD); | |
| 37 } | |
| 38 // Matcher for the navigate backward button. | |
| 39 id<GREYMatcher> backButton() { | |
| 40 return chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK); | |
| 41 } | |
| 42 } // namespace | 37 } // namespace |
| 43 | 38 |
| 44 // Tests for pushState/replaceState navigations. | 39 // Tests for pushState/replaceState navigations. |
| 45 @interface PushAndReplaceStateNavigationTestCase : ChromeTestCase | 40 @interface PushAndReplaceStateNavigationTestCase : ChromeTestCase |
| 46 @end | 41 @end |
| 47 | 42 |
| 48 @implementation PushAndReplaceStateNavigationTestCase | 43 @implementation PushAndReplaceStateNavigationTestCase |
| 49 | 44 |
| 50 // Tests calling history.pushState() multiple times and navigating back/forward. | 45 // Tests calling history.pushState() multiple times and navigating back/forward. |
| 51 - (void)testHtml5HistoryPushStateThenGoBackAndForward { | 46 - (void)testHtml5HistoryPushStateThenGoBackAndForward { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 69 withURL:pushStateRootPathURL | 64 withURL:pushStateRootPathURL |
| 70 pageLoaded:NO]; | 65 pageLoaded:NO]; |
| 71 | 66 |
| 72 [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePathSpace"]; | 67 [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePathSpace"]; |
| 73 [self assertStatusText:@"pushStatePathSpace" | 68 [self assertStatusText:@"pushStatePathSpace" |
| 74 withURL:pushStatePathSpaceURL | 69 withURL:pushStatePathSpaceURL |
| 75 pageLoaded:NO]; | 70 pageLoaded:NO]; |
| 76 | 71 |
| 77 // Go back and check that the page doesn't load and the status text is updated | 72 // Go back and check that the page doesn't load and the status text is updated |
| 78 // by the popstate event. | 73 // by the popstate event. |
| 79 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 74 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 80 [self assertStatusText:@"pushStateRootPath" | 75 [self assertStatusText:@"pushStateRootPath" |
| 81 withURL:pushStateRootPathURL | 76 withURL:pushStateRootPathURL |
| 82 pageLoaded:NO]; | 77 pageLoaded:NO]; |
| 83 | 78 |
| 84 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 79 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 85 [self assertStatusText:@"pushStateHashWithObject" | 80 [self assertStatusText:@"pushStateHashWithObject" |
| 86 withURL:pushStateHashWithObjectURL | 81 withURL:pushStateHashWithObjectURL |
| 87 pageLoaded:NO]; | 82 pageLoaded:NO]; |
| 88 | 83 |
| 89 [ChromeEarlGrey tapWebViewElementWithID:@"goBack"]; | 84 [ChromeEarlGrey tapWebViewElementWithID:@"goBack"]; |
| 90 const GURL historyTestURL = web::test::HttpServer::MakeUrl(kHistoryTestUrl); | 85 const GURL historyTestURL = web::test::HttpServer::MakeUrl(kHistoryTestUrl); |
| 91 [self assertStatusText:NULL withURL:historyTestURL pageLoaded:NO]; | 86 [self assertStatusText:NULL withURL:historyTestURL pageLoaded:NO]; |
| 92 | 87 |
| 93 // Go forward 2 pages and check that the page doesn't load and the status text | 88 // Go forward 2 pages and check that the page doesn't load and the status text |
| 94 // is updated by the popstate event. | 89 // is updated by the popstate event. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kHistoryTestUrl)]; | 101 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kHistoryTestUrl)]; |
| 107 | 102 |
| 108 // Replace the URL and go back then forward. | 103 // Replace the URL and go back then forward. |
| 109 const GURL replaceStateHashWithObjectURL = | 104 const GURL replaceStateHashWithObjectURL = |
| 110 web::test::HttpServer::MakeUrl(kReplaceStateHashWithObjectURL); | 105 web::test::HttpServer::MakeUrl(kReplaceStateHashWithObjectURL); |
| 111 [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateHashWithObject"]; | 106 [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateHashWithObject"]; |
| 112 [self assertStatusText:@"replaceStateHashWithObject" | 107 [self assertStatusText:@"replaceStateHashWithObject" |
| 113 withURL:replaceStateHashWithObjectURL | 108 withURL:replaceStateHashWithObjectURL |
| 114 pageLoaded:NO]; | 109 pageLoaded:NO]; |
| 115 | 110 |
| 116 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 111 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 117 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 112 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( |
| 118 initialURL.GetContent())] | 113 initialURL.GetContent())] |
| 119 assertWithMatcher:grey_notNil()]; | 114 assertWithMatcher:grey_notNil()]; |
| 120 | 115 |
| 121 [[EarlGrey selectElementWithMatcher:forwardButton()] | 116 [[EarlGrey selectElementWithMatcher:ForwardButton()] |
| 122 performAction:grey_tap()]; | 117 performAction:grey_tap()]; |
| 123 [self assertStatusText:@"replaceStateHashWithObject" | 118 [self assertStatusText:@"replaceStateHashWithObject" |
| 124 withURL:replaceStateHashWithObjectURL | 119 withURL:replaceStateHashWithObjectURL |
| 125 pageLoaded:YES]; | 120 pageLoaded:YES]; |
| 126 | 121 |
| 127 // Push URL then replace it. Do this twice. | 122 // Push URL then replace it. Do this twice. |
| 128 const GURL pushStateHashStringURL = | 123 const GURL pushStateHashStringURL = |
| 129 web::test::HttpServer::MakeUrl(kPushStateHashStringURL); | 124 web::test::HttpServer::MakeUrl(kPushStateHashStringURL); |
| 130 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; | 125 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; |
| 131 [self assertStatusText:@"pushStateHashString" | 126 [self assertStatusText:@"pushStateHashString" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 147 pageLoaded:NO]; | 142 pageLoaded:NO]; |
| 148 | 143 |
| 149 const GURL replaceStateRootPathSpaceURL = | 144 const GURL replaceStateRootPathSpaceURL = |
| 150 web::test::HttpServer::MakeUrl(kReplaceStateRootPathSpaceURL); | 145 web::test::HttpServer::MakeUrl(kReplaceStateRootPathSpaceURL); |
| 151 [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateRootPathSpace"]; | 146 [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateRootPathSpace"]; |
| 152 [self assertStatusText:@"replaceStateRootPathSpace" | 147 [self assertStatusText:@"replaceStateRootPathSpace" |
| 153 withURL:replaceStateRootPathSpaceURL | 148 withURL:replaceStateRootPathSpaceURL |
| 154 pageLoaded:NO]; | 149 pageLoaded:NO]; |
| 155 | 150 |
| 156 // Go back and check URLs. | 151 // Go back and check URLs. |
| 157 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 152 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 158 [self assertStatusText:@"replaceStateHashString" | 153 [self assertStatusText:@"replaceStateHashString" |
| 159 withURL:replaceStateHashStringURL | 154 withURL:replaceStateHashStringURL |
| 160 pageLoaded:NO]; | 155 pageLoaded:NO]; |
| 161 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 156 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 162 [self assertStatusText:@"replaceStateHashWithObject" | 157 [self assertStatusText:@"replaceStateHashWithObject" |
| 163 withURL:replaceStateHashWithObjectURL | 158 withURL:replaceStateHashWithObjectURL |
| 164 pageLoaded:NO]; | 159 pageLoaded:NO]; |
| 165 | 160 |
| 166 // Go forward and check URL. | 161 // Go forward and check URL. |
| 167 [ChromeEarlGrey tapWebViewElementWithID:@"goForward2"]; | 162 [ChromeEarlGrey tapWebViewElementWithID:@"goForward2"]; |
| 168 [self assertStatusText:@"replaceStateRootPathSpace" | 163 [self assertStatusText:@"replaceStateRootPathSpace" |
| 169 withURL:replaceStateRootPathSpaceURL | 164 withURL:replaceStateRootPathSpaceURL |
| 170 pageLoaded:NO]; | 165 pageLoaded:NO]; |
| 171 } | 166 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 196 [ChromeEarlGrey loadURL:historyTestURL]; | 191 [ChromeEarlGrey loadURL:historyTestURL]; |
| 197 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; | 192 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; |
| 198 [self assertStatusText:@"pushStateHashString" | 193 [self assertStatusText:@"pushStateHashString" |
| 199 withURL:pushStateHashStringURL | 194 withURL:pushStateHashStringURL |
| 200 pageLoaded:NO]; | 195 pageLoaded:NO]; |
| 201 | 196 |
| 202 // At this point the history looks like this: | 197 // At this point the history looks like this: |
| 203 // [NTP, history.html, #string, #string, nonPushedURL, history.html, #string] | 198 // [NTP, history.html, #string, #string, nonPushedURL, history.html, #string] |
| 204 | 199 |
| 205 // Go back (to second history.html) and verify page did not load. | 200 // Go back (to second history.html) and verify page did not load. |
| 206 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 201 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 207 [self assertStatusText:nil withURL:historyTestURL pageLoaded:NO]; | 202 [self assertStatusText:nil withURL:historyTestURL pageLoaded:NO]; |
| 208 | 203 |
| 209 // Go back twice (to second #string) and verify page did load. | 204 // Go back twice (to second #string) and verify page did load. |
| 210 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 205 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 211 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 206 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 212 [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES]; | 207 [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES]; |
| 213 | 208 |
| 214 // Go back once (to first #string) and verify page did not load. | 209 // Go back once (to first #string) and verify page did not load. |
| 215 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 210 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 216 [self assertStatusText:@"pushStateHashString" | 211 [self assertStatusText:@"pushStateHashString" |
| 217 withURL:pushStateHashStringURL | 212 withURL:pushStateHashStringURL |
| 218 pageLoaded:NO]; | 213 pageLoaded:NO]; |
| 219 | 214 |
| 220 // Go forward 4 entries at once (to third #string) and verify page did load. | 215 // Go forward 4 entries at once (to third #string) and verify page did load. |
| 221 [ChromeEarlGrey tapWebViewElementWithID:@"goForward4"]; | 216 [ChromeEarlGrey tapWebViewElementWithID:@"goForward4"]; |
| 222 | 217 |
| 223 [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES]; | 218 [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES]; |
| 224 | 219 |
| 225 // Go back 4 entries at once (to first #string) and verify page did load. | 220 // Go back 4 entries at once (to first #string) and verify page did load. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 243 | 238 |
| 244 web::test::SetUpFileBasedHttpServer(); | 239 web::test::SetUpFileBasedHttpServer(); |
| 245 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kHistoryTestUrl)]; | 240 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kHistoryTestUrl)]; |
| 246 | 241 |
| 247 // TODO(crbug.com/643458): The fact that the URL shows %-escaped is due to | 242 // TODO(crbug.com/643458): The fact that the URL shows %-escaped is due to |
| 248 // NSURL escaping to make UIWebView/JS happy. See if it's possible to | 243 // NSURL escaping to make UIWebView/JS happy. See if it's possible to |
| 249 // represent differently such that it displays unescaped. | 244 // represent differently such that it displays unescaped. |
| 250 // Do 2 push states with unicode characters. | 245 // Do 2 push states with unicode characters. |
| 251 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode"]; | 246 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode"]; |
| 252 [[EarlGrey | 247 [[EarlGrey |
| 253 selectElementWithMatcher:chrome_test_util::omniboxText( | 248 selectElementWithMatcher:chrome_test_util::OmniboxText( |
| 254 pushStateUnicodeURLEncoded.GetContent())] | 249 pushStateUnicodeURLEncoded.GetContent())] |
| 255 assertWithMatcher:grey_notNil()]; | 250 assertWithMatcher:grey_notNil()]; |
| 256 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( | 251 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( |
| 257 pushStateUnicodeLabel)] | 252 pushStateUnicodeLabel)] |
| 258 assertWithMatcher:grey_notNil()]; | 253 assertWithMatcher:grey_notNil()]; |
| 259 | 254 |
| 260 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode2"]; | 255 [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode2"]; |
| 261 [[EarlGrey | 256 [[EarlGrey |
| 262 selectElementWithMatcher:chrome_test_util::omniboxText( | 257 selectElementWithMatcher:chrome_test_util::OmniboxText( |
| 263 pushStateUnicode2URLEncoded.GetContent())] | 258 pushStateUnicode2URLEncoded.GetContent())] |
| 264 assertWithMatcher:grey_notNil()]; | 259 assertWithMatcher:grey_notNil()]; |
| 265 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( | 260 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( |
| 266 pushStateUnicode2Label)] | 261 pushStateUnicode2Label)] |
| 267 assertWithMatcher:grey_notNil()]; | 262 assertWithMatcher:grey_notNil()]; |
| 268 | 263 |
| 269 // Do a push state without a unicode character. | 264 // Do a push state without a unicode character. |
| 270 const GURL pushStatePathURL = | 265 const GURL pushStatePathURL = |
| 271 web::test::HttpServer::MakeUrl(kPushStatePathURL); | 266 web::test::HttpServer::MakeUrl(kPushStatePathURL); |
| 272 [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePath"]; | 267 [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePath"]; |
| 273 | 268 |
| 274 [self assertStatusText:@"pushStatePath" | 269 [self assertStatusText:@"pushStatePath" |
| 275 withURL:pushStatePathURL | 270 withURL:pushStatePathURL |
| 276 pageLoaded:NO]; | 271 pageLoaded:NO]; |
| 277 | 272 |
| 278 // Go back and check the unicode in the URL and status. | 273 // Go back and check the unicode in the URL and status. |
| 279 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 274 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 280 [self assertStatusText:pushStateUnicode2Status | 275 [self assertStatusText:pushStateUnicode2Status |
| 281 withURL:pushStateUnicode2URLEncoded | 276 withURL:pushStateUnicode2URLEncoded |
| 282 pageLoaded:NO]; | 277 pageLoaded:NO]; |
| 283 | 278 |
| 284 [[EarlGrey selectElementWithMatcher:backButton()] performAction:grey_tap()]; | 279 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; |
| 285 [self assertStatusText:pushStateUnicodeStatus | 280 [self assertStatusText:pushStateUnicodeStatus |
| 286 withURL:pushStateUnicodeURLEncoded | 281 withURL:pushStateUnicodeURLEncoded |
| 287 pageLoaded:NO]; | 282 pageLoaded:NO]; |
| 288 } | 283 } |
| 289 | 284 |
| 290 // Tests that pushState/replaceState handling properly handles <base>. | 285 // Tests that pushState/replaceState handling properly handles <base>. |
| 291 - (void)testHtml5HistoryWithBase { | 286 - (void)testHtml5HistoryWithBase { |
| 292 std::map<GURL, std::string> responses; | 287 std::map<GURL, std::string> responses; |
| 293 GURL originURL = | 288 GURL originURL = |
| 294 web::test::HttpServer::MakeUrl("http://foo.com/foo/bar.html"); | 289 web::test::HttpServer::MakeUrl("http://foo.com/foo/bar.html"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 308 "id=\"replaceState\" onclick=\"history.replaceState(" | 303 "id=\"replaceState\" onclick=\"history.replaceState(" |
| 309 "{}, 'Foo', './replaced/relative/url');\"><br>"; | 304 "{}, 'Foo', './replaced/relative/url');\"><br>"; |
| 310 NSString* simplePage = | 305 NSString* simplePage = |
| 311 @"<!doctype html><html><head>%@</head><body>%@</body></html>"; | 306 @"<!doctype html><html><head>%@</head><body>%@</body></html>"; |
| 312 responses[originURL] = base::SysNSStringToUTF8( | 307 responses[originURL] = base::SysNSStringToUTF8( |
| 313 [NSString stringWithFormat:simplePage, baseTag, pushAndReplaceButtons]); | 308 [NSString stringWithFormat:simplePage, baseTag, pushAndReplaceButtons]); |
| 314 web::test::SetUpSimpleHttpServer(responses); | 309 web::test::SetUpSimpleHttpServer(responses); |
| 315 | 310 |
| 316 [ChromeEarlGrey loadURL:originURL]; | 311 [ChromeEarlGrey loadURL:originURL]; |
| 317 [ChromeEarlGrey tapWebViewElementWithID:@"pushState"]; | 312 [ChromeEarlGrey tapWebViewElementWithID:@"pushState"]; |
| 318 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 313 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( |
| 319 pushResultURL.GetContent())] | 314 pushResultURL.GetContent())] |
| 320 assertWithMatcher:grey_notNil()]; | 315 assertWithMatcher:grey_notNil()]; |
| 321 | 316 |
| 322 [ChromeEarlGrey tapWebViewElementWithID:@"replaceState"]; | 317 [ChromeEarlGrey tapWebViewElementWithID:@"replaceState"]; |
| 323 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 318 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( |
| 324 replaceResultURL.GetContent())] | 319 replaceResultURL.GetContent())] |
| 325 assertWithMatcher:grey_notNil()]; | 320 assertWithMatcher:grey_notNil()]; |
| 326 } | 321 } |
| 327 | 322 |
| 328 #pragma mark - Utility methods | 323 #pragma mark - Utility methods |
| 329 | 324 |
| 330 // Assert that status text |status| is displayed in the webview, that "onloaded" | 325 // Assert that status text |status| is displayed in the webview, that "onloaded" |
| 331 // text is displayed if pageLoaded is YES, and that the URL is as expected. | 326 // text is displayed if pageLoaded is YES, and that the URL is as expected. |
| 332 - (void)assertStatusText:(NSString*)status | 327 - (void)assertStatusText:(NSString*)status |
| 333 withURL:(const GURL&)urlToVerify | 328 withURL:(const GURL&)urlToVerify |
| 334 pageLoaded:(BOOL)pageLoaded { | 329 pageLoaded:(BOOL)pageLoaded { |
| 335 id<GREYMatcher> pageLoadedMatcher = | 330 id<GREYMatcher> pageLoadedMatcher = |
| 336 pageLoaded ? chrome_test_util::webViewContainingText("onload") | 331 pageLoaded ? chrome_test_util::WebViewContainingText("onload") |
| 337 : chrome_test_util::webViewNotContainingText("onload"); | 332 : chrome_test_util::WebViewNotContainingText("onload"); |
| 338 [[EarlGrey selectElementWithMatcher:pageLoadedMatcher] | 333 [[EarlGrey selectElementWithMatcher:pageLoadedMatcher] |
| 339 assertWithMatcher:grey_notNil()]; | 334 assertWithMatcher:grey_notNil()]; |
| 340 | 335 |
| 341 if (status != NULL) { | 336 if (status != NULL) { |
| 342 NSString* statusLabel = [NSString stringWithFormat:@"Action: %@", status]; | 337 NSString* statusLabel = [NSString stringWithFormat:@"Action: %@", status]; |
| 343 [[EarlGrey | 338 [[EarlGrey |
| 344 selectElementWithMatcher:chrome_test_util::webViewContainingText( | 339 selectElementWithMatcher:chrome_test_util::WebViewContainingText( |
| 345 base::SysNSStringToUTF8(statusLabel))] | 340 base::SysNSStringToUTF8(statusLabel))] |
| 346 assertWithMatcher:grey_notNil()]; | 341 assertWithMatcher:grey_notNil()]; |
| 347 } | 342 } |
| 348 | 343 |
| 349 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( | 344 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( |
| 350 urlToVerify.GetContent())] | 345 urlToVerify.GetContent())] |
| 351 assertWithMatcher:grey_notNil()]; | 346 assertWithMatcher:grey_notNil()]; |
| 352 } | 347 } |
| 353 | 348 |
| 354 @end | 349 @end |
| OLD | NEW |