Chromium Code Reviews| 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 <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 #import <WebKit/WebKit.h> | 6 #import <WebKit/WebKit.h> |
| 7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
| 8 | 8 |
| 9 #import <EarlGrey/EarlGrey.h> | 9 #import <EarlGrey/EarlGrey.h> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 [super tearDown]; | 46 [super tearDown]; |
| 47 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); | 47 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); |
| 48 server.RemoveAllResponseProviders(); | 48 server.RemoveAllResponseProviders(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Tests the back and forward button after entering two URLs. | 51 // Tests the back and forward button after entering two URLs. |
| 52 - (void)testWebScenarioBrowsingBackAndForward { | 52 - (void)testWebScenarioBrowsingBackAndForward { |
| 53 // Create map of canned responses and set up the test HTML server. | 53 // Create map of canned responses and set up the test HTML server. |
| 54 std::map<GURL, std::string> responses; | 54 std::map<GURL, std::string> responses; |
| 55 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL"); | 55 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL"); |
| 56 NSString* URL1Text = base::SysUTF8ToNSString(URL1.spec()); | |
| 56 NSString* response1 = @"Test Page 1"; | 57 NSString* response1 = @"Test Page 1"; |
| 57 responses[URL1] = base::SysNSStringToUTF8(response1); | 58 responses[URL1] = base::SysNSStringToUTF8(response1); |
| 58 | 59 |
| 59 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL"); | 60 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL"); |
| 61 NSString* URL2Text = base::SysUTF8ToNSString(URL2.spec()); | |
| 60 NSString* response2 = @"Test Page 2"; | 62 NSString* response2 = @"Test Page 2"; |
| 61 responses[URL2] = base::SysNSStringToUTF8(response2); | 63 responses[URL2] = base::SysNSStringToUTF8(response2); |
| 62 | 64 |
| 63 web::test::SetUpSimpleHttpServer(responses); | 65 web::test::SetUpSimpleHttpServer(responses); |
| 64 | 66 |
| 65 web::WebState* webState = web::web_shell_test_util::GetCurrentWebState(); | 67 web::WebState* webState = web::web_shell_test_util::GetCurrentWebState(); |
| 66 | 68 |
| 67 web::navigation_test_util::LoadUrl(webState, URL1); | 69 web::navigation_test_util::LoadUrl(webState, URL1); |
| 68 | 70 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1Text)] |
|
Eugene But (OOO till 7-30)
2016/05/09 15:59:08
Can be changed later.
Sounds like your matcher sh
baxley
2016/05/09 17:11:43
Okay, I'll wait. I don't know if there's a case wh
| |
| 71 assertWithMatcher:grey_notNil()]; | |
| 69 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] | 72 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] |
| 70 assertWithMatcher:grey_notNil()]; | 73 assertWithMatcher:grey_notNil()]; |
| 71 | 74 |
| 72 web::navigation_test_util::LoadUrl(webState, URL2); | 75 web::navigation_test_util::LoadUrl(webState, URL2); |
| 73 | 76 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2Text)] |
| 77 assertWithMatcher:grey_notNil()]; | |
| 74 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] | 78 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] |
| 75 assertWithMatcher:grey_notNil()]; | 79 assertWithMatcher:grey_notNil()]; |
| 76 | 80 |
| 77 [[EarlGrey selectElementWithMatcher:web::backButton()] | 81 [[EarlGrey selectElementWithMatcher:web::backButton()] |
| 78 performAction:grey_tap()]; | 82 performAction:grey_tap()]; |
| 79 | 83 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1Text)] |
| 84 assertWithMatcher:grey_notNil()]; | |
| 80 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] | 85 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] |
| 81 assertWithMatcher:grey_notNil()]; | 86 assertWithMatcher:grey_notNil()]; |
| 82 | 87 |
| 83 [[EarlGrey selectElementWithMatcher:web::forwardButton()] | 88 [[EarlGrey selectElementWithMatcher:web::forwardButton()] |
| 84 performAction:grey_tap()]; | 89 performAction:grey_tap()]; |
| 85 | 90 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2Text)] |
| 91 assertWithMatcher:grey_notNil()]; | |
| 86 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] | 92 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] |
| 87 assertWithMatcher:grey_notNil()]; | 93 assertWithMatcher:grey_notNil()]; |
| 88 } | 94 } |
| 89 | 95 |
| 90 @end | 96 @end |
| OLD | NEW |