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 | |
25 CWVWebView* CreateWebView() { | 20 CWVWebView* CreateWebView() { |
26 return CreateWebView([CWVWebViewConfiguration defaultConfiguration]); | 21 return [[CWVWebView alloc] |
| 22 initWithFrame:UIScreen.mainScreen.bounds |
| 23 configuration:[CWVWebViewConfiguration defaultConfiguration]]; |
27 } | 24 } |
28 | 25 |
29 bool LoadUrl(CWVWebView* web_view, NSURL* url) { | 26 bool LoadUrl(CWVWebView* web_view, NSURL* url) { |
30 [web_view loadRequest:[NSURLRequest requestWithURL:url]]; | 27 [web_view loadRequest:[NSURLRequest requestWithURL:url]]; |
31 | 28 |
32 return WaitForWebViewLoadCompletionOrTimeout(web_view); | 29 return WaitForWebViewLoadCompletionOrTimeout(web_view); |
33 } | 30 } |
34 | 31 |
35 bool TapWebViewElementWithId(CWVWebView* web_view, NSString* element_id) { | 32 bool TapWebViewElementWithId(CWVWebView* web_view, NSString* element_id) { |
36 // TODO(crbug.com/725524): Share this script with Chrome. | 33 // TODO(crbug.com/725524): Share this script with Chrome. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 75 } |
79 | 76 |
80 bool WaitForWebViewLoadCompletionOrTimeout(CWVWebView* web_view) { | 77 bool WaitForWebViewLoadCompletionOrTimeout(CWVWebView* web_view) { |
81 return WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{ | 78 return WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{ |
82 return !web_view.loading; | 79 return !web_view.loading; |
83 }); | 80 }); |
84 } | 81 } |
85 | 82 |
86 } // namespace test | 83 } // namespace test |
87 } // namespace ios_web_view | 84 } // namespace ios_web_view |
OLD | NEW |