Chromium Code Reviews| 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/shell/test/earl_grey/shell_matchers.h" | 5 #import "ios/web/shell/test/earl_grey/shell_matchers.h" |
| 6 | 6 |
| 7 #import "base/mac/foundation_util.h" | 7 #import "base/mac/foundation_util.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "base/test/ios/wait_util.h" | 9 #include "base/test/ios/wait_util.h" |
| 10 #include "ios/testing/earl_grey/wait_util.h" | 10 #include "ios/testing/earl_grey/wait_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 + (id<GREYMatcher>)matcherForAddressFieldEqualToText:(const std::string&)text { | 47 + (id<GREYMatcher>)matcherForAddressFieldEqualToText:(const std::string&)text { |
| 48 MatchesBlock matches = ^BOOL(UIView* view) { | 48 MatchesBlock matches = ^BOOL(UIView* view) { |
| 49 if (![view isKindOfClass:[UITextField class]]) { | 49 if (![view isKindOfClass:[UITextField class]]) { |
| 50 return NO; | 50 return NO; |
| 51 } | 51 } |
| 52 if (![[view accessibilityLabel] | 52 if (![[view accessibilityLabel] |
| 53 isEqualToString:kWebShellAddressFieldAccessibilityLabel]) { | 53 isEqualToString:kWebShellAddressFieldAccessibilityLabel]) { |
| 54 return NO; | 54 return NO; |
| 55 } | 55 } |
| 56 UITextField* textField = base::mac::ObjCCastStrict<UITextField>(view); | 56 UITextField* textField = base::mac::ObjCCastStrict<UITextField>(view); |
| 57 NSDate* deadline = | 57 testing::WaitUntilCondition(testing::kWaitForUIElementTimeout, ^() { |
|
Eugene But (OOO till 7-30)
2016/06/06 21:38:59
I don't think this will compile on 32-bit platform
baxley
2016/06/06 22:38:08
Nice catch! Done.
| |
| 58 [NSDate dateWithTimeIntervalSinceNow:testing::kWaitForUIElementTimeout]; | 58 return [textField.text isEqualToString:base::SysUTF8ToNSString(text)]; |
| 59 while ([[NSDate date] compare:deadline] != NSOrderedDescending) { | 59 }); |
| 60 if ([textField.text isEqualToString:base::SysUTF8ToNSString(text)]) { | 60 return YES; |
| 61 return YES; | |
| 62 } | |
| 63 base::test::ios::SpinRunLoopWithMaxDelay( | |
| 64 base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds)); | |
| 65 } | |
| 66 return NO; | |
| 67 }; | 61 }; |
| 68 | 62 |
| 69 DescribeToBlock describe = ^(id<GREYDescription> description) { | 63 DescribeToBlock describe = ^(id<GREYDescription> description) { |
| 70 [description appendText:@"address field containing "]; | 64 [description appendText:@"address field containing "]; |
| 71 [description appendText:base::SysUTF8ToNSString(text)]; | 65 [description appendText:base::SysUTF8ToNSString(text)]; |
| 72 }; | 66 }; |
| 73 | 67 |
| 74 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches | 68 return [[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
| 75 descriptionBlock:describe] | 69 descriptionBlock:describe] |
| 76 autorelease]; | 70 autorelease]; |
| 77 } | 71 } |
| 78 | 72 |
| 79 + (id<GREYMatcher>)matcherForWebShellBackButton { | 73 + (id<GREYMatcher>)matcherForWebShellBackButton { |
| 80 return grey_accessibilityLabel(kWebShellBackButtonAccessibilityLabel); | 74 return grey_accessibilityLabel(kWebShellBackButtonAccessibilityLabel); |
| 81 } | 75 } |
| 82 | 76 |
| 83 + (id<GREYMatcher>)matcherForWebShellForwardButton { | 77 + (id<GREYMatcher>)matcherForWebShellForwardButton { |
| 84 return grey_accessibilityLabel(kWebShellForwardButtonAccessibilityLabel); | 78 return grey_accessibilityLabel(kWebShellForwardButtonAccessibilityLabel); |
| 85 } | 79 } |
| 86 | 80 |
| 87 + (id<GREYMatcher>)matcherForWebShellAddressField { | 81 + (id<GREYMatcher>)matcherForWebShellAddressField { |
| 88 return grey_accessibilityLabel(kWebShellAddressFieldAccessibilityLabel); | 82 return grey_accessibilityLabel(kWebShellAddressFieldAccessibilityLabel); |
| 89 } | 83 } |
| 90 | 84 |
| 91 @end | 85 @end |
| OLD | NEW |