Chromium Code Reviews| Index: ui/app_list/views/apps_grid_view_unittest.cc |
| diff --git a/ui/app_list/views/apps_grid_view_unittest.cc b/ui/app_list/views/apps_grid_view_unittest.cc |
| index 5adacb1956f382cb40abaa796de24a6b34d2a258..45c5e6195f2f2af56f024fbb93d3368f1220877f 100644 |
| --- a/ui/app_list/views/apps_grid_view_unittest.cc |
| +++ b/ui/app_list/views/apps_grid_view_unittest.cc |
| @@ -20,6 +20,7 @@ |
| #include "ui/app_list/pagination_model.h" |
| #include "ui/app_list/test/app_list_test_model.h" |
| #include "ui/app_list/views/app_list_item_view.h" |
| +#include "ui/app_list/views/apps_grid_view_folder_delegate.h" |
| #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
| #include "ui/views/test/views_test_base.h" |
| @@ -179,6 +180,38 @@ class AppsGridViewTest : public views::ViewsTestBase { |
| DISALLOW_COPY_AND_ASSIGN(AppsGridViewTest); |
| }; |
| +class TestAppsGridViewFolderDelegate : public AppsGridViewFolderDelegate { |
| + public: |
| + TestAppsGridViewFolderDelegate() : show_bubble_(false) {} |
| + ~TestAppsGridViewFolderDelegate() {} |
| + |
| + // Overridden from AppsGridViewFolderDelegate: |
| + virtual void UpdateFolderViewBackground(bool show_bubble) OVERRIDE { |
| + show_bubble_ = show_bubble; |
| + } |
| + |
| + virtual void ReparentItem(AppListItemView* original_drag_view, |
| + const gfx::Point& drag_point_in_folder_grid) |
| + OVERRIDE {} |
|
tapted
2014/03/26 02:53:54
nit: OVERRIDE looks lonely, unless clang-format di
calamity
2014/03/27 05:14:44
All hail our benevolent clang-format overlord.
|
| + |
| + virtual void DispatchDragEventForReparent(AppsGridView::Pointer pointer, |
| + const ui::LocatedEvent& event) |
| + OVERRIDE {} |
| + |
| + virtual void DispatchEndDragEventForReparent( |
| + bool events_forwarded_to_drag_drop_host) OVERRIDE {} |
| + |
| + virtual bool IsPointOutsideOfFolderBoundary(const gfx::Point& point) |
| + OVERRIDE { |
| + return false; |
| + } |
| + |
| + bool show_bubble() { return show_bubble_; } |
| + |
| + private: |
| + bool show_bubble_; |
| +}; |
|
tapted
2014/03/26 02:53:54
nit: DISALLOW_COPY_AND_ASSIGN(..)
calamity
2014/03/27 05:14:44
Done.
|
| + |
| TEST_F(AppsGridViewTest, CreatePage) { |
| // Fully populates a page. |
| const int kPages = 1; |
| @@ -352,6 +385,26 @@ TEST_F(AppsGridViewTest, SimultaneousDragWithFolderDisabled) { |
| test_api_->LayoutToIdealBounds(); |
| } |
| +TEST_F(AppsGridViewTest, UpdateFolderBackgroundOnCancelDrag) { |
| + const int kTotalItems = 4; |
| + TestAppsGridViewFolderDelegate folder_delegate; |
| + apps_grid_view_->set_folder_delegate(&folder_delegate); |
| + model_->PopulateApps(kTotalItems); |
| + EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"), |
| + model_->GetModelContent()); |
| + |
| + gfx::Point mouse_from = GetItemTileRectAt(0, 0).CenterPoint(); |
| + gfx::Point mouse_to = GetItemTileRectAt(0, 1).CenterPoint(); |
| + |
| + // Starts a mouse drag and then cancels it. |
| + SimulateDrag(AppsGridView::MOUSE, mouse_from, mouse_to); |
| + EXPECT_TRUE(folder_delegate.show_bubble()); |
| + apps_grid_view_->EndDrag(true); |
| + EXPECT_FALSE(folder_delegate.show_bubble()); |
| + EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"), |
| + model_->GetModelContent()); |
| +} |
| + |
| TEST_F(AppsGridViewTest, HighlightWithKeyboard) { |
| const int kPages = 3; |
| const int kItems = (kPages - 1) * kTilesPerPage + 1; |