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 "ui/app_list/views/apps_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ui/app_list/views/app_list_item_view.h" | 24 #include "ui/app_list/views/app_list_item_view.h" |
25 #include "ui/app_list/views/apps_grid_view_folder_delegate.h" | 25 #include "ui/app_list/views/apps_grid_view_folder_delegate.h" |
26 #include "ui/app_list/views/test/apps_grid_view_test_api.h" | 26 #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
27 #include "ui/views/test/views_test_base.h" | 27 #include "ui/views/test/views_test_base.h" |
28 | 28 |
29 namespace app_list { | 29 namespace app_list { |
30 namespace test { | 30 namespace test { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 const int kIconDimension = 48; | |
35 const int kCols = 2; | 34 const int kCols = 2; |
36 const int kRows = 2; | 35 const int kRows = 2; |
37 const int kTilesPerPage = kCols * kRows; | 36 const int kTilesPerPage = kCols * kRows; |
38 | 37 |
39 const int kWidth = 320; | 38 const int kWidth = 320; |
40 const int kHeight = 240; | 39 const int kHeight = 240; |
41 | 40 |
42 class PageFlipWaiter : public PaginationModelObserver { | 41 class PageFlipWaiter : public PaginationModelObserver { |
43 public: | 42 public: |
44 PageFlipWaiter(base::MessageLoopForUI* ui_loop, PaginationModel* model) | 43 PageFlipWaiter(base::MessageLoopForUI* ui_loop, PaginationModel* model) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 AppsGridViewTest() {} | 94 AppsGridViewTest() {} |
96 virtual ~AppsGridViewTest() {} | 95 virtual ~AppsGridViewTest() {} |
97 | 96 |
98 // testing::Test overrides: | 97 // testing::Test overrides: |
99 virtual void SetUp() OVERRIDE { | 98 virtual void SetUp() OVERRIDE { |
100 views::ViewsTestBase::SetUp(); | 99 views::ViewsTestBase::SetUp(); |
101 model_.reset(new AppListTestModel); | 100 model_.reset(new AppListTestModel); |
102 model_->SetFoldersEnabled(true); | 101 model_->SetFoldersEnabled(true); |
103 | 102 |
104 apps_grid_view_.reset(new AppsGridView(NULL)); | 103 apps_grid_view_.reset(new AppsGridView(NULL)); |
105 apps_grid_view_->SetLayout(kIconDimension, kCols, kRows); | 104 apps_grid_view_->SetLayout(kCols, kRows); |
106 apps_grid_view_->SetBoundsRect(gfx::Rect(gfx::Size(kWidth, kHeight))); | 105 apps_grid_view_->SetBoundsRect(gfx::Rect(gfx::Size(kWidth, kHeight))); |
107 apps_grid_view_->SetModel(model_.get()); | 106 apps_grid_view_->SetModel(model_.get()); |
108 apps_grid_view_->SetItemList(model_->top_level_item_list()); | 107 apps_grid_view_->SetItemList(model_->top_level_item_list()); |
109 | 108 |
110 test_api_.reset(new AppsGridViewTestApi(apps_grid_view_.get())); | 109 test_api_.reset(new AppsGridViewTestApi(apps_grid_view_.get())); |
111 } | 110 } |
112 virtual void TearDown() OVERRIDE { | 111 virtual void TearDown() OVERRIDE { |
113 apps_grid_view_.reset(); // Release apps grid view before models. | 112 apps_grid_view_.reset(); // Release apps grid view before models. |
114 views::ViewsTestBase::TearDown(); | 113 views::ViewsTestBase::TearDown(); |
115 } | 114 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 EnsureFoldersEnabled(); | 424 EnsureFoldersEnabled(); |
426 | 425 |
427 size_t kTotalItems = 2; | 426 size_t kTotalItems = 2; |
428 model_->PopulateApps(kTotalItems); | 427 model_->PopulateApps(kTotalItems); |
429 EXPECT_EQ(2u, model_->top_level_item_list()->item_count()); | 428 EXPECT_EQ(2u, model_->top_level_item_list()->item_count()); |
430 EXPECT_EQ(std::string("Item 0,Item 1"), model_->GetModelContent()); | 429 EXPECT_EQ(std::string("Item 0,Item 1"), model_->GetModelContent()); |
431 | 430 |
432 gfx::Point from = GetItemTileRectAt(0, 1).CenterPoint(); | 431 gfx::Point from = GetItemTileRectAt(0, 1).CenterPoint(); |
433 int reorder_offset = (GetItemTileRectAt(0, 1).CenterPoint() - | 432 int reorder_offset = (GetItemTileRectAt(0, 1).CenterPoint() - |
434 GetItemTileRectAt(0, 0).CenterPoint()).Length() - | 433 GetItemTileRectAt(0, 0).CenterPoint()).Length() - |
435 kReorderDroppingCircleRadius - | 434 kReorderDroppingCircleRadius - kGridIconDimension / 2 + |
436 kPreferredIconDimension / 2 + 5; | 435 5; |
437 gfx::Point to = gfx::Point(from.x() - reorder_offset, from.y()); | 436 gfx::Point to = gfx::Point(from.x() - reorder_offset, from.y()); |
438 | 437 |
439 // Dragging item_1 closing to item_0 should leads to re-ordering these two | 438 // Dragging item_1 closing to item_0 should leads to re-ordering these two |
440 // items. | 439 // items. |
441 SimulateDrag(AppsGridView::MOUSE, from, to); | 440 SimulateDrag(AppsGridView::MOUSE, from, to); |
442 apps_grid_view_->EndDrag(false); | 441 apps_grid_view_->EndDrag(false); |
443 EXPECT_EQ(2u, model_->top_level_item_list()->item_count()); | 442 EXPECT_EQ(2u, model_->top_level_item_list()->item_count()); |
444 EXPECT_EQ(std::string("Item 1,Item 0"), model_->GetModelContent()); | 443 EXPECT_EQ(std::string("Item 1,Item 0"), model_->GetModelContent()); |
445 test_api_->LayoutToIdealBounds(); | 444 test_api_->LayoutToIdealBounds(); |
446 } | 445 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 AppListItemView* item_view = GetItemViewAt(0); | 709 AppListItemView* item_view = GetItemViewAt(0); |
711 ASSERT_TRUE(item_view); | 710 ASSERT_TRUE(item_view); |
712 const views::Label* title_label = item_view->title(); | 711 const views::Label* title_label = item_view->title(); |
713 EXPECT_FALSE(title_label->GetTooltipText( | 712 EXPECT_FALSE(title_label->GetTooltipText( |
714 title_label->bounds().CenterPoint(), &actual_tooltip)); | 713 title_label->bounds().CenterPoint(), &actual_tooltip)); |
715 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); | 714 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); |
716 } | 715 } |
717 | 716 |
718 } // namespace test | 717 } // namespace test |
719 } // namespace app_list | 718 } // namespace app_list |
OLD | NEW |