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