Index: ui/app_list/cocoa/apps_grid_controller_unittest.mm |
diff --git a/ui/app_list/cocoa/apps_grid_controller_unittest.mm b/ui/app_list/cocoa/apps_grid_controller_unittest.mm |
index 9ef2daecde1079c40b7ea875b8b857cb22b7e886..ab99477b3cb2db3557bfb583bab236e02aa9e77b 100644 |
--- a/ui/app_list/cocoa/apps_grid_controller_unittest.mm |
+++ b/ui/app_list/cocoa/apps_grid_controller_unittest.mm |
@@ -429,15 +429,15 @@ TEST_F(AppsGridControllerTest, ModelUpdates) { |
EXPECT_EQ(2u, [[GetPageAt(0) content] count]); |
EXPECT_EQ(std::string("|Item 0,Item 1|"), GetViewContent()); |
- // Add an item (PopulateApps will create a duplicate "Item 0"). |
+ // Add an item (PopulateApps will create a new "Item 2"). |
model()->PopulateApps(1); |
EXPECT_EQ(3u, [[GetPageAt(0) content] count]); |
NSButton* button = GetItemViewAt(2); |
- EXPECT_NSEQ(@"Item 0", [button title]); |
- EXPECT_EQ(std::string("|Item 0,Item 1,Item 0|"), GetViewContent()); |
+ EXPECT_NSEQ(@"Item 2", [button title]); |
+ EXPECT_EQ(std::string("|Item 0,Item 1,Item 2|"), GetViewContent()); |
// Update the title via the ItemModelObserver. |
- app_list::AppListItemModel* item_model = model()->apps()->GetItemAt(2); |
+ app_list::AppListItemModel* item_model = model()->GetItemAt(0, 2); |
item_model->SetTitleAndFullName("UpdatedItem", "UpdatedItem"); |
EXPECT_NSEQ(@"UpdatedItem", [button title]); |
EXPECT_EQ(std::string("|Item 0,Item 1,UpdatedItem|"), GetViewContent()); |
@@ -458,37 +458,32 @@ TEST_F(AppsGridControllerTest, ModelUpdates) { |
EXPECT_EQ(kTargetImageSize, icon_size.height); |
// Test removing an item at the end. |
- model()->apps()->DeleteAt(2); |
+ model()->DeleteItemAt(0, 2); |
EXPECT_EQ(2u, [apps_grid_controller_ itemCount]); |
EXPECT_EQ(std::string("|Item 0,Item 1|"), GetViewContent()); |
// Test removing in the middle. |
- model()->AddItem("Item 2"); |
+ model()->CreateAndAddItem("Item 2"); |
EXPECT_EQ(3u, [apps_grid_controller_ itemCount]); |
EXPECT_EQ(std::string("|Item 0,Item 1,Item 2|"), GetViewContent()); |
- model()->apps()->DeleteAt(1); |
+ model()->DeleteItemAt(0, 1); |
EXPECT_EQ(2u, [apps_grid_controller_ itemCount]); |
EXPECT_EQ(std::string("|Item 0,Item 2|"), GetViewContent()); |
- // Test inserting in the middle. |
- model()->apps()->AddAt(1, model()->CreateItem("Item One", "Item One")); |
+ // Test adding an item at the end. |
+ model()->CreateAndAddItem("Item Three"); |
EXPECT_EQ(3u, [apps_grid_controller_ itemCount]); |
- EXPECT_EQ(std::string("|Item 0,Item One,Item 2|"), GetViewContent()); |
+ EXPECT_EQ(std::string("|Item 0,Item 2,Item Three|"), GetViewContent()); |
// Test swapping items (e.g. rearranging via sync). |
- model()->apps()->Move(1, 2); |
- EXPECT_EQ(std::string("|Item 0,Item 2,Item One|"), GetViewContent()); |
- |
- // Test removing multiple items via the model. |
- model()->apps()->DeleteAll(); |
- EXPECT_EQ(0u, [apps_grid_controller_ itemCount]); |
- EXPECT_EQ(std::string("||"), GetViewContent()); |
+ model()->MoveItem(0, 1, 0, 2); |
+ EXPECT_EQ(std::string("|Item 0,Item Three,Item 2|"), GetViewContent()); |
// Test removing the last item when there is one item on the second page. |
ReplaceTestModel(kItemsPerPage + 1); |
EXPECT_EQ(kItemsPerPage + 1, [apps_grid_controller_ itemCount]); |
EXPECT_EQ(2u, [apps_grid_controller_ pageCount]); |
- model()->apps()->DeleteAt(kItemsPerPage); |
+ model()->DeleteItemAt(1, 0); |
EXPECT_EQ(kItemsPerPage, [apps_grid_controller_ itemCount]); |
EXPECT_EQ(1u, [apps_grid_controller_ pageCount]); |
} |
@@ -498,8 +493,7 @@ TEST_F(AppsGridControllerTest, ItemInstallProgress) { |
ReplaceTestModel(kItemsPerPage + 1); |
EXPECT_EQ(2u, [apps_grid_controller_ pageCount]); |
EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); |
- app_list::AppListItemModel* item_model = |
- model()->apps()->GetItemAt(kItemsPerPage); |
+ app_list::AppListItemModel* item_model = model()->GetItemAt(1, 0); |
// Highlighting an item should activate the page it is on. |
item_model->SetHighlighted(true); |
@@ -535,7 +529,7 @@ TEST_F(AppsGridControllerTest, ItemInstallProgress) { |
// Two things can be installing simultaneously. When one starts or completes |
// the model builder will ask for the item to be highlighted. |
app_list::AppListItemModel* alternate_item_model = |
- model()->apps()->GetItemAt(0); |
+ model()->GetItemAt(0, 0); |
item_model->SetHighlighted(false); |
alternate_item_model->SetHighlighted(true); |
EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); |
@@ -602,7 +596,8 @@ TEST_F(AppsGridControllerTest, PaginationObserverPagesChanged) { |
EXPECT_EQ(2, [observer totalPagesChangedCount]); |
EXPECT_EQ(1u, [apps_grid_controller_ pageCount]); |
ReplaceTestModel(kItemsPerPage * 3 + 1); |
- EXPECT_EQ(3, [observer totalPagesChangedCount]); |
+ // 4 pages = 3 additional page changes |
+ EXPECT_EQ(5, [observer totalPagesChangedCount]); |
EXPECT_EQ(4u, [apps_grid_controller_ pageCount]); |
EXPECT_FALSE([observer readVisibilityDidChange]); |
@@ -619,7 +614,8 @@ TEST_F(AppsGridControllerTest, PaginationObserverSelectedPageChanged) { |
EXPECT_EQ(0, [[NSAnimationContext currentContext] duration]); |
ReplaceTestModel(kItemsPerPage * 3 + 1); |
- EXPECT_EQ(1, [observer totalPagesChangedCount]); |
+ // 4 pages = 3 page changes |
+ EXPECT_EQ(3, [observer totalPagesChangedCount]); |
EXPECT_EQ(4u, [apps_grid_controller_ pageCount]); |
EXPECT_FALSE([observer readVisibilityDidChange]); |
@@ -906,8 +902,8 @@ TEST_F(AppsGridControllerTest, ScrollingWhileDragging) { |
TEST_F(AppsGridControllerTest, ContextMenus) { |
AppListItemWithMenu* item_two_model = new AppListItemWithMenu("Item Two"); |
- model()->apps()->AddAt(0, new AppListItemWithMenu("Item One")); |
- model()->apps()->AddAt(1, item_two_model); |
+ model()->AddItem(new AppListItemWithMenu("Item One")); |
+ model()->AddItem(item_two_model); |
EXPECT_EQ(2u, [apps_grid_controller_ itemCount]); |
NSCollectionView* page = [apps_grid_controller_ collectionViewAtPageIndex:0]; |