Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: ui/app_list/app_list_model_unittest.cc

Issue 600393002: AppListModel / AppsGridView: Better error handling for corner cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@appsgridview-static-casts
Patch Set: Comment. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/app_list_model.cc ('k') | ui/app_list/views/apps_grid_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/app_list_model_unittest.cc
diff --git a/ui/app_list/app_list_model_unittest.cc b/ui/app_list/app_list_model_unittest.cc
index b88a964fe2c64097eaa70850a73c0d97a9c7c805..05dbfbb00dccfd45156b7a3f4aea6a726157a54d 100644
--- a/ui/app_list/app_list_model_unittest.cc
+++ b/ui/app_list/app_list_model_unittest.cc
@@ -292,6 +292,20 @@ TEST_F(AppListModelFolderTest, MergeItems) {
AppListItem* item1 = model_.top_level_item_list()->item_at(1);
AppListItem* item2 = model_.top_level_item_list()->item_at(2);
+ // Merge an item onto a non-existent target.
+ EXPECT_EQ(std::string(), model_.MergeItems("nonexistent", item0->id()));
+ ASSERT_EQ(3u, model_.top_level_item_list()->item_count());
+
+ // Merge a non-existent item onto a target.
+ EXPECT_EQ(std::string(), model_.MergeItems(item0->id(), "nonexistent"));
+ ASSERT_EQ(3u, model_.top_level_item_list()->item_count());
+
+ // Merge an item onto itself (should have no effect). This should not be
+ // possible, but there have been bugs in the past that made it possible (see
+ // http://crbug.com/415530), so it should be handled correctly.
+ EXPECT_EQ(std::string(), model_.MergeItems(item0->id(), item0->id()));
+ ASSERT_EQ(3u, model_.top_level_item_list()->item_count());
+
// Merge two items.
std::string folder1_id = model_.MergeItems(item0->id(), item1->id());
ASSERT_EQ(2u, model_.top_level_item_list()->item_count()); // Folder + 1 item
@@ -299,6 +313,13 @@ TEST_F(AppListModelFolderTest, MergeItems) {
ASSERT_TRUE(folder1_item);
EXPECT_EQ("Item 0,Item 1", GetItemListContents(folder1_item->item_list()));
+ // Merge an item onto an item that is already in a folder (should have no
+ // effect). This should not be possible, but it should be handled correctly
+ // if it does happen.
+ EXPECT_EQ(std::string(), model_.MergeItems(item1->id(), item2->id()));
+ ASSERT_EQ(2u, model_.top_level_item_list()->item_count()); // Folder + 1 item
+ EXPECT_EQ("Item 0,Item 1", GetItemListContents(folder1_item->item_list()));
+
// Merge an item from the new folder into the third item.
std::string folder2_id = model_.MergeItems(item2->id(), item1->id());
ASSERT_EQ(2u, model_.top_level_item_list()->item_count()); // 2 folders
@@ -315,6 +336,7 @@ TEST_F(AppListModelFolderTest, MergeItems) {
// The empty folder should be deleted.
folder1_item = model_.FindFolderItem(folder1_id);
EXPECT_FALSE(folder1_item);
+ EXPECT_EQ(1u, model_.top_level_item_list()->item_count()); // 1 folder
}
TEST_F(AppListModelFolderTest, AddItemToFolder) {
« no previous file with comments | « ui/app_list/app_list_model.cc ('k') | ui/app_list/views/apps_grid_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698