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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 assertWithMatcher:grey_notNil()]; | 62 assertWithMatcher:grey_notNil()]; |
| 63 | 63 |
| 64 web::shell_test_util::TapWebViewElementWithId( | 64 web::shell_test_util::TapWebViewElementWithId( |
| 65 "basic-link-navigation-to-about-blank"); | 65 "basic-link-navigation-to-about-blank"); |
| 66 | 66 |
| 67 [[EarlGrey selectElementWithMatcher:web::addressFieldText(@"about:blank")] | 67 [[EarlGrey selectElementWithMatcher:web::addressFieldText(@"about:blank")] |
| 68 assertWithMatcher:grey_notNil()]; | 68 assertWithMatcher:grey_notNil()]; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Tests the back and forward button after entering two URLs. | 71 // Tests the back and forward button after entering two URLs. |
| 72 - (void)testWebScenarioBrowsingBackAndForward { | 72 - (void)testNavigationBackAndForward { |
| 73 // Create map of canned responses and set up the test HTML server. | 73 // Create map of canned responses and set up the test HTML server. |
| 74 std::map<GURL, std::string> responses; | 74 std::map<GURL, std::string> responses; |
| 75 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL"); | 75 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL"); |
| 76 NSString* URL1Text = base::SysUTF8ToNSString(URL1.spec()); | 76 NSString* URL1Text = base::SysUTF8ToNSString(URL1.spec()); |
| 77 NSString* response1 = @"Test Page 1"; | 77 NSString* response1 = @"Test Page 1"; |
| 78 responses[URL1] = base::SysNSStringToUTF8(response1); | 78 responses[URL1] = base::SysNSStringToUTF8(response1); |
| 79 | 79 |
| 80 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL"); | 80 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL"); |
| 81 NSString* URL2Text = base::SysUTF8ToNSString(URL2.spec()); | 81 NSString* URL2Text = base::SysUTF8ToNSString(URL2.spec()); |
| 82 NSString* response2 = @"Test Page 2"; | 82 NSString* response2 = @"Test Page 2"; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 104 assertWithMatcher:grey_notNil()]; | 104 assertWithMatcher:grey_notNil()]; |
| 105 | 105 |
| 106 [[EarlGrey selectElementWithMatcher:web::forwardButton()] | 106 [[EarlGrey selectElementWithMatcher:web::forwardButton()] |
| 107 performAction:grey_tap()]; | 107 performAction:grey_tap()]; |
| 108 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2Text)] | 108 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2Text)] |
| 109 assertWithMatcher:grey_notNil()]; | 109 assertWithMatcher:grey_notNil()]; |
| 110 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] | 110 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] |
| 111 assertWithMatcher:grey_notNil()]; | 111 assertWithMatcher:grey_notNil()]; |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Tests back and forward navigation where a fragment link is tapped. | |
| 115 - (void)testNavigationBackAndForwardAfterFragmentLink { | |
| 116 // Create map of canned responses and set up the test HTML server. | |
| 117 std::map<GURL, std::string> responses; | |
| 118 const GURL URL1 = web::test::HttpServer::MakeUrl("http://fragmentLink"); | |
| 119 NSString* URL1Text = base::SysUTF8ToNSString(URL1.spec()); | |
| 120 const std::string response = "<a href=\"#hash\" id=\"link\">link</a>"; | |
|
Eugene But (OOO till 7-30)
2016/05/23 20:21:58
Optional NIT: s/\"/'
baxley
2016/05/23 21:18:02
Done.
| |
| 121 responses[URL1] = response; | |
| 122 | |
| 123 const GURL URL2 = web::test::HttpServer::MakeUrl("http://fragmentLink/#hash"); | |
| 124 NSString* URL2Text = base::SysUTF8ToNSString(URL2.spec()); | |
| 125 | |
| 126 web::test::SetUpSimpleHttpServer(responses); | |
| 127 | |
| 128 web::shell_test_util::LoadUrl(URL1); | |
| 129 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1Text)] | |
|
Eugene But (OOO till 7-30)
2016/05/23 20:21:58
Suggestion for the future:
Should |addressFieldTe
baxley
2016/05/23 21:18:02
That sounds reasonable. I was hesitant since the c
| |
| 130 assertWithMatcher:grey_notNil()]; | |
| 131 | |
| 132 web::shell_test_util::TapWebViewElementWithId("link"); | |
| 133 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2Text)] | |
| 134 assertWithMatcher:grey_notNil()]; | |
| 135 | |
| 136 [[EarlGrey selectElementWithMatcher:web::backButton()] | |
| 137 performAction:grey_tap()]; | |
| 138 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL1Text)] | |
| 139 assertWithMatcher:grey_notNil()]; | |
| 140 | |
| 141 [[EarlGrey selectElementWithMatcher:web::forwardButton()] | |
| 142 performAction:grey_tap()]; | |
| 143 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL2Text)] | |
| 144 assertWithMatcher:grey_notNil()]; | |
| 145 } | |
| 146 | |
| 114 @end | 147 @end |
| OLD | NEW |