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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 class AppsGridViewTest : public views::ViewsTestBase { | 100 class AppsGridViewTest : public views::ViewsTestBase { |
101 public: | 101 public: |
102 AppsGridViewTest() {} | 102 AppsGridViewTest() {} |
103 virtual ~AppsGridViewTest() {} | 103 virtual ~AppsGridViewTest() {} |
104 | 104 |
105 // testing::Test overrides: | 105 // testing::Test overrides: |
106 virtual void SetUp() OVERRIDE { | 106 virtual void SetUp() OVERRIDE { |
107 views::ViewsTestBase::SetUp(); | 107 views::ViewsTestBase::SetUp(); |
108 model_.reset(new AppListTestModel); | 108 model_.reset(new AppListTestModel); |
| 109 model_->SetFoldersEnabled(true); |
109 | 110 |
110 apps_grid_view_.reset(new AppsGridView(NULL)); | 111 apps_grid_view_.reset(new AppsGridView(NULL)); |
111 apps_grid_view_->SetLayout(kIconDimension, kCols, kRows); | 112 apps_grid_view_->SetLayout(kIconDimension, kCols, kRows); |
112 apps_grid_view_->SetBoundsRect(gfx::Rect(gfx::Size(kWidth, kHeight))); | 113 apps_grid_view_->SetBoundsRect(gfx::Rect(gfx::Size(kWidth, kHeight))); |
113 apps_grid_view_->SetModel(model_.get()); | 114 apps_grid_view_->SetModel(model_.get()); |
114 apps_grid_view_->SetItemList(model_->top_level_item_list()); | 115 apps_grid_view_->SetItemList(model_->top_level_item_list()); |
115 | 116 |
116 test_api_.reset(new AppsGridViewTestApi(apps_grid_view_.get())); | 117 test_api_.reset(new AppsGridViewTestApi(apps_grid_view_.get())); |
117 } | 118 } |
118 virtual void TearDown() OVERRIDE { | 119 virtual void TearDown() OVERRIDE { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 274 |
274 EXPECT_FALSE(apps_grid_view_->IsSelectedView(last_view)); | 275 EXPECT_FALSE(apps_grid_view_->IsSelectedView(last_view)); |
275 | 276 |
276 // No crash happens. | 277 // No crash happens. |
277 AppListItemView* view = GetItemViewAt(0); | 278 AppListItemView* view = GetItemViewAt(0); |
278 apps_grid_view_->SetSelectedView(view); | 279 apps_grid_view_->SetSelectedView(view); |
279 EXPECT_TRUE(apps_grid_view_->IsSelectedView(view)); | 280 EXPECT_TRUE(apps_grid_view_->IsSelectedView(view)); |
280 } | 281 } |
281 | 282 |
282 TEST_F(AppsGridViewTest, MouseDragWithFolderDisabled) { | 283 TEST_F(AppsGridViewTest, MouseDragWithFolderDisabled) { |
283 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSyncAppList); | 284 model_->SetFoldersEnabled(false); |
284 const int kTotalItems = 4; | 285 const int kTotalItems = 4; |
285 model_->PopulateApps(kTotalItems); | 286 model_->PopulateApps(kTotalItems); |
286 EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"), | 287 EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"), |
287 model_->GetModelContent()); | 288 model_->GetModelContent()); |
288 | 289 |
289 gfx::Point from = GetItemTileRectAt(0, 0).CenterPoint(); | 290 gfx::Point from = GetItemTileRectAt(0, 0).CenterPoint(); |
290 gfx::Point to = GetItemTileRectAt(0, 1).CenterPoint(); | 291 gfx::Point to = GetItemTileRectAt(0, 1).CenterPoint(); |
291 | 292 |
292 // Dragging changes model order. | 293 // Dragging changes model order. |
293 SimulateDrag(AppsGridView::MOUSE, from, to); | 294 SimulateDrag(AppsGridView::MOUSE, from, to); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 544 |
544 EXPECT_TRUE(page_flip_waiter.Wait(0)); | 545 EXPECT_TRUE(page_flip_waiter.Wait(0)); |
545 EXPECT_EQ(0, GetPaginationModel()->selected_page()); | 546 EXPECT_EQ(0, GetPaginationModel()->selected_page()); |
546 | 547 |
547 EXPECT_FALSE(page_flip_waiter.Wait(100)); | 548 EXPECT_FALSE(page_flip_waiter.Wait(100)); |
548 EXPECT_EQ(0, GetPaginationModel()->selected_page()); | 549 EXPECT_EQ(0, GetPaginationModel()->selected_page()); |
549 apps_grid_view_->EndDrag(true); | 550 apps_grid_view_->EndDrag(true); |
550 } | 551 } |
551 | 552 |
552 TEST_F(AppsGridViewTest, SimultaneousDragWithFolderDisabled) { | 553 TEST_F(AppsGridViewTest, SimultaneousDragWithFolderDisabled) { |
553 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSyncAppList); | 554 model_->SetFoldersEnabled(false); |
554 const int kTotalItems = 4; | 555 const int kTotalItems = 4; |
555 model_->PopulateApps(kTotalItems); | 556 model_->PopulateApps(kTotalItems); |
556 EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"), | 557 EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"), |
557 model_->GetModelContent()); | 558 model_->GetModelContent()); |
558 | 559 |
559 gfx::Point mouse_from = GetItemTileRectAt(0, 0).CenterPoint(); | 560 gfx::Point mouse_from = GetItemTileRectAt(0, 0).CenterPoint(); |
560 gfx::Point mouse_to = GetItemTileRectAt(0, 1).CenterPoint(); | 561 gfx::Point mouse_to = GetItemTileRectAt(0, 1).CenterPoint(); |
561 | 562 |
562 gfx::Point touch_from = GetItemTileRectAt(1, 0).CenterPoint(); | 563 gfx::Point touch_from = GetItemTileRectAt(1, 0).CenterPoint(); |
563 gfx::Point touch_to = GetItemTileRectAt(1, 1).CenterPoint(); | 564 gfx::Point touch_to = GetItemTileRectAt(1, 1).CenterPoint(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 AppListItemView* item_view = GetItemViewAt(0); | 713 AppListItemView* item_view = GetItemViewAt(0); |
713 ASSERT_TRUE(item_view); | 714 ASSERT_TRUE(item_view); |
714 const views::Label* title_label = item_view->title(); | 715 const views::Label* title_label = item_view->title(); |
715 EXPECT_FALSE(title_label->GetTooltipText( | 716 EXPECT_FALSE(title_label->GetTooltipText( |
716 title_label->bounds().CenterPoint(), &actual_tooltip)); | 717 title_label->bounds().CenterPoint(), &actual_tooltip)); |
717 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); | 718 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); |
718 } | 719 } |
719 | 720 |
720 } // namespace test | 721 } // namespace test |
721 } // namespace app_list | 722 } // namespace app_list |
OLD | NEW |