Skip to content

Commit

Permalink
Add RenderTests in StartSurfaceLayoutTest for native tab
Browse files Browse the repository at this point in the history
Add one more RenderTest for native tab. Choose NTP in incognito mode
for its consistency.

Also fix the issue about thumbnails being not freed in
http://crrev.com/c/1903402.

Bug: 983170
Change-Id: I68d3f08184cb4b9504935a53f893bb7ea9473ba6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903620
Commit-Queue: Wei-Yin Chen (陳威尹) <[email protected]>
Reviewed-by: Yue Zhang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#713961}
  • Loading branch information
wychen authored and Commit Bot committed Nov 8, 2019
1 parent 5b753f4 commit ac0e2c9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ public void setUp() {
.getCurrentTabModelFilter()::isTabModelRestored));

assertEquals(0, mTabListDelegate.getBitmapFetchCountForTesting());
// Only skip thumbnail releasing assertion when "warm" (large soft-cleanup-delay) or in
// RenderTest.
// TODO(wychen): figure out why thumbnails are not released in RenderTest.
// Only skip thumbnail releasing assertion when "warm" (large soft-cleanup-delay).
mSkipAssertThumbnailsAreReleased = false;
}

Expand All @@ -148,42 +146,36 @@ public void tearDown() {
@Feature({"RenderTest"})
@CommandLineFlags.Add({BASE_PARAMS})
public void testRenderGrid_3WebTabs() throws InterruptedException, IOException {
mSkipAssertThumbnailsAreReleased = true;

prepareTabs(3, 0, mUrl);
TabUiTestHelper.enterTabSwitcher(mActivityTestRule.getActivity());
TabUiTestHelper.clickFirstCardFromTabSwitcher(mActivityTestRule.getActivity());

enterGTS();
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(
org.chromium.chrome.tab_ui.R.id.tab_list_view),
"3_web_tabs");
mRenderTestRule.render(
mActivityTestRule.getActivity().findViewById(R.id.tab_list_view), "3_web_tabs");
leaveGTS();
}

@Test
@MediumTest
@Feature({"RenderTest"})
@CommandLineFlags.Add({BASE_PARAMS})
public void testRenderGrid_10WebTabs() throws InterruptedException, IOException {
mSkipAssertThumbnailsAreReleased = true;

prepareTabs(10, 0, mUrl);
TabUiTestHelper.enterTabSwitcher(mActivityTestRule.getActivity());
TabUiTestHelper.clickFirstCardFromTabSwitcher(mActivityTestRule.getActivity());

enterGTS();
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(
org.chromium.chrome.tab_ui.R.id.tab_list_view),
"10_web_tabs");
mRenderTestRule.render(
mActivityTestRule.getActivity().findViewById(R.id.tab_list_view), "10_web_tabs");
leaveGTS();
}

@Test
@MediumTest
@Feature({"RenderTest"})
@CommandLineFlags.Add({BASE_PARAMS})
public void testRenderGrid_10WebTabs_InitialScroll() throws InterruptedException, IOException {
mSkipAssertThumbnailsAreReleased = true;

prepareTabs(10, 0, mUrl);
TabUiTestHelper.enterTabSwitcher(mActivityTestRule.getActivity());
TabUiTestHelper.clickNthCardFromTabSwitcher(mActivityTestRule.getActivity(),
Expand All @@ -192,28 +184,45 @@ public void testRenderGrid_10WebTabs_InitialScroll() throws InterruptedException

enterGTS();
// Make sure the grid tab switcher is scrolled down to show the selected tab.
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(
org.chromium.chrome.tab_ui.R.id.tab_list_view),
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(R.id.tab_list_view),
"10_web_tabs-select_last");
leaveGTS();
}

@Test
@MediumTest
@Feature({"RenderTest"})
@CommandLineFlags.Add({BASE_PARAMS})
public void testRenderGrid_Incognito() throws InterruptedException, IOException {
mSkipAssertThumbnailsAreReleased = true;

// Prepare some incognito tabs and enter tab switcher.
prepareTabs(1, 3, mUrl);
assertTrue(mActivityTestRule.getActivity().getCurrentTabModel().isIncognito());
TabUiTestHelper.enterTabSwitcher(mActivityTestRule.getActivity());
TabUiTestHelper.clickFirstCardFromTabSwitcher(mActivityTestRule.getActivity());

enterGTS();
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(
org.chromium.chrome.tab_ui.R.id.tab_list_view),
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(R.id.tab_list_view),
"3_incognito_web_tabs");
leaveGTS();
}

@Test
@MediumTest
@Feature({"RenderTest"})
@CommandLineFlags.Add({BASE_PARAMS})
public void testRenderGrid_3IncognitoNTPs() throws InterruptedException, IOException {
// Prepare some incognito native tabs and enter tab switcher.
// NTP in incognito mode is chosen for its consistency in look, and we don't have to mock
// away the MV tiles, login promo, feed, etc.
prepareTabs(1, 3, null);
assertTrue(mActivityTestRule.getActivity().getCurrentTabModel().isIncognito());
TabUiTestHelper.enterTabSwitcher(mActivityTestRule.getActivity());
TabUiTestHelper.clickFirstCardFromTabSwitcher(mActivityTestRule.getActivity());

enterGTS();
mRenderTestRule.render(mActivityTestRule.getActivity().findViewById(R.id.tab_list_view),
"3_incognito_ntps");
leaveGTS();
}

@Test
Expand Down Expand Up @@ -459,7 +468,7 @@ private void testGridToTab(boolean switchToAnotherTab, boolean killBeforeSwitchi
waitForCaptureRateControl();
}
int count = getCaptureCount();
onView(withId(org.chromium.chrome.tab_ui.R.id.tab_list_view))
onView(withId(R.id.tab_list_view))
.perform(RecyclerViewActions.actionOnItemAtPosition(targetIndex, click()));
CriteriaHelper.pollUiThread(() -> {
boolean doneHiding =
Expand Down Expand Up @@ -582,16 +591,16 @@ public void testInvisibleTabsDontFetchSoft() throws InterruptedException {
public void testIncognitoEnterGts() throws InterruptedException {
prepareTabs(1, 1, null);
enterGTS();
onView(withId(org.chromium.chrome.tab_ui.R.id.tab_list_view))
onView(withId(R.id.tab_list_view))
.check(TabCountAssertion.havingTabCount(1));

onView(withId(org.chromium.chrome.tab_ui.R.id.tab_list_view))
onView(withId(R.id.tab_list_view))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
CriteriaHelper.pollInstrumentationThread(
() -> !mActivityTestRule.getActivity().getLayoutManager().overviewVisible());

enterGTS();
onView(withId(org.chromium.chrome.tab_ui.R.id.tab_list_view))
onView(withId(R.id.tab_list_view))
.check(TabCountAssertion.havingTabCount(1));
}

Expand All @@ -604,16 +613,16 @@ public void testIncognitoToggle_tabCount() throws InterruptedException {
// Prepare two incognito tabs and enter tab switcher.
prepareTabs(1, 2, mUrl);
enterGTS();
onView(withId(org.chromium.chrome.tab_ui.R.id.tab_list_view))
onView(withId(R.id.tab_list_view))
.check(TabCountAssertion.havingTabCount(2));

for (int i = 0; i < mRepeat; i++) {
switchTabModel(false);
onView(withId(org.chromium.chrome.tab_ui.R.id.tab_list_view))
onView(withId(R.id.tab_list_view))
.check(TabCountAssertion.havingTabCount(1));

switchTabModel(true);
onView(withId(org.chromium.chrome.tab_ui.R.id.tab_list_view))
onView(withId(R.id.tab_list_view))
.check(TabCountAssertion.havingTabCount(2));
}
leaveGTS();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aa72b682f2a1056919067f870c576e0f9f531302

0 comments on commit ac0e2c9

Please sign in to comment.