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