Commit 422aa229 authored by Tim Song's avatar Tim Song Committed by Commit Bot

Ash Tray: Update calculation for maximum number of feature pod rows.

TEST=updated unit tests
BUG=976952

Change-Id: I37f22b20f9fdefb18f29ace8e63cfad8d89260d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884762Reviewed-by: default avatarAhmed Mehfooz <amehfooz@chromium.org>
Commit-Queue: Tim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710164}
parent 32a68dac
......@@ -234,7 +234,7 @@ int FeaturePodsContainerView::CalculateRowsFromHeight(int height) {
// Only use the max number of rows when there is enough space
// to show the fully expanded message center and quick settings.
if (available_height > (kUnifiedFeaturePodMaxRows * row_height) &&
available_height % (kUnifiedFeaturePodMaxRows * row_height) >
available_height - (kUnifiedFeaturePodMaxRows * row_height) >
kMessageCenterCollapseThreshold) {
return kUnifiedFeaturePodMaxRows;
}
......@@ -244,7 +244,7 @@ int FeaturePodsContainerView::CalculateRowsFromHeight(int height) {
// with the expanded quick settings.
int feature_pod_rows = kUnifiedFeaturePodMaxRows - 1;
if (available_height > (feature_pod_rows * row_height) &&
available_height % (feature_pod_rows * row_height) >
available_height - (feature_pod_rows * row_height) >
kStackedNotificationBarHeight) {
return feature_pod_rows;
}
......
......@@ -252,6 +252,10 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) {
const int kNumberOfFeaturePods = kUnifiedFeaturePodItemsInRow * 3;
const int padding =
kUnifiedFeaturePodTopPadding + kUnifiedFeaturePodBottomPadding;
int row_height =
kUnifiedFeaturePodSize.height() + kUnifiedFeaturePodVerticalPadding;
int min_height_for_three_rows = kUnifiedFeaturePodMaxRows * row_height +
padding + kMessageCenterCollapseThreshold;
EnablePagination();
AddButtons(kNumberOfFeaturePods);
......@@ -264,11 +268,9 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) {
expected_number_of_pages += 1;
EXPECT_EQ(expected_number_of_pages, pagination_model()->total_pages());
// Expect 2 rows of feature pods when there is enough height to display them.
container()->SetMaxHeight(padding +
(2 * (kUnifiedFeaturePodSize.height() +
kUnifiedFeaturePodVerticalPadding)) +
kMessageCenterCollapseThreshold);
// Expect 2 rows of feature pods when there is enough height to display them
// but less than enough to display 3 rows.
container()->SetMaxHeight(min_height_for_three_rows - 1);
expected_number_of_pages =
kNumberOfFeaturePods / (2 * kUnifiedFeaturePodItemsInRow);
if (kNumberOfFeaturePods % (2 * kUnifiedFeaturePodItemsInRow))
......@@ -277,13 +279,14 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) {
// Expect 3 rows of feature pods at max even when the max height is very
// large.
container()->SetMaxHeight(150 * (kUnifiedFeaturePodSize.height()));
container()->SetMaxHeight(min_height_for_three_rows + 1);
expected_number_of_pages =
kNumberOfFeaturePods / (3 * kUnifiedFeaturePodItemsInRow);
if (kNumberOfFeaturePods % (3 * kUnifiedFeaturePodItemsInRow))
expected_number_of_pages += 1;
EXPECT_EQ(expected_number_of_pages, pagination_model()->total_pages());
}
TEST_F(FeaturePodsContainerViewTest, PaginationGestureHandling) {
const int kNumberOfPages = 8;
......
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