| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/app_list/app_list_model_view.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 #include "ui/app_list/app_list_item_view.h" | |
| 9 | |
| 10 namespace { | |
| 11 | |
| 12 struct ModelViewCalculateLayoutCase { | |
| 13 gfx::Size screen_size; | |
| 14 int num_of_tiles; | |
| 15 gfx::Size expected_icon_size; | |
| 16 int expected_rows; | |
| 17 int expected_cols; | |
| 18 }; | |
| 19 | |
| 20 } // namespace | |
| 21 | |
| 22 namespace app_list { | |
| 23 | |
| 24 TEST(AppListModelViewTest, ModelViewCalculateLayout) { | |
| 25 // kMinTitleWidth is the average width of 15 chars of default size 12 font in | |
| 26 // chromeos. Override here to avoid flakiness from different default font on | |
| 27 // bots. | |
| 28 const int kMinTitleWidth = 90; | |
| 29 AppListItemView::SetMinTitleWidth(kMinTitleWidth); | |
| 30 | |
| 31 const int kLauncherHeight = 50; | |
| 32 const ModelViewCalculateLayoutCase kCases[] = { | |
| 33 { gfx::Size(1024, 768), 4, gfx::Size(128, 128), 2, 3 }, | |
| 34 { gfx::Size(1024, 768), 29, gfx::Size(64, 64), 5, 6 }, | |
| 35 { gfx::Size(1024, 768), 40, gfx::Size(48, 48), 5, 8 }, | |
| 36 { gfx::Size(1024, 768), 48, gfx::Size(48, 48), 6, 8 }, | |
| 37 | |
| 38 { gfx::Size(1280, 1024), 4, gfx::Size(128, 128), 2, 3 }, | |
| 39 { gfx::Size(1280, 1024), 29, gfx::Size(64, 64), 5, 7 }, | |
| 40 { gfx::Size(1280, 1024), 50, gfx::Size(64, 64), 7, 8 }, | |
| 41 { gfx::Size(1280, 1024), 70, gfx::Size(48, 48), 7, 10 }, | |
| 42 { gfx::Size(1280, 1024), 99, gfx::Size(48, 48), 9, 11 }, | |
| 43 | |
| 44 { gfx::Size(1600, 900), 4, gfx::Size(128, 128), 2, 3 }, | |
| 45 { gfx::Size(1600, 900), 29, gfx::Size(64, 64), 4, 8 }, | |
| 46 | |
| 47 // Not able to fit into screen case. | |
| 48 { gfx::Size(1024, 768), 50, gfx::Size(32, 32), 6, 9 }, | |
| 49 { gfx::Size(1280, 1024), 100, gfx::Size(32, 32), 10, 11 }, | |
| 50 }; | |
| 51 | |
| 52 for (size_t i = 0; i < arraysize(kCases); ++i) { | |
| 53 gfx::Size icon_size; | |
| 54 int rows = 0; | |
| 55 int cols = 0; | |
| 56 gfx::Size content_size(kCases[i].screen_size.width(), | |
| 57 kCases[i].screen_size.height() - kLauncherHeight); | |
| 58 AppListModelView::CalculateLayout(content_size, | |
| 59 kCases[i].num_of_tiles, | |
| 60 &icon_size, | |
| 61 &rows, | |
| 62 &cols); | |
| 63 EXPECT_EQ(kCases[i].expected_icon_size, icon_size) << "i=" << i; | |
| 64 EXPECT_EQ(kCases[i].expected_rows, rows) << "i=" << i; | |
| 65 EXPECT_EQ(kCases[i].expected_cols, cols) << "i=" << i; | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 } // namespace app_list | |
| OLD | NEW |