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) { ...@@ -234,7 +234,7 @@ int FeaturePodsContainerView::CalculateRowsFromHeight(int height) {
// Only use the max number of rows when there is enough space // Only use the max number of rows when there is enough space
// to show the fully expanded message center and quick settings. // to show the fully expanded message center and quick settings.
if (available_height > (kUnifiedFeaturePodMaxRows * row_height) && if (available_height > (kUnifiedFeaturePodMaxRows * row_height) &&
available_height % (kUnifiedFeaturePodMaxRows * row_height) > available_height - (kUnifiedFeaturePodMaxRows * row_height) >
kMessageCenterCollapseThreshold) { kMessageCenterCollapseThreshold) {
return kUnifiedFeaturePodMaxRows; return kUnifiedFeaturePodMaxRows;
} }
...@@ -244,7 +244,7 @@ int FeaturePodsContainerView::CalculateRowsFromHeight(int height) { ...@@ -244,7 +244,7 @@ int FeaturePodsContainerView::CalculateRowsFromHeight(int height) {
// with the expanded quick settings. // with the expanded quick settings.
int feature_pod_rows = kUnifiedFeaturePodMaxRows - 1; int feature_pod_rows = kUnifiedFeaturePodMaxRows - 1;
if (available_height > (feature_pod_rows * row_height) && if (available_height > (feature_pod_rows * row_height) &&
available_height % (feature_pod_rows * row_height) > available_height - (feature_pod_rows * row_height) >
kStackedNotificationBarHeight) { kStackedNotificationBarHeight) {
return feature_pod_rows; return feature_pod_rows;
} }
......
...@@ -252,6 +252,10 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) { ...@@ -252,6 +252,10 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) {
const int kNumberOfFeaturePods = kUnifiedFeaturePodItemsInRow * 3; const int kNumberOfFeaturePods = kUnifiedFeaturePodItemsInRow * 3;
const int padding = const int padding =
kUnifiedFeaturePodTopPadding + kUnifiedFeaturePodBottomPadding; kUnifiedFeaturePodTopPadding + kUnifiedFeaturePodBottomPadding;
int row_height =
kUnifiedFeaturePodSize.height() + kUnifiedFeaturePodVerticalPadding;
int min_height_for_three_rows = kUnifiedFeaturePodMaxRows * row_height +
padding + kMessageCenterCollapseThreshold;
EnablePagination(); EnablePagination();
AddButtons(kNumberOfFeaturePods); AddButtons(kNumberOfFeaturePods);
...@@ -264,11 +268,9 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) { ...@@ -264,11 +268,9 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) {
expected_number_of_pages += 1; expected_number_of_pages += 1;
EXPECT_EQ(expected_number_of_pages, pagination_model()->total_pages()); EXPECT_EQ(expected_number_of_pages, pagination_model()->total_pages());
// Expect 2 rows of feature pods when there is enough height to display them. // Expect 2 rows of feature pods when there is enough height to display them
container()->SetMaxHeight(padding + // but less than enough to display 3 rows.
(2 * (kUnifiedFeaturePodSize.height() + container()->SetMaxHeight(min_height_for_three_rows - 1);
kUnifiedFeaturePodVerticalPadding)) +
kMessageCenterCollapseThreshold);
expected_number_of_pages = expected_number_of_pages =
kNumberOfFeaturePods / (2 * kUnifiedFeaturePodItemsInRow); kNumberOfFeaturePods / (2 * kUnifiedFeaturePodItemsInRow);
if (kNumberOfFeaturePods % (2 * kUnifiedFeaturePodItemsInRow)) if (kNumberOfFeaturePods % (2 * kUnifiedFeaturePodItemsInRow))
...@@ -277,13 +279,14 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) { ...@@ -277,13 +279,14 @@ TEST_F(FeaturePodsContainerViewTest, PaginationDynamicRows) {
// Expect 3 rows of feature pods at max even when the max height is very // Expect 3 rows of feature pods at max even when the max height is very
// large. // large.
container()->SetMaxHeight(150 * (kUnifiedFeaturePodSize.height())); container()->SetMaxHeight(min_height_for_three_rows + 1);
expected_number_of_pages = expected_number_of_pages =
kNumberOfFeaturePods / (3 * kUnifiedFeaturePodItemsInRow); kNumberOfFeaturePods / (3 * kUnifiedFeaturePodItemsInRow);
if (kNumberOfFeaturePods % (3 * kUnifiedFeaturePodItemsInRow)) if (kNumberOfFeaturePods % (3 * kUnifiedFeaturePodItemsInRow))
expected_number_of_pages += 1; expected_number_of_pages += 1;
EXPECT_EQ(expected_number_of_pages, pagination_model()->total_pages()); EXPECT_EQ(expected_number_of_pages, pagination_model()->total_pages());
} }
TEST_F(FeaturePodsContainerViewTest, PaginationGestureHandling) { TEST_F(FeaturePodsContainerViewTest, PaginationGestureHandling) {
const int kNumberOfPages = 8; 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