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

Side by Side 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 unified diff | Download patch
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/public/test/web_view_content_test_util.h"
6
7 #import <Foundation/Foundation.h>
8
9 #import "ios/web/public/test/web_view_interaction_test_util.h"
10
11 namespace {
12 // Script that returns document.body as a string.
13 char kGetDocumentBodyJavaScript[] =
14 "document.body ? document.body.textContent : null";
15 }
16
17 namespace web {
18 namespace test {
19
20 bool WebViewContainingText(web::WebState* web_state, const std::string& text) {
21 std::unique_ptr<base::Value> value =
22 web::test::ExecuteJavaScript(web_state, kGetDocumentBodyJavaScript);
23 std::string body;
24 if (value && value->GetAsString(&body)) {
25 return body.find(text) != std::string::npos;
26 }
27 return false;
28 }
29
30 } // namespace test
31 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698