Chromium Code Reviews| Index: ios/chrome/browser/context_menu/context_menu_egtest.mm |
| diff --git a/ios/chrome/browser/context_menu/context_menu_egtest.mm b/ios/chrome/browser/context_menu/context_menu_egtest.mm |
| index 65c652fda9189b8c9126a576507ee7c42cd32bf0..8f5d46c8b9e01a1cb8bc418042683b8df195851f 100644 |
| --- a/ios/chrome/browser/context_menu/context_menu_egtest.mm |
| +++ b/ios/chrome/browser/context_menu/context_menu_egtest.mm |
| @@ -57,6 +57,20 @@ |
| return buttonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| } |
| +// Wait until |matcher| is nil. |
| +void WaitForMatcherBecomesNil(id<GREYMatcher> matcher) { |
|
baxley
2017/01/19 22:27:40
Can we call it "WaitForMatcher"? I think becoming
liaoyuke
2017/01/19 22:47:44
Acknowledged.
|
| + ConditionBlock condition = ^{ |
| + NSError* error = nil; |
| + [[EarlGrey selectElementWithMatcher:matcher] assertWithMatcher:grey_nil() |
| + error:&error]; |
| + return error == nil; |
| + }; |
| + GREYAssert( |
| + testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, |
| + condition), |
| + [NSString stringWithFormat:@"Waiting for matcher %@ failed.", matcher]); |
| +} |
| + |
| // Long press on |elementId| to trigger context menu and then tap on |
| // |contextMenuItemButton| item. |
| void LongPressElementAndTapOnButton(const char* elementId, |
| @@ -70,8 +84,10 @@ void LongPressElementAndTapOnButton(const char* elementId, |
| assertWithMatcher:grey_notNil()]; |
| [[EarlGrey selectElementWithMatcher:contextMenuItemButton] |
| performAction:grey_tap()]; |
| - [[EarlGrey selectElementWithMatcher:contextMenuItemButton] |
| - assertWithMatcher:grey_nil()]; |
| + |
| + // Earl Grey cannot preperly synchronize with WKWebView, so adding a |
| + // WaitUntilCondition to wait for the context menu to disappear. |
| + WaitForMatcherBecomesNil(contextMenuItemButton); |
|
baxley
2017/01/19 22:27:40
Were you able to verify that this fixes the proble
liaoyuke
2017/01/19 22:47:44
Speculative. I'll keep an eye on it and once it fa
|
| } |
| // A simple wrapper that sleeps for 1s to wait for the animation, triggered from |
| @@ -174,15 +190,7 @@ - (void)testContextMenuOpenInNewTab { |
| // Tests "Open in New Tab" on context menu on a link that requires scrolling |
| // on the page to verify that context menu can be properly triggered in the |
| // current screen view. |
| -// TODO(crbug.com/681130): Re-enable this test on device. |
| -#if TARGET_IPHONE_SIMULATOR |
| -#define MAYBE_testContextMenuOpenInNewTabFromTallPage \ |
| - testContextMenuOpenInNewTabFromTallPage |
| -#else |
| -#define MAYBE_testContextMenuOpenInNewTabFromTallPage \ |
| - FLAKY_testContextMenuOpenInNewTabFromTallPage |
| -#endif |
| -- (void)MAYBE_testContextMenuOpenInNewTabFromTallPage { |
| +- (void)testContextMenuOpenInNewTabFromTallPage { |
|
baxley
2017/01/19 22:27:40
Did you have to modify anything to fix this method
liaoyuke
2017/01/19 22:47:44
Acknowledged.
|
| // Set up test simple http server. |
| std::map<GURL, std::string> responses; |
| GURL initialURL = |