| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | 5 #import "ios/web/public/test/earl_grey/web_view_matchers.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #include "base/mac/bind_objc_block.h" | 9 #include "base/mac/bind_objc_block.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/test/ios/wait_util.h" | 12 #include "base/test/ios/wait_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "ios/testing/earl_grey/wait_util.h" | 14 #include "ios/testing/earl_grey/wait_util.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Script that returns document.body as a string. | 18 // Script that returns document.body as a string. |
| 19 char kGetDocumentBodyJavaScript[] = | 19 char kGetDocumentBodyJavaScript[] = |
| 20 "document.body ? document.body.textContent : null"; | 20 "document.body ? document.body.textContent : null"; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace web { | 23 namespace web { |
| 24 | 24 |
| 25 id<GREYMatcher> webViewContainingText(NSString* text, web::WebState* webState) { | |
| 26 return [GREYMatchers | |
| 27 matcherForWebViewContainingText:base::SysNSStringToUTF8(text) | |
| 28 inWebState:webState]; | |
| 29 } | |
| 30 | |
| 31 id<GREYMatcher> webViewContainingText(const std::string& text, | 25 id<GREYMatcher> webViewContainingText(const std::string& text, |
| 32 web::WebState* webState) { | 26 web::WebState* webState) { |
| 33 return | 27 return |
| 34 [GREYMatchers matcherForWebViewContainingText:text inWebState:webState]; | 28 [GREYMatchers matcherForWebViewContainingText:text inWebState:webState]; |
| 35 } | 29 } |
| 36 | 30 |
| 37 } // namespace web | 31 } // namespace web |
| 38 | 32 |
| 39 @implementation GREYMatchers (WebViewAdditions) | 33 @implementation GREYMatchers (WebViewAdditions) |
| 40 | 34 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 [description appendText:@"web view containing "]; | 66 [description appendText:@"web view containing "]; |
| 73 [description appendText:base::SysUTF8ToNSString(text)]; | 67 [description appendText:base::SysUTF8ToNSString(text)]; |
| 74 }; | 68 }; |
| 75 | 69 |
| 76 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches | 70 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
| 77 descriptionBlock:describe] | 71 descriptionBlock:describe] |
| 78 autorelease]; | 72 autorelease]; |
| 79 } | 73 } |
| 80 | 74 |
| 81 @end | 75 @end |
| OLD | NEW |