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

Unified Diff: ui/app_list/test/app_list_test_model.cc

Issue 27438002: Store AppItems as pages in AppListModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 2 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
Index: ui/app_list/test/app_list_test_model.cc
diff --git a/ui/app_list/test/app_list_test_model.cc b/ui/app_list/test/app_list_test_model.cc
index dd7cab40bc523f541c7cf1da408099629f64b31d..a295da28a8be9d3ccb04c713ccc0c0c8a522a9bc 100644
--- a/ui/app_list/test/app_list_test_model.cc
+++ b/ui/app_list/test/app_list_test_model.cc
@@ -33,21 +33,31 @@ AppListTestModel::AppListTestModel()
SetSignedIn(true);
}
+std::string AppListTestModel::GetItemName(int id) {
+ return base::StringPrintf("Item %d", id);
+}
+
void AppListTestModel::PopulateApps(int n) {
+ int start_index = 0;
+ for (size_t p = 0; p < GetNumAppPages(); ++p)
+ start_index += GetAppItems(p).item_count();
for (int i = 0; i < n; ++i)
- AddItem(base::StringPrintf("Item %d", i));
+ CreateAndAddItem(GetItemName(start_index + i));
}
void AppListTestModel::PopulateAppWithId(int id) {
- AddItem(base::StringPrintf("Item %d", id));
+ CreateAndAddItem(GetItemName(id));
}
std::string AppListTestModel::GetModelContent() {
std::string content;
- for (size_t i = 0; i < apps()->item_count(); ++i) {
- if (i > 0)
- content += ',';
- content += apps()->GetItemAt(i)->title();
+ for (size_t p = 0; p < GetNumAppPages(); ++p) {
+ const AppItems& apps = GetAppItems(p);
+ for (size_t i = 0; i < apps.item_count(); ++i) {
+ if (i > 0)
+ content += ',';
+ content += apps.GetItemAt(i)->title();
+ }
}
return content;
}
@@ -59,17 +69,17 @@ AppListItemModel* AppListTestModel::CreateItem(const std::string& title,
return item;
}
-void AppListTestModel::AddItem(const std::string& title) {
- apps()->Add(CreateItem(title, title));
+void AppListTestModel::CreateAndAddItem(const std::string& title,
+ const std::string& full_name) {
+ AddItem(CreateItem(title, full_name));
}
-void AppListTestModel::AddItem(const std::string& title,
- const std::string& full_name) {
- apps()->Add(CreateItem(title, full_name));
+void AppListTestModel::CreateAndAddItem(const std::string& title) {
+ CreateAndAddItem(title, title);
}
void AppListTestModel::HighlightItemAt(int index) {
- AppListItemModel* item = apps()->GetItemAt(index);
+ AppListItemModel* item = GetItemAt(0, index);
item->SetHighlighted(true);
}

Powered by Google App Engine
This is Rietveld 408576698