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) { |