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

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

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: better formatting Created 3 years, 8 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/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..850cf76c47482337e017bf96b89818f36577db8e
--- /dev/null
+++ b/ios/web/public/test/web_view_content_test_util.mm
@@ -0,0 +1,31 @@
+// 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 WebViewContainingText(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

Powered by Google App Engine
This is Rietveld 408576698