summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorerikchen@chromium.org <erikchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-26 23:06:04 +0000
committererikchen@chromium.org <erikchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-26 23:06:04 +0000
commitb995b007fb52d13fe8f6c60c1f351f863a2793b3 (patch)
tree91b988d054503009bf426b1cd070e1c62aaa5411 /ui
parent9adb0163c712d46024a2592ea556e6ab9bce105b (diff)
downloadchromium_src-b995b007fb52d13fe8f6c60c1f351f863a2793b3.zip
chromium_src-b995b007fb52d13fe8f6c60c1f351f863a2793b3.tar.gz
chromium_src-b995b007fb52d13fe8f6c60c1f351f863a2793b3.tar.bz2
Revert of Add AppsGridView unit test for folder ui tests. (https://codereview.chromium.org/211423006/)
Reason for revert: Compile errors. http://build.chromium.org/p/chromium.win/builders/Win%20x64%20Builder/builds/16508 Original issue's description: > Add AppsGridView unit test for folder ui tests. This cl add ui tests for: > 1. Drag/drop items in top level to re-order items. > 2. Drag/drop items to create a folder or add items into an existing folder. > 3. Test the maximum number of items user can drag/drop into a folder. > > BUG=354627 > R=xiyuan@chromium.org > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=259720 TBR=xiyuan@chromium.org,tfarina@chromium.org,jennyz@chromium.org NOTREECHECKS=true NOTRY=true BUG=354627 Review URL: https://codereview.chromium.org/213683004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/app_list/app_list_constants.cc6
-rw-r--r--ui/app_list/app_list_constants.h3
-rw-r--r--ui/app_list/test/app_list_test_model.cc11
-rw-r--r--ui/app_list/test/app_list_test_model.h3
-rw-r--r--ui/app_list/views/apps_grid_view.cc7
-rw-r--r--ui/app_list/views/apps_grid_view_unittest.cc174
6 files changed, 6 insertions, 198 deletions
diff --git a/ui/app_list/app_list_constants.cc b/ui/app_list/app_list_constants.cc
index 6dd3eb4..6c2ec45 100644
--- a/ui/app_list/app_list_constants.cc
+++ b/ui/app_list/app_list_constants.cc
@@ -64,12 +64,6 @@ const int kPreferredIconDimension = 48;
const int kExperimentalPreferredCols = 6;
const int kExperimentalPreferredRows = 3;
-// Radius of the circle, in which if entered, show re-order preview.
-const int kReorderDroppingCircleRadius = 35;
-
-// Max items allowed in a folder.
-size_t kMaxFolderItems = 16;
-
// Number of the top items in a folder, which are shown inside the folder icon
// and animated when opening and closing a folder.
const size_t kNumFolderTopItems = 4;
diff --git a/ui/app_list/app_list_constants.h b/ui/app_list/app_list_constants.h
index ed6fba8..8245017 100644
--- a/ui/app_list/app_list_constants.h
+++ b/ui/app_list/app_list_constants.h
@@ -49,9 +49,6 @@ APP_LIST_EXPORT extern const int kPreferredIconDimension;
APP_LIST_EXPORT extern const int kExperimentalPreferredCols;
APP_LIST_EXPORT extern const int kExperimentalPreferredRows;
-APP_LIST_EXPORT extern const int kReorderDroppingCircleRadius;
-
-APP_LIST_EXPORT extern size_t kMaxFolderItems;
APP_LIST_EXPORT extern const size_t kNumFolderTopItems;
APP_LIST_EXPORT extern const ui::ResourceBundle::FontStyle kItemTextFontStyle;
diff --git a/ui/app_list/test/app_list_test_model.cc b/ui/app_list/test/app_list_test_model.cc
index 0e8775b..7a90812 100644
--- a/ui/app_list/test/app_list_test_model.cc
+++ b/ui/app_list/test/app_list_test_model.cc
@@ -69,17 +69,6 @@ void AppListTestModel::PopulateApps(int n) {
CreateAndAddItem(GetItemName(start_index + i));
}
-void AppListTestModel::CreateAndPopulateFolderWithApps(size_t n) {
- DCHECK_GT(n, 1u);
- size_t start_index = top_level_item_list()->item_count();
- AppListTestItem* item = CreateAndAddItem(GetItemName(start_index));
- std::string merged_item_id = item->id();
- for (size_t i = 1; i < n; ++i) {
- AppListTestItem* new_item = CreateAndAddItem(GetItemName(start_index + i));
- merged_item_id = AppListModel::MergeItems(merged_item_id, new_item->id());
- }
-}
-
void AppListTestModel::PopulateAppWithId(int id) {
CreateAndAddItem(GetItemName(id));
}
diff --git a/ui/app_list/test/app_list_test_model.h b/ui/app_list/test/app_list_test_model.h
index 0b6c3f8..c7ef6fa 100644
--- a/ui/app_list/test/app_list_test_model.h
+++ b/ui/app_list/test/app_list_test_model.h
@@ -47,9 +47,6 @@ class AppListTestModel : public AppListModel {
// Populate the model with |n| items titled "Item #".
void PopulateApps(int n);
- // Creates and populate a folder with |n| test apps in it.
- void CreateAndPopulateFolderWithApps(size_t n);
-
// Populate the model with an item titled "Item |id|".
void PopulateAppWithId(int id);
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index 75c6359..da22ef0 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -95,6 +95,11 @@ const int kFolderItemReparentDealy = 50;
// UI.
const int kFolderDroppingCircleRadius = 15;
+// Radius of the circle, in which if entered, show re-order preview.
+const int kReorderDroppingCircleRadius = 35;
+
+// Max items allowed in a folder.
+size_t kMaxFolderItems = 16;
// RowMoveAnimationDelegate is used when moving an item into a different row.
// Before running the animation, the item's layer is re-created and kept in
@@ -2079,7 +2084,7 @@ views::View* AppsGridView::GetViewAtSlotOnCurrentPage(int slot) {
for (int i = 0; i < view_model_.view_size(); ++i) {
views::View* view = view_model_.view_at(i);
- if (view->bounds() == tile_rect && view != drag_view_)
+ if (view->bounds() == tile_rect)
return view;
}
return NULL;
diff --git a/ui/app_list/views/apps_grid_view_unittest.cc b/ui/app_list/views/apps_grid_view_unittest.cc
index 7daed0d..a519674 100644
--- a/ui/app_list/views/apps_grid_view_unittest.cc
+++ b/ui/app_list/views/apps_grid_view_unittest.cc
@@ -14,8 +14,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/timer/timer.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/app_list/app_list_constants.h"
-#include "ui/app_list/app_list_folder_item.h"
#include "ui/app_list/app_list_item.h"
#include "ui/app_list/app_list_model.h"
#include "ui/app_list/app_list_switches.h"
@@ -272,178 +270,6 @@ TEST_F(AppsGridViewTest, MouseDragWithFolderDisabled) {
test_api_->LayoutToIdealBounds();
}
-TEST_F(AppsGridViewTest, MouseDragItemIntoFolder) {
- size_t kTotalItems = 3;
- model_->PopulateApps(kTotalItems);
- EXPECT_EQ(model_->top_level_item_list()->item_count(), kTotalItems);
- EXPECT_EQ(std::string("Item 0,Item 1,Item 2"), model_->GetModelContent());
-
- gfx::Point from = GetItemTileRectAt(0, 1).CenterPoint();
- gfx::Point to = GetItemTileRectAt(0, 0).CenterPoint();
-
- // Dragging item_1 over item_0 creates a folder.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- apps_grid_view_->EndDrag(false);
- EXPECT_EQ(kTotalItems - 1, model_->top_level_item_list()->item_count());
- EXPECT_EQ(AppListFolderItem::kItemType,
- model_->top_level_item_list()->item_at(0)->GetItemType());
- AppListFolderItem* folder_item = static_cast<AppListFolderItem*>(
- model_->top_level_item_list()->item_at(0));
- EXPECT_EQ(2u, folder_item->ChildItemCount());
- AppListItem* item_0 = model_->FindItem("Item 0");
- EXPECT_TRUE(item_0->IsInFolder());
- EXPECT_EQ(folder_item->id(), item_0->folder_id());
- AppListItem* item_1 = model_->FindItem("Item 1");
- EXPECT_TRUE(item_1->IsInFolder());
- EXPECT_EQ(folder_item->id(), item_1->folder_id());
- std::string expected_items = folder_item->id() + ",Item 2";
- EXPECT_EQ(expected_items, model_->GetModelContent());
- test_api_->LayoutToIdealBounds();
-
- // Dragging item_2 to the folder adds item_2 to the folder.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- apps_grid_view_->EndDrag(false);
-
- EXPECT_EQ(kTotalItems - 2, model_->top_level_item_list()->item_count());
- EXPECT_EQ(folder_item->id(), model_->GetModelContent());
- EXPECT_EQ(3u, folder_item->ChildItemCount());
- item_0 = model_->FindItem("Item 0");
- EXPECT_TRUE(item_0->IsInFolder());
- EXPECT_EQ(folder_item->id(), item_0->folder_id());
- item_1 = model_->FindItem("Item 1");
- EXPECT_TRUE(item_1->IsInFolder());
- EXPECT_EQ(folder_item->id(), item_1->folder_id());
- AppListItem* item_2 = model_->FindItem("Item 2");
- EXPECT_TRUE(item_2->IsInFolder());
- EXPECT_EQ(folder_item->id(), item_2->folder_id());
- test_api_->LayoutToIdealBounds();
-}
-
-TEST_F(AppsGridViewTest, MouseDragMaxItemsInFolder) {
- // Create and add a folder with 15 items in it.
- size_t kTotalItems = kMaxFolderItems - 1;
- model_->CreateAndPopulateFolderWithApps(kTotalItems);
- EXPECT_EQ(1u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(AppListFolderItem::kItemType,
- model_->top_level_item_list()->item_at(0)->GetItemType());
- AppListFolderItem* folder_item = static_cast<AppListFolderItem*>(
- model_->top_level_item_list()->item_at(0));
- EXPECT_EQ(kTotalItems, folder_item->ChildItemCount());
-
- // Create and add another 2 items.
- model_->PopulateAppWithId(kTotalItems);
- model_->PopulateAppWithId(kTotalItems + 1);
- EXPECT_EQ(3u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(folder_item->id(), model_->top_level_item_list()->item_at(0)->id());
- EXPECT_EQ(model_->GetItemName(kMaxFolderItems - 1),
- model_->top_level_item_list()->item_at(1)->id());
- EXPECT_EQ(model_->GetItemName(kMaxFolderItems),
- model_->top_level_item_list()->item_at(2)->id());
-
- gfx::Point from = GetItemTileRectAt(0, 1).CenterPoint();
- gfx::Point to = GetItemTileRectAt(0, 0).CenterPoint();
-
- // Dragging one item into the folder, the folder should accept the item.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- apps_grid_view_->EndDrag(false);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(folder_item->id(), model_->top_level_item_list()->item_at(0)->id());
- EXPECT_EQ(kMaxFolderItems, folder_item->ChildItemCount());
- EXPECT_EQ(model_->GetItemName(kMaxFolderItems),
- model_->top_level_item_list()->item_at(1)->id());
- test_api_->LayoutToIdealBounds();
-
- // Dragging the last item over the folder, the folder won't accept the new
- // item, instead, it will re-order the items.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- apps_grid_view_->EndDrag(false);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(model_->GetItemName(kMaxFolderItems),
- model_->top_level_item_list()->item_at(0)->id());
- EXPECT_EQ(folder_item->id(), model_->top_level_item_list()->item_at(1)->id());
- EXPECT_EQ(kMaxFolderItems, folder_item->ChildItemCount());
- test_api_->LayoutToIdealBounds();
-}
-
-TEST_F(AppsGridViewTest, MouseDragItemReorder) {
- size_t kTotalItems = 2;
- model_->PopulateApps(kTotalItems);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(std::string("Item 0,Item 1"), model_->GetModelContent());
-
- gfx::Point from = GetItemTileRectAt(0, 1).CenterPoint();
- int reorder_offset = (GetItemTileRectAt(0, 1).CenterPoint() -
- GetItemTileRectAt(0, 0).CenterPoint()).Length() -
- kReorderDroppingCircleRadius -
- kPreferredIconDimension / 2 + 5;
- gfx::Point to = gfx::Point(from.x() - reorder_offset, from.y());
-
- // Dragging item_1 closing to item_0 should leads to re-ordering these two
- // items.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- apps_grid_view_->EndDrag(false);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(std::string("Item 1,Item 0"), model_->GetModelContent());
- test_api_->LayoutToIdealBounds();
-}
-
-TEST_F(AppsGridViewTest, MouseDragFolderReorder) {
- size_t kTotalItems = 2;
- model_->CreateAndPopulateFolderWithApps(kTotalItems);
- model_->PopulateAppWithId(kTotalItems);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ(AppListFolderItem::kItemType,
- model_->top_level_item_list()->item_at(0)->GetItemType());
- AppListFolderItem* folder_item = static_cast<AppListFolderItem*>(
- model_->top_level_item_list()->item_at(0));
- EXPECT_EQ("Item 2", model_->top_level_item_list()->item_at(1)->id());
-
- gfx::Point from = GetItemTileRectAt(0, 0).CenterPoint();
- gfx::Point to = GetItemTileRectAt(0, 1).CenterPoint();
-
- // Dragging folder over item_1 should leads to re-ordering these two
- // items.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- apps_grid_view_->EndDrag(false);
- EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
- EXPECT_EQ("Item 2", model_->top_level_item_list()->item_at(0)->id());
- EXPECT_EQ(folder_item->id(), model_->top_level_item_list()->item_at(1)->id());
- test_api_->LayoutToIdealBounds();
-}
-
-TEST_F(AppsGridViewTest, MouseDragWithCancelDeleteAddItem) {
- size_t kTotalItems = 4;
- model_->PopulateApps(kTotalItems);
- EXPECT_EQ(model_->top_level_item_list()->item_count(), kTotalItems);
- EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"),
- model_->GetModelContent());
-
- gfx::Point from = GetItemTileRectAt(0, 0).CenterPoint();
- gfx::Point to = GetItemTileRectAt(0, 1).CenterPoint();
-
- // Canceling drag should keep existing order.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- apps_grid_view_->EndDrag(true);
- EXPECT_EQ(std::string("Item 0,Item 1,Item 2,Item 3"),
- model_->GetModelContent());
- test_api_->LayoutToIdealBounds();
-
- // Deleting an item keeps remaining intact.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- model_->DeleteItem(model_->GetItemName(2));
- apps_grid_view_->EndDrag(false);
- EXPECT_EQ(std::string("Item 0,Item 1,Item 3"), model_->GetModelContent());
- test_api_->LayoutToIdealBounds();
-
- // Adding a launcher item cancels the drag and respects the order.
- SimulateDrag(AppsGridView::MOUSE, from, to);
- model_->CreateAndAddItem("Extra");
- apps_grid_view_->EndDrag(false);
- EXPECT_EQ(std::string("Item 0,Item 1,Item 3,Extra"),
- model_->GetModelContent());
- test_api_->LayoutToIdealBounds();
-}
-
TEST_F(AppsGridViewTest, MouseDragFlipPage) {
test_api_->SetPageFlipDelay(10);
pagination_model_->SetTransitionDurations(10, 10);