Skip to content

Commit

Permalink
[StartTablet] Fix bug caused by calculating the interval padding of M…
Browse files Browse the repository at this point in the history
…VT on tablets.

This change fixes the issue by adding a minimum value for the number of columns the MVT can have.

(cherry picked from commit 54cf1ae)

Bug: 1448365
Change-Id: I87bdcdaddc33d85c8cab0d969811a73c7741ecda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4563336
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Xinyi Ji <xinyiji@chromium.org>
Reviewed-by: Carlos Knippschild <carlosk@chromium.org>
Reviewed-by: Xi Han <hanxi@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1149866}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4582474
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Cr-Commit-Position: refs/branch-heads/5790@{#238}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
Xinyi Ji authored and Chromium LUCI CQ committed Jun 1, 2023
1 parent 04235de commit 6cbd3fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -683,13 +683,14 @@ private void verifyMostVisitedTileMarginImpl(View ntpLayout, View mvTilesContain
/ (mvTilesItemWidth + minHorizontalSpacing),
1, MostVisitedTilesCoordinator.MAX_TILE_COLUMNS_FOR_GRID);
int expectedIntervalPadding =
(mvTilesLayoutWidth - mvTilesItemWidth * numColumns - expectedEdgeMargin * 2)
/ (numColumns - 1);
Math.round((float) (mvTilesLayoutWidth - mvTilesItemWidth * numColumns
- expectedEdgeMargin * 2)
/ (numColumns - 1));
if (expectedIntervalPadding >= minHorizontalSpacing
&& expectedIntervalPadding <= maxHorizontalSpacing) {
Assert.assertEquals("The edge margin of the most visited tiles element to "
+ "the MV tiles layout is wrong.",
mvt1LeftMargin, expectedEdgeMargin);
expectedEdgeMargin, mvt1LeftMargin, 1);
Assert.assertEquals(
"The padding between each element of the most visited tiles is incorrect.",
expectedIntervalPadding,
Expand Down
Expand Up @@ -163,7 +163,8 @@ Pair<Integer, Integer> computeHorizontalDimensions(int availableWidth, int numCo
== Configuration.ORIENTATION_LANDSCAPE
? mTileViewLandscapeEdgePaddingTablet
: mTileViewPortraitEdgePaddingTablet;
horizontalSpacing = (availableWidth - gridStart * 2) / (numColumns - 1);
horizontalSpacing =
(float) (availableWidth - gridStart * 2) / Math.max(1, numColumns - 1);
} else {
// Identically sized spacers are added both between and around the tiles.
int spacerCount = numColumns + 1;
Expand Down

0 comments on commit 6cbd3fc

Please sign in to comment.