Index: ios/chrome/test/earl_grey/chrome_matchers.mm |
diff --git a/ios/chrome/test/earl_grey/chrome_matchers.mm b/ios/chrome/test/earl_grey/chrome_matchers.mm |
index c9aa5e426c40446b9905a82ffd69db0894fba2db..3f34db1aaf735aa929d1a746ef054230a999d67c 100644 |
--- a/ios/chrome/test/earl_grey/chrome_matchers.mm |
+++ b/ios/chrome/test/earl_grey/chrome_matchers.mm |
@@ -222,4 +222,20 @@ id<GREYMatcher> SettingsMenuBackButton() { |
grey_accessibilityTrait(UIAccessibilityTraitButton), nil); |
} |
+id<GREYMatcher> ContainsText(NSString* text) { |
+ MatchesBlock matches = ^BOOL(id element) { |
+ return [[element text] containsString:text]; |
+ }; |
+ DescribeToBlock describe = ^void(id<GREYDescription> description) { |
+ [description appendText:[NSString stringWithFormat:@"hasText('%@')", text]]; |
+ }; |
+ id<GREYMatcher> matcher = |
+ [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
+ descriptionBlock:describe]; |
+ return grey_allOf(grey_anyOf(grey_kindOfClass([UILabel class]), |
+ grey_kindOfClass([UITextField class]), |
+ grey_kindOfClass([UITextView class]), nil), |
+ matcher, nil); |
+} |
+ |
} // namespace chrome_test_util |