Commit 12996a4d authored by olivierrobin's avatar olivierrobin Committed by Commit bot

Fix flake in TabUsageRecorder egtests.

- Switching of BVC is not always immediate. Add a Wait condition.
- FastSwipe gesture sometimes fail to switch mode. Use SlowSwipe.

Review-Url: https://codereview.chromium.org/2602943002
Cr-Commit-Position: refs/heads/master@{#440949}
parent a5af9931
...@@ -124,7 +124,12 @@ void OpenNewIncognitoTabUsingUIAndEvictMainTabs() { ...@@ -124,7 +124,12 @@ void OpenNewIncognitoTabUsingUIAndEvictMainTabs() {
[[EarlGrey selectElementWithMatcher:new_incognito_tab_button_matcher] [[EarlGrey selectElementWithMatcher:new_incognito_tab_button_matcher]
performAction:grey_tap()]; performAction:grey_tap()];
chrome_test_util::AssertIncognitoTabCount(nb_incognito_tab + 1); chrome_test_util::AssertIncognitoTabCount(nb_incognito_tab + 1);
ConditionBlock condition = ^bool {
return chrome_test_util::IsIncognitoMode();
};
GREYAssert(
testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition),
@"Waiting switch to incognito mode.");
chrome_test_util::EvictOtherTabModelTabs(); chrome_test_util::EvictOtherTabModelTabs();
} }
...@@ -183,13 +188,17 @@ void SwitchToNormalMode() { ...@@ -183,13 +188,17 @@ void SwitchToNormalMode() {
[[EarlGrey selectElementWithMatcher: [[EarlGrey selectElementWithMatcher:
chrome_test_util::buttonWithAccessibilityLabelId( chrome_test_util::buttonWithAccessibilityLabelId(
IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)] IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)]
performAction:grey_swipeFastInDirection(kGREYDirectionRight)]; performAction:grey_swipeSlowInDirection(kGREYDirectionRight)];
[[EarlGrey selectElementWithMatcher: [[EarlGrey selectElementWithMatcher:
chrome_test_util::buttonWithAccessibilityLabelId( chrome_test_util::buttonWithAccessibilityLabelId(
IDS_IOS_TOOLBAR_SHOW_TABS)] performAction:grey_tap()]; IDS_IOS_TOOLBAR_SHOW_TABS)] performAction:grey_tap()];
} }
GREYAssertFalse(chrome_test_util::IsIncognitoMode(), ConditionBlock condition = ^bool {
@"Switching to normal mode failed."); return !chrome_test_util::IsIncognitoMode();
};
GREYAssert(
testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition),
@"Waiting switch to normal mode.");
} }
// Check that the error page is visible. // Check that the error page is visible.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment