Commit 350db31d authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Skip extra thumbnail capturing when GTS animation is off

When the transition animation to Grid Tab Switcher (GTS) is disabled,
the thumbnail of the current tab is already updated when showing the
grid view. There is no need to force update it again after GTS has
finished showing. However, this is still needed when the animation is
enabled because the downsampled thumbnail is not written to cache.

This CL makes non-animation tests less flaky. Animation tests are
still flaky because the 2nd capturing might be skipped if the 1st one
takes too long.

Bug: 964406, 983448
Change-Id: Iabc8d360707fe78c3dea2b6e02c687c7d5b3bfca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1694929Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676987}
parent ff712029
...@@ -98,8 +98,11 @@ public class GridTabSwitcherLayout ...@@ -98,8 +98,11 @@ public class GridTabSwitcherLayout
@Override @Override
public void finishedShowing() { public void finishedShowing() {
doneShowing(); doneShowing();
Tab currentTab = mTabModelSelector.getCurrentTab(); // When animation is off, the thumbnail is already updated when showing the GTS.
if (currentTab != null) mTabContentManager.cacheTabThumbnail(currentTab); if (ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_TO_GTS_ANIMATION)) {
Tab currentTab = mTabModelSelector.getCurrentTab();
if (currentTab != null) mTabContentManager.cacheTabThumbnail(currentTab);
}
} }
@Override @Override
......
...@@ -212,7 +212,7 @@ public class GridTabSwitcherLayoutTest { ...@@ -212,7 +212,7 @@ public class GridTabSwitcherLayoutTest {
private void testTabToGrid(String fromUrl) throws InterruptedException { private void testTabToGrid(String fromUrl) throws InterruptedException {
mActivityTestRule.loadUrl(fromUrl); mActivityTestRule.loadUrl(fromUrl);
int initCount = getCaptureCount(); final int initCount = getCaptureCount();
GridTabSwitcher gts = mGtsLayout.getGridTabSwitcherForTesting(); GridTabSwitcher gts = mGtsLayout.getGridTabSwitcherForTesting();
for (int i = 0; i < mRepeat; i++) { for (int i = 0; i < mRepeat; i++) {
...@@ -321,7 +321,7 @@ public class GridTabSwitcherLayoutTest { ...@@ -321,7 +321,7 @@ public class GridTabSwitcherLayoutTest {
} else { } else {
delta = 0; delta = 0;
} }
CriteriaHelper.pollUiThread(Criteria.equals(delta, () -> getCaptureCount() - count)); checkCaptureCount(delta, count);
} }
checkFinalCaptureCount(switchToAnotherTab, initCount); checkFinalCaptureCount(switchToAnotherTab, initCount);
assertThumbnailsAreReleased(); assertThumbnailsAreReleased();
...@@ -451,7 +451,7 @@ public class GridTabSwitcherLayoutTest { ...@@ -451,7 +451,7 @@ public class GridTabSwitcherLayoutTest {
delta += 1; delta += 1;
} }
} }
CriteriaHelper.pollUiThread(Criteria.equals(delta, () -> getCaptureCount() - count)); checkCaptureCount(delta, count);
if (checkThumbnail) checkThumbnailsExist(currentTab); if (checkThumbnail) checkThumbnailsExist(currentTab);
} }
...@@ -471,7 +471,13 @@ public class GridTabSwitcherLayoutTest { ...@@ -471,7 +471,13 @@ public class GridTabSwitcherLayoutTest {
expected += mRepeat; expected += mRepeat;
} }
} }
Assert.assertEquals(expected, getCaptureCount() - initCount); checkCaptureCount(expected, initCount);
}
private void checkCaptureCount(int expectedDelta, int initCount) {
// TODO(wychen): With animation, the 2nd capture might be skipped if the 1st takes too long.
CriteriaHelper.pollUiThread(
Criteria.equals(expectedDelta, () -> getCaptureCount() - initCount));
} }
private void checkThumbnailsExist(Tab tab) { private void checkThumbnailsExist(Tab tab) {
......
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