| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ios/web_view/test/web_view_test_util.h" | 5 #import "ios/web_view/test/web_view_test_util.h" |
| 6 | 6 |
| 7 #import <ChromeWebView/ChromeWebView.h> | 7 #import <ChromeWebView/ChromeWebView.h> |
| 8 | 8 |
| 9 #import "ios/testing/wait_util.h" | 9 #import "ios/testing/wait_util.h" |
| 10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 using testing::WaitUntilConditionOrTimeout; | 15 using testing::WaitUntilConditionOrTimeout; |
| 16 | 16 |
| 17 namespace ios_web_view { | 17 namespace ios_web_view { |
| 18 namespace test { | 18 namespace test { |
| 19 | 19 |
| 20 CWVWebView* CreateWebView(CWVWebViewConfiguration* configuration) { |
| 21 return [[CWVWebView alloc] initWithFrame:UIScreen.mainScreen.bounds |
| 22 configuration:configuration]; |
| 23 } |
| 24 |
| 20 CWVWebView* CreateWebView() { | 25 CWVWebView* CreateWebView() { |
| 21 return [[CWVWebView alloc] | 26 return CreateWebView([CWVWebViewConfiguration defaultConfiguration]); |
| 22 initWithFrame:UIScreen.mainScreen.bounds | |
| 23 configuration:[CWVWebViewConfiguration defaultConfiguration]]; | |
| 24 } | 27 } |
| 25 | 28 |
| 26 bool LoadUrl(CWVWebView* web_view, NSURL* url) { | 29 bool LoadUrl(CWVWebView* web_view, NSURL* url) { |
| 27 [web_view loadRequest:[NSURLRequest requestWithURL:url]]; | 30 [web_view loadRequest:[NSURLRequest requestWithURL:url]]; |
| 28 | 31 |
| 29 return WaitForWebViewLoadCompletionOrTimeout(web_view); | 32 return WaitForWebViewLoadCompletionOrTimeout(web_view); |
| 30 } | 33 } |
| 31 | 34 |
| 32 bool TapWebViewElementWithId(CWVWebView* web_view, NSString* element_id) { | 35 bool TapWebViewElementWithId(CWVWebView* web_view, NSString* element_id) { |
| 33 // TODO(crbug.com/725524): Share this script with Chrome. | 36 // TODO(crbug.com/725524): Share this script with Chrome. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 78 } |
| 76 | 79 |
| 77 bool WaitForWebViewLoadCompletionOrTimeout(CWVWebView* web_view) { | 80 bool WaitForWebViewLoadCompletionOrTimeout(CWVWebView* web_view) { |
| 78 return WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{ | 81 return WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{ |
| 79 return !web_view.loading; | 82 return !web_view.loading; |
| 80 }); | 83 }); |
| 81 } | 84 } |
| 82 | 85 |
| 83 } // namespace test | 86 } // namespace test |
| 84 } // namespace ios_web_view | 87 } // namespace ios_web_view |
| OLD | NEW |