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

Unified Diff: ui/app_list/apps_grid_view_unittest.cc

Issue 10892017: app_list: Fix crash after uninstalling last app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test Created 8 years, 4 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/apps_grid_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/apps_grid_view_unittest.cc
diff --git a/ui/app_list/apps_grid_view_unittest.cc b/ui/app_list/apps_grid_view_unittest.cc
index 763ea14a58372486267169260630e34e02cc665c..7b34584959540c66f0203a6679ff0172a0750fba 100644
--- a/ui/app_list/apps_grid_view_unittest.cc
+++ b/ui/app_list/apps_grid_view_unittest.cc
@@ -68,6 +68,11 @@ class AppsGridViewTest : public testing::Test {
item->SetHighlighted(true);
}
+ AppListItemView* GetItemViewAt(int index) {
+ DCHECK(index >= 0 && index < apps_grid_view_->child_count());
+ return static_cast<AppListItemView*>(apps_grid_view_->child_at(index));
+ }
+
scoped_ptr<AppListModel::Apps> apps_model_;
scoped_ptr<PaginationModel> pagination_model_;
scoped_ptr<AppsGridView> apps_grid_view_;
@@ -109,5 +114,23 @@ TEST_F(AppsGridViewTest, EnsureHighlightedVisible) {
EXPECT_EQ(kPages - 1, pagination_model_->selected_page());
}
+TEST_F(AppsGridViewTest, RemoveSelectedLastApp) {
+ const int kTotalItems = 2;
+ const int kLastItemIndex = kTotalItems - 1;
+
+ PopulateApps(kTotalItems);
+
+ AppListItemView* last_item = GetItemViewAt(kLastItemIndex);
+ apps_grid_view_->SetSelectedItem(last_item);
+ apps_model_->DeleteAt(kLastItemIndex);
+
+ EXPECT_FALSE(apps_grid_view_->IsSelectedItem(last_item));
+
+ // No crash happens.
+ AppListItemView* item = GetItemViewAt(0);
+ apps_grid_view_->SetSelectedItem(item);
+ EXPECT_TRUE(apps_grid_view_->IsSelectedItem(item));
+}
+
} // namespace test
} // namespace app_list
« no previous file with comments | « ui/app_list/apps_grid_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698