Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: ios/web_view/test/web_view_interaction_test_util.mm

Issue 2892193002: Add unittest to test CWVWebView. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/web_view/test/web_view_interaction_test_util.mm
diff --git a/ios/web_view/test/web_view_interaction_test_util.mm b/ios/web_view/test/web_view_interaction_test_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..af929b7c8b492f6f0b8a3accd76c28d8a8d609a7
--- /dev/null
+++ b/ios/web_view/test/web_view_interaction_test_util.mm
@@ -0,0 +1,45 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/web_view/test/web_view_interaction_test_util.h"
+
+#import <ChromeWebView/ChromeWebView.h>
+
+#import "ios/testing/wait_util.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace ios_web_view {
+namespace test {
+
+bool TapChromeWebViewElementWithId(CWVWebView* web_view, NSString* element_id) {
+ NSString* script = [NSString
+ stringWithFormat:@"(function() {"
Eugene But (OOO till 7-30) 2017/05/19 18:39:49 This script already exist somewhere else. Is there
michaeldo 2017/05/23 16:20:52 Unfortunately no at this point. But I will continu
+ " var element = document.getElementById('%@');"
+ " if (element) {"
+ " element.click();"
+ " return true;"
+ " }"
+ " return false;"
+ "})();",
+ element_id];
+ __block bool did_complete = false;
+ __block bool element_found = false;
+ [web_view evaluateJavaScript:script
+ completionHandler:^(id result, NSError*) {
+ did_complete = true;
+ element_found = [result boolValue];
+ }];
+
+ testing::WaitUntilConditionOrTimeout(testing::kWaitForJSCompletionTimeout, ^{
+ return did_complete;
+ });
+
+ return element_found;
+}
+
+} // namespace test
+} // namespace ios_web_view
« ios/web_view/test/test_server.cc ('K') | « ios/web_view/test/web_view_interaction_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698