Commit 7338fe83 authored by zhaoyangli's avatar zhaoyangli Committed by Commit Bot

[iOS][EG2] Add sync to some ChromeEarlGrey operations.

Added sync after some ChromeEarlGrey operations where a UI change in
app might be triggered. This should eliminate undesirable racing
conditions before UI change finishes at app. TabUsageRecorderTestCase
is an example and this CL fixes it.

Bug: 1034196, 1033879
Change-Id: Ib260414371b832eed517d8bf72b2ee0c10f5cfd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1970914
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726550}
parent 653bb678
......@@ -266,10 +266,6 @@ void SwitchToNormalMode() {
SwitchToNormalMode();
[ChromeEarlGrey selectTabAtIndex:0];
#if defined(CHROME_EARL_GREY_2)
// TODO(crbug.com/1033879): Remove this timer once the sync is fixed.
base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSeconds(1));
#endif
[ChromeEarlGrey waitForWebStateContainingText:kURL1FirstWord];
// Verify that one page-load count has been recorded. It should contain two
......@@ -747,10 +743,6 @@ void SwitchToNormalMode() {
SwitchToNormalMode();
[ChromeEarlGrey selectTabAtIndex:tabIndex];
#if defined(CHROME_EARL_GREY_2)
// TODO(crbug.com/1033879): Remove this timer once the sync is fixed.
base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSeconds(1));
#endif
[ChromeEarlGrey waitForWebStateContainingText:"arrived"];
// Verify that one page-load count has been recorded. It should contain a
......
......@@ -192,6 +192,9 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
- (void)selectTabAtIndex:(NSUInteger)index {
[ChromeEarlGreyAppInterface selectTabAtIndex:index];
// Tab changes are initiated through |WebStateList|. Need to wait its
// obeservers to complete UI changes at app.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
- (BOOL)isIncognitoMode {
......@@ -200,6 +203,9 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
- (void)closeTabAtIndex:(NSUInteger)index {
[ChromeEarlGreyAppInterface closeTabAtIndex:index];
// Tab changes are initiated through |WebStateList|. Need to wait its
// obeservers to complete UI changes at app.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
- (NSUInteger)mainTabCount {
......@@ -277,6 +283,9 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
- (void)closeAllTabs {
[ChromeEarlGreyAppInterface closeAllTabs];
// Tab changes are initiated through |WebStateList|. Need to wait its
// obeservers to complete UI changes at app.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
- (void)waitForPageToFinishLoading {
......
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