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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // Deleting an item keeps remaining intact. | 300 // Deleting an item keeps remaining intact. |
301 SimulateDrag(AppsGridView::MOUSE, from, to); | 301 SimulateDrag(AppsGridView::MOUSE, from, to); |
302 model_->DeleteItem(model_->GetItemName(0)); | 302 model_->DeleteItem(model_->GetItemName(0)); |
303 apps_grid_view_->EndDrag(false); | 303 apps_grid_view_->EndDrag(false); |
304 EXPECT_EQ(std::string("Item 1,Item 2,Item 3"), | 304 EXPECT_EQ(std::string("Item 1,Item 2,Item 3"), |
305 model_->GetModelContent()); | 305 model_->GetModelContent()); |
306 test_api_->LayoutToIdealBounds(); | 306 test_api_->LayoutToIdealBounds(); |
307 | 307 |
308 // Adding a launcher item cancels the drag and respects the order. | 308 // Adding a launcher item cancels the drag and respects the order. |
309 SimulateDrag(AppsGridView::MOUSE, from, to); | 309 SimulateDrag(AppsGridView::MOUSE, from, to); |
| 310 EXPECT_TRUE(apps_grid_view_->has_dragged_view()); |
310 model_->CreateAndAddItem("Extra"); | 311 model_->CreateAndAddItem("Extra"); |
311 apps_grid_view_->EndDrag(false); | 312 // No need to EndDrag explicitly - adding an item should do this. |
| 313 EXPECT_FALSE(apps_grid_view_->has_dragged_view()); |
| 314 // Even though cancelled, mouse move events can still arrive via the item |
| 315 // view. Ensure that behaves sanely, and doesn't start a new drag. |
| 316 ui::MouseEvent drag_event( |
| 317 ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), gfx::Point(2, 2), 0, 0); |
| 318 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event); |
| 319 EXPECT_FALSE(apps_grid_view_->has_dragged_view()); |
| 320 |
312 EXPECT_EQ(std::string("Item 1,Item 2,Item 3,Extra"), | 321 EXPECT_EQ(std::string("Item 1,Item 2,Item 3,Extra"), |
313 model_->GetModelContent()); | 322 model_->GetModelContent()); |
314 test_api_->LayoutToIdealBounds(); | 323 test_api_->LayoutToIdealBounds(); |
315 } | 324 } |
316 | 325 |
317 TEST_F(AppsGridViewTest, MouseDragItemIntoFolder) { | 326 TEST_F(AppsGridViewTest, MouseDragItemIntoFolder) { |
318 EnsureFoldersEnabled(); | 327 EnsureFoldersEnabled(); |
319 | 328 |
320 size_t kTotalItems = 3; | 329 size_t kTotalItems = 3; |
321 model_->PopulateApps(kTotalItems); | 330 model_->PopulateApps(kTotalItems); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 AppListItemView* item_view = GetItemViewAt(0); | 710 AppListItemView* item_view = GetItemViewAt(0); |
702 ASSERT_TRUE(item_view); | 711 ASSERT_TRUE(item_view); |
703 const views::Label* title_label = item_view->title(); | 712 const views::Label* title_label = item_view->title(); |
704 EXPECT_FALSE(title_label->GetTooltipText( | 713 EXPECT_FALSE(title_label->GetTooltipText( |
705 title_label->bounds().CenterPoint(), &actual_tooltip)); | 714 title_label->bounds().CenterPoint(), &actual_tooltip)); |
706 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); | 715 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); |
707 } | 716 } |
708 | 717 |
709 } // namespace test | 718 } // namespace test |
710 } // namespace app_list | 719 } // namespace app_list |
OLD | NEW |