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 "ash/app_list/app_list_item_view.h" | |
6 #include "ash/app_list/app_list_model_view.h" | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace { | |
10 | |
11 struct ModelViewCalculateLayoutCase { | |
12 gfx::Size screen_size; | |
13 int num_of_tiles; | |
14 gfx::Size expected_icon_size; | |
15 int expected_rows; | |
16 int expected_cols; | |
17 }; | |
18 | |
19 } // namespace | |
20 | |
21 TEST(AppListTest, ModelViewCalculateLayout) { | |
22 // kMinTitleWidth is the average width of 15 chars of default size 12 font in | |
23 // chromeos. Override here to avoid flakiness from different default font on | |
24 // bots. | |
25 const int kMinTitleWidth = 90; | |
26 ash::AppListItemView::SetMinTitleWidth(kMinTitleWidth); | |
27 | |
28 const int kLauncherHeight = 50; | |
29 const ModelViewCalculateLayoutCase kCases[] = { | |
30 { gfx::Size(1024, 768), 4, gfx::Size(128, 128), 2, 3 }, | |
31 { gfx::Size(1024, 768), 29, gfx::Size(64, 64), 5, 6 }, | |
32 { gfx::Size(1024, 768), 40, gfx::Size(48, 48), 5, 8 }, | |
33 { gfx::Size(1024, 768), 48, gfx::Size(48, 48), 6, 8 }, | |
34 | |
35 { gfx::Size(1280, 1024), 4, gfx::Size(128, 128), 2, 3 }, | |
36 { gfx::Size(1280, 1024), 29, gfx::Size(64, 64), 5, 7 }, | |
37 { gfx::Size(1280, 1024), 50, gfx::Size(64, 64), 7, 8 }, | |
38 { gfx::Size(1280, 1024), 70, gfx::Size(48, 48), 7, 10 }, | |
39 { gfx::Size(1280, 1024), 99, gfx::Size(48, 48), 9, 11 }, | |
40 | |
41 { gfx::Size(1600, 900), 4, gfx::Size(128, 128), 2, 3 }, | |
42 { gfx::Size(1600, 900), 29, gfx::Size(64, 64), 4, 8 }, | |
43 | |
44 // Not able to fit into screen case. | |
45 { gfx::Size(1024, 768), 50, gfx::Size(32, 32), 6, 9 }, | |
46 { gfx::Size(1280, 1024), 100, gfx::Size(32, 32), 10, 11 }, | |
47 }; | |
48 | |
49 for (size_t i = 0; i < arraysize(kCases); ++i) { | |
50 gfx::Size icon_size; | |
51 int rows = 0; | |
52 int cols = 0; | |
53 gfx::Size content_size(kCases[i].screen_size.width(), | |
54 kCases[i].screen_size.height() - kLauncherHeight); | |
55 ash::AppListModelView::CalculateLayout(content_size, | |
56 kCases[i].num_of_tiles, | |
57 &icon_size, | |
58 &rows, | |
59 &cols); | |
60 EXPECT_EQ(kCases[i].expected_icon_size, icon_size) << "i=" << i; | |
61 EXPECT_EQ(kCases[i].expected_rows, rows) << "i=" << i; | |
62 EXPECT_EQ(kCases[i].expected_cols, cols) << "i=" << i; | |
63 } | |
64 } | |
OLD | NEW |