| 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 <EarlGrey/EarlGrey.h> | 5 #import <EarlGrey/EarlGrey.h> |
| 6 #import <UIKit/UIKit.h> | 6 #import <UIKit/UIKit.h> |
| 7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
| 8 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/mac/bind_objc_block.h" | 10 #include "base/mac/bind_objc_block.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 21 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 22 #import "ios/chrome/test/earl_grey/chrome_util.h" | 22 #import "ios/chrome/test/earl_grey/chrome_util.h" |
| 23 #import "ios/testing/wait_util.h" | 23 #import "ios/testing/wait_util.h" |
| 24 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | 24 #import "ios/web/public/test/earl_grey/web_view_matchers.h" |
| 25 #import "ios/web/public/test/http_server.h" | 25 #import "ios/web/public/test/http_server.h" |
| 26 #import "ios/web/public/test/http_server_util.h" | 26 #import "ios/web/public/test/http_server_util.h" |
| 27 #import "ios/web/public/test/response_providers/error_page_response_provider.h" | 27 #import "ios/web/public/test/response_providers/error_page_response_provider.h" |
| 28 #import "ios/web/public/test/web_view_interaction_test_util.h" | 28 #import "ios/web/public/test/web_view_interaction_test_util.h" |
| 29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 30 | 30 |
| 31 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 32 #error "This file requires ARC support." |
| 33 #endif |
| 34 |
| 31 namespace { | 35 namespace { |
| 32 | 36 |
| 33 // TODO(crbug.com/638674): Move this to a shared location as it is a duplicate | 37 // TODO(crbug.com/638674): Move this to a shared location as it is a duplicate |
| 34 // of ios/web/shell/test/page_state_egtest.mm. | 38 // of ios/web/shell/test/page_state_egtest.mm. |
| 35 // Returns a matcher for asserting that element's content offset matches the | 39 // Returns a matcher for asserting that element's content offset matches the |
| 36 // given |offset|. | 40 // given |offset|. |
| 37 id<GREYMatcher> ContentOffset(CGPoint offset) { | 41 id<GREYMatcher> ContentOffset(CGPoint offset) { |
| 38 MatchesBlock matches = ^BOOL(UIScrollView* element) { | 42 MatchesBlock matches = ^BOOL(UIScrollView* element) { |
| 39 return CGPointEqualToPoint([element contentOffset], offset); | 43 return CGPointEqualToPoint([element contentOffset], offset); |
| 40 }; | 44 }; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 " if (metas[i].getAttribute('name') == 'viewport') {" | 177 " if (metas[i].getAttribute('name') == 'viewport') {" |
| 174 " metas[i].setAttribute('content', 'width=10');" | 178 " metas[i].setAttribute('content', 'width=10');" |
| 175 " return;" | 179 " return;" |
| 176 " }" | 180 " }" |
| 177 "}" | 181 "}" |
| 178 "document.body.innerHTML += \"<meta name='viewport' content='width=10'>\"" | 182 "document.body.innerHTML += \"<meta name='viewport' content='width=10'>\"" |
| 179 "})()"; | 183 "})()"; |
| 180 | 184 |
| 181 __block bool finished = false; | 185 __block bool finished = false; |
| 182 chrome_test_util::GetCurrentWebState()->ExecuteJavaScript( | 186 chrome_test_util::GetCurrentWebState()->ExecuteJavaScript( |
| 183 base::UTF8ToUTF16(script), base::BindBlock(^(const base::Value*) { | 187 base::UTF8ToUTF16(script), base::BindBlockArc(^(const base::Value*) { |
| 184 finished = true; | 188 finished = true; |
| 185 })); | 189 })); |
| 186 | 190 |
| 187 GREYAssert(testing::WaitUntilConditionOrTimeout(1.0, | 191 GREYAssert(testing::WaitUntilConditionOrTimeout(1.0, |
| 188 ^{ | 192 ^{ |
| 189 return finished; | 193 return finished; |
| 190 }), | 194 }), |
| 191 @"JavaScript to hide the toolbar did not complete"); | 195 @"JavaScript to hide the toolbar did not complete"); |
| 192 | 196 |
| 193 // Scroll up to be sure the toolbar can be dismissed by scrolling down. | 197 // Scroll up to be sure the toolbar can be dismissed by scrolling down. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 [ChromeEarlGrey loadURL:URL]; | 406 [ChromeEarlGrey loadURL:URL]; |
| 403 HideToolbarUsingUI(); | 407 HideToolbarUsingUI(); |
| 404 chrome_test_util::AssertToolbarNotVisible(); | 408 chrome_test_util::AssertToolbarNotVisible(); |
| 405 | 409 |
| 406 chrome_test_util::TapWebViewElementWithId("link"); | 410 chrome_test_util::TapWebViewElementWithId("link"); |
| 407 AssertURLIs(ErrorPageResponseProvider::GetDnsFailureUrl()); | 411 AssertURLIs(ErrorPageResponseProvider::GetDnsFailureUrl()); |
| 408 chrome_test_util::AssertToolbarVisible(); | 412 chrome_test_util::AssertToolbarVisible(); |
| 409 } | 413 } |
| 410 | 414 |
| 411 @end | 415 @end |
| OLD | NEW |