Commit 52d97b7e authored by Yue Zhang's avatar Yue Zhang Committed by Commit Bot

De-flaky StartSurfaceLayoutTest#testNewTabTile

Based on the error information on bots, this flaky is due to catching
multiple views with id new_tab_tile in view hierarchy. This could be
because during tab model switching, the check happens when the tab list
recyclerView is still updating, and new tab tiles for both models are
all in the view hierarchy at that moment. This CL fixes this issue by
adding a wait after tab model switch to make sure the recyclerView is
stable, and move the TabCountAssertion check earlier to give better
error information if the test is still flaky.

Bug: 1051961
Change-Id: I18181046f76a6cb60096140d5343cdb913bd6ce3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135951Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756878}
parent bff24471
......@@ -34,6 +34,7 @@ import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.g
import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.rotateDeviceToOrientation;
import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.verifyTabModelTabCount;
import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.verifyTabSwitcherCardCount;
import static org.chromium.chrome.test.util.browser.RecyclerViewTestUtils.waitForStableRecyclerView;
import static org.chromium.components.embedder_support.util.UrlConstants.NTP_URL;
import static org.chromium.content_public.browser.test.util.CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL;
import static org.chromium.content_public.browser.test.util.CriteriaHelper.DEFAULT_POLLING_INTERVAL;
......@@ -892,29 +893,29 @@ public class StartSurfaceLayoutTest {
// New tab tile should be showing.
enterGTSWithThumbnailChecking();
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(3));
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
verifyTabModelTabCount(cta, 2, 0);
// Clicking new tab tile in normal mode should create a normal tab.
onView(withId(R.id.new_tab_tile)).perform(click());
CriteriaHelper.pollUiThread(() -> !cta.getOverviewModeBehavior().overviewVisible());
enterGTSWithThumbnailChecking();
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(4));
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
verifyTabModelTabCount(cta, 3, 0);
// New tab tile should be showing in incognito mode.
switchTabModel(true);
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(1));
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
// Clicking new tab tile in incognito mode should create an incognito tab.
onView(withId(R.id.new_tab_tile)).perform(click());
CriteriaHelper.pollUiThread(() -> !cta.getOverviewModeBehavior().overviewVisible());
enterGTSWithThumbnailChecking();
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
onView(withId(R.id.tab_list_view)).check(TabCountAssertion.havingTabCount(2));
onView(withId(R.id.new_tab_tile)).check(matches(isDisplayed()));
verifyTabModelTabCount(cta, 3, 1);
// Close all normal tabs and incognito tabs, the new tab tile should still show in both
......@@ -1582,6 +1583,11 @@ public class StartSurfaceLayoutTest {
CriteriaHelper.pollUiThread(Criteria.equals(isIncognito,
() -> mActivityTestRule.getActivity().getTabModelSelector().isIncognitoSelected()));
// Wait for tab list recyclerView to finish animation after tab model switch.
RecyclerView recyclerView =
mActivityTestRule.getActivity().findViewById(R.id.tab_list_view);
waitForStableRecyclerView(recyclerView);
}
/**
......
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