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

Unified Diff: ios/web/public/test/web_view_content_test_util.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: review comments Created 3 years, 6 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
« no previous file with comments | « ios/web/public/test/web_view_content_test_util.h ('k') | ios/web/shell/test/context_menu_egtest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/public/test/web_view_content_test_util.mm
diff --git a/ios/web/public/test/web_view_content_test_util.mm b/ios/web/public/test/web_view_content_test_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..dfbf57a9002d1efcda3a9c6138eca0ba830b766e
--- /dev/null
+++ b/ios/web/public/test/web_view_content_test_util.mm
@@ -0,0 +1,32 @@
+// 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/public/test/web_view_content_test_util.h"
+
+#import <Foundation/Foundation.h>
+
+#import "ios/web/public/test/web_view_interaction_test_util.h"
+
+namespace {
+// Script that returns document.body as a string.
+char kGetDocumentBodyJavaScript[] =
+ "document.body ? document.body.textContent : null";
+}
+
+namespace web {
+namespace test {
+
+bool IsWebViewContainingText(web::WebState* web_state,
+ const std::string& text) {
+ std::unique_ptr<base::Value> value =
+ web::test::ExecuteJavaScript(web_state, kGetDocumentBodyJavaScript);
+ std::string body;
+ if (value && value->GetAsString(&body)) {
+ return body.find(text) != std::string::npos;
+ }
+ return false;
+}
+
+} // namespace test
+} // namespace web
« no previous file with comments | « ios/web/public/test/web_view_content_test_util.h ('k') | ios/web/shell/test/context_menu_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698