| 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_interaction_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() { |
| 21 return [[CWVWebView alloc] |
| 22 initWithFrame:UIScreen.mainScreen.bounds |
| 23 configuration:[CWVWebViewConfiguration defaultConfiguration]]; |
| 24 } |
| 25 |
| 20 bool TapChromeWebViewElementWithId(CWVWebView* web_view, NSString* element_id) { | 26 bool TapChromeWebViewElementWithId(CWVWebView* web_view, NSString* element_id) { |
| 21 // TODO(crbug.com/725524): Share this script with Chrome. | 27 // TODO(crbug.com/725524): Share this script with Chrome. |
| 22 NSString* script = [NSString | 28 NSString* script = [NSString |
| 23 stringWithFormat:@"(function() {" | 29 stringWithFormat:@"(function() {" |
| 24 " var element = document.getElementById('%@');" | 30 " var element = document.getElementById('%@');" |
| 25 " if (element) {" | 31 " if (element) {" |
| 26 " element.click();" | 32 " element.click();" |
| 27 " return true;" | 33 " return true;" |
| 28 " }" | 34 " }" |
| 29 " return false;" | 35 " return false;" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 57 NSString* text) { | 63 NSString* text) { |
| 58 return WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ | 64 return WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ |
| 59 id body = ios_web_view::test::EvaluateJavaScript( | 65 id body = ios_web_view::test::EvaluateJavaScript( |
| 60 web_view, @"document.body ? document.body.textContent : null", nil); | 66 web_view, @"document.body ? document.body.textContent : null", nil); |
| 61 return [body isKindOfClass:[NSString class]] && [body containsString:text]; | 67 return [body isKindOfClass:[NSString class]] && [body containsString:text]; |
| 62 }); | 68 }); |
| 63 } | 69 } |
| 64 | 70 |
| 65 } // namespace test | 71 } // namespace test |
| 66 } // namespace ios_web_view | 72 } // namespace ios_web_view |
| OLD | NEW |