diff options
Diffstat (limited to 'ui/app_list/test')
-rw-r--r-- | ui/app_list/test/app_list_test_model.cc | 24 | ||||
-rw-r--r-- | ui/app_list/test/app_list_test_model.h | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/ui/app_list/test/app_list_test_model.cc b/ui/app_list/test/app_list_test_model.cc index 6f6bf10..4fd1acc 100644 --- a/ui/app_list/test/app_list_test_model.cc +++ b/ui/app_list/test/app_list_test_model.cc @@ -10,6 +10,9 @@ namespace app_list { namespace test { +// static +const char AppListTestModel::kAppType[] = "FolderItem"; + class AppListTestModel::AppListTestItemModel : public AppListItemModel { public: AppListTestItemModel(const std::string& id, AppListTestModel* model) @@ -22,6 +25,10 @@ class AppListTestModel::AppListTestItemModel : public AppListItemModel { model_->ItemActivated(this); } + virtual const char* GetAppType() const OVERRIDE { + return AppListTestModel::kAppType; + } + private: AppListTestModel* model_; DISALLOW_COPY_AND_ASSIGN(AppListTestItemModel); @@ -38,7 +45,7 @@ std::string AppListTestModel::GetItemName(int id) { } void AppListTestModel::PopulateApps(int n) { - int start_index = apps()->item_count(); + int start_index = item_list()->item_count(); for (int i = 0; i < n; ++i) CreateAndAddItem(GetItemName(start_index + i)); } @@ -49,10 +56,10 @@ void AppListTestModel::PopulateAppWithId(int id) { std::string AppListTestModel::GetModelContent() { std::string content; - for (size_t i = 0; i < apps()->item_count(); ++i) { + for (size_t i = 0; i < item_list()->item_count(); ++i) { if (i > 0) content += ','; - content += apps()->GetItemAt(i)->title(); + content += item_list()->item_at(i)->title(); } return content; } @@ -60,13 +67,20 @@ std::string AppListTestModel::GetModelContent() { AppListItemModel* AppListTestModel::CreateItem(const std::string& title, const std::string& full_name) { AppListItemModel* item = new AppListTestItemModel(title, this); + size_t nitems = item_list()->item_count(); + syncer::StringOrdinal position; + if (nitems == 0) + position = syncer::StringOrdinal::CreateInitialOrdinal(); + else + position = item_list()->item_at(nitems - 1)->position().CreateAfter(); + item->set_position(position); item->SetTitleAndFullName(title, full_name); return item; } void AppListTestModel::CreateAndAddItem(const std::string& title, const std::string& full_name) { - AddItem(CreateItem(title, full_name)); + item_list()->AddItem(CreateItem(title, full_name)); } void AppListTestModel::CreateAndAddItem(const std::string& title) { @@ -74,7 +88,7 @@ void AppListTestModel::CreateAndAddItem(const std::string& title) { } void AppListTestModel::HighlightItemAt(int index) { - AppListItemModel* item = apps()->GetItemAt(index); + AppListItemModel* item = item_list()->item_at(index); item->SetHighlighted(true); } diff --git a/ui/app_list/test/app_list_test_model.h b/ui/app_list/test/app_list_test_model.h index 548072e..473152e 100644 --- a/ui/app_list/test/app_list_test_model.h +++ b/ui/app_list/test/app_list_test_model.h @@ -48,6 +48,8 @@ class AppListTestModel : public AppListModel { int activate_count() { return activate_count_; } AppListItemModel* last_activated() { return last_activated_; } + static const char kAppType[]; + private: class AppListTestItemModel; |