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

Side by Side Diff: ios/web_view/test/web_view_interaction_test_util.mm

Issue 2892193002: Add unittest to test CWVWebView. (Closed)
Patch Set: Respond to comments. 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 unified diff | Download patch
« no previous file with comments | « ios/web_view/test/web_view_interaction_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/web_view/test/web_view_interaction_test_util.h"
6
7 #import <ChromeWebView/ChromeWebView.h>
8
9 #import "ios/testing/wait_util.h"
10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
15 namespace ios_web_view {
16 namespace test {
17
18 bool TapChromeWebViewElementWithId(CWVWebView* web_view, NSString* element_id) {
19 // TODO(crbug.com/725524): Share this script with Chrome.
20 NSString* script = [NSString
21 stringWithFormat:@"(function() {"
22 " var element = document.getElementById('%@');"
23 " if (element) {"
24 " element.click();"
25 " return true;"
26 " }"
27 " return false;"
28 "})();",
29 element_id];
30 __block bool did_complete = false;
31 __block bool element_found = false;
32 [web_view evaluateJavaScript:script
33 completionHandler:^(id result, NSError*) {
34 did_complete = true;
35 element_found = [result boolValue];
36 }];
37
38 testing::WaitUntilConditionOrTimeout(testing::kWaitForJSCompletionTimeout, ^{
39 return did_complete;
40 });
41
42 return element_found;
43 }
44
45 } // namespace test
46 } // namespace ios_web_view
OLDNEW
« no previous file with comments | « 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