| 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 #ifndef IOS_WEB_VIEW_TEST_WEB_VIEW_TEST_UTIL_H_ | 5 #ifndef IOS_WEB_VIEW_TEST_WEB_VIEW_TEST_UTIL_H_ |
| 6 #define IOS_WEB_VIEW_TEST_WEB_VIEW_TEST_UTIL_H_ | 6 #define IOS_WEB_VIEW_TEST_WEB_VIEW_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" |
| 11 |
| 10 @class CWVWebView; | 12 @class CWVWebView; |
| 11 | 13 |
| 12 namespace ios_web_view { | 14 namespace ios_web_view { |
| 13 namespace test { | 15 namespace test { |
| 14 | 16 |
| 15 // Creates web view with default configuration and frame equal to screen bounds. | 17 // Creates web view with default configuration and frame equal to screen bounds. |
| 16 CWVWebView* CreateWebView(); | 18 CWVWebView* CreateWebView() WARN_UNUSED_RESULT; |
| 19 |
| 20 // Loads |URL| in |web_view| and waits until the load completes. Asserts if |
| 21 // loading does not complete. |
| 22 bool LoadUrl(CWVWebView* web_view, NSURL* url) WARN_UNUSED_RESULT; |
| 17 | 23 |
| 18 // Returns whether the element with |element_id| in the passed |web_view| has | 24 // Returns whether the element with |element_id| in the passed |web_view| has |
| 19 // been tapped using a JavaScript click() event. | 25 // been tapped using a JavaScript click() event. |
| 20 bool TapChromeWebViewElementWithId(CWVWebView* web_view, NSString* element_id); | 26 bool TapWebViewElementWithId(CWVWebView* web_view, |
| 27 NSString* element_id) WARN_UNUSED_RESULT; |
| 21 | 28 |
| 22 // Waits until |script| is executed and synchronously returns the evaluation | 29 // Waits until |script| is executed and synchronously returns the evaluation |
| 23 // result. | 30 // result. |
| 24 id EvaluateJavaScript(CWVWebView* web_view, NSString* script, NSError** error); | 31 id EvaluateJavaScript(CWVWebView* web_view, NSString* script, NSError** error); |
| 25 | 32 |
| 26 // Waits for |web_view| to contain |text|. Returns false if the condition is not | 33 // Waits for |web_view| to contain |text|. Returns false if the condition is not |
| 27 // met within a timeout. | 34 // met within a timeout. |
| 28 bool WaitForWebViewContainingTextOrTimeout(CWVWebView* web_view, | 35 bool WaitForWebViewContainingTextOrTimeout(CWVWebView* web_view, |
| 29 NSString* text); | 36 NSString* text) WARN_UNUSED_RESULT; |
| 37 |
| 38 // Waits until |web_view| stops loading. Returns false if the condition is not |
| 39 // met within a timeout. |
| 40 bool WaitForWebViewLoadCompletionOrTimeout(CWVWebView* web_view) |
| 41 WARN_UNUSED_RESULT; |
| 30 | 42 |
| 31 } // namespace test | 43 } // namespace test |
| 32 } // namespace ios_web_view | 44 } // namespace ios_web_view |
| 33 | 45 |
| 34 #endif // IOS_WEB_VIEW_TEST_WEB_VIEW_TEST_UTIL_H_ | 46 #endif // IOS_WEB_VIEW_TEST_WEB_VIEW_TEST_UTIL_H_ |
| OLD | NEW |