diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 11:58:25 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 11:58:25 +0000 |
commit | cca964332a964fd7e4efb7056612217b11f15ac7 (patch) | |
tree | f2f03d7e9709e176d5408183b927a37f9d23bb36 /ui/app_list/test | |
parent | 21099c4c267a74f481e3742ac7449b334f0aa527 (diff) | |
download | chromium_src-cca964332a964fd7e4efb7056612217b11f15ac7.zip chromium_src-cca964332a964fd7e4efb7056612217b11f15ac7.tar.gz chromium_src-cca964332a964fd7e4efb7056612217b11f15ac7.tar.bz2 |
Add AppListModel::MoveItemToFolderAt
This is necessary to allow items to be moved to a specific locaiton in
a folder (or in the top level model).
This also updates MergeItems() to support source items inside folders.
This includes some cleanup to use scoped ptrs to document ownership of
items in AppListModel.
BUG=335761
For app_list.cc
TBR=jamescook@chromium.org
Review URL: https://codereview.chromium.org/152713003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249373 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list/test')
-rw-r--r-- | ui/app_list/test/app_list_test_model.cc | 37 | ||||
-rw-r--r-- | ui/app_list/test/app_list_test_model.h | 19 |
2 files changed, 39 insertions, 17 deletions
diff --git a/ui/app_list/test/app_list_test_model.cc b/ui/app_list/test/app_list_test_model.cc index d29fc25..8d2868c 100644 --- a/ui/app_list/test/app_list_test_model.cc +++ b/ui/app_list/test/app_list_test_model.cc @@ -4,6 +4,7 @@ #include "ui/app_list/test/app_list_test_model.h" +#include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" namespace app_list { @@ -12,26 +13,26 @@ namespace test { // static const char AppListTestModel::kItemType[] = "TestItem"; -// AppListTestModel::AppListTestItemModel +// AppListTestModel::AppListTestItem -AppListTestModel::AppListTestItemModel::AppListTestItemModel( +AppListTestModel::AppListTestItem::AppListTestItem( const std::string& id, AppListTestModel* model) : AppListItem(id), model_(model) { } -AppListTestModel::AppListTestItemModel::~AppListTestItemModel() { +AppListTestModel::AppListTestItem::~AppListTestItem() { } -void AppListTestModel::AppListTestItemModel::Activate(int event_flags) { +void AppListTestModel::AppListTestItem::Activate(int event_flags) { model_->ItemActivated(this); } -const char* AppListTestModel::AppListTestItemModel::GetItemType() const { +const char* AppListTestModel::AppListTestItem::GetItemType() const { return AppListTestModel::kItemType; } -void AppListTestModel::AppListTestItemModel::SetPosition( +void AppListTestModel::AppListTestItem::SetPosition( const syncer::StringOrdinal& new_position) { set_position(new_position); } @@ -43,6 +44,21 @@ AppListTestModel::AppListTestModel() last_activated_(NULL) { } +AppListItem* AppListTestModel::AddItem(AppListItem* item) { + return AppListModel::AddItem(make_scoped_ptr(item)); +} + +AppListItem* AppListTestModel::AddItemToFolder(AppListItem* item, + const std::string& folder_id) { + return AppListModel::AddItemToFolder(make_scoped_ptr(item), folder_id); +} + +void AppListTestModel::MoveItemToFolder(AppListItem* item, + const std::string& folder_id) { + AppListModel::MoveItemToFolder(item, folder_id); +} + + std::string AppListTestModel::GetItemName(int id) { return base::StringPrintf("Item %d", id); } @@ -67,10 +83,10 @@ std::string AppListTestModel::GetModelContent() { return content; } -AppListTestModel::AppListTestItemModel* AppListTestModel::CreateItem( +AppListTestModel::AppListTestItem* AppListTestModel::CreateItem( const std::string& title, const std::string& full_name) { - AppListTestItemModel* item = new AppListTestItemModel(title, this); + AppListTestItem* item = new AppListTestItem(title, this); size_t nitems = item_list()->item_count(); syncer::StringOrdinal position; if (nitems == 0) @@ -84,7 +100,8 @@ AppListTestModel::AppListTestItemModel* AppListTestModel::CreateItem( void AppListTestModel::CreateAndAddItem(const std::string& title, const std::string& full_name) { - AddItem(CreateItem(title, full_name)); + scoped_ptr<AppListTestItem> test_item(CreateItem(title, full_name)); + AppListModel::AddItem(test_item.PassAs<AppListItem>()); } void AppListTestModel::CreateAndAddItem(const std::string& title) { @@ -96,7 +113,7 @@ void AppListTestModel::HighlightItemAt(int index) { item->SetHighlighted(true); } -void AppListTestModel::ItemActivated(AppListTestItemModel* item) { +void AppListTestModel::ItemActivated(AppListTestItem* item) { last_activated_ = item; ++activate_count_; } diff --git a/ui/app_list/test/app_list_test_model.h b/ui/app_list/test/app_list_test_model.h index 71e73b1..cbc4713 100644 --- a/ui/app_list/test/app_list_test_model.h +++ b/ui/app_list/test/app_list_test_model.h @@ -17,10 +17,10 @@ namespace test { // Extends AppListModel with helper functions for use in tests. class AppListTestModel : public AppListModel { public: - class AppListTestItemModel : public AppListItem { + class AppListTestItem : public AppListItem { public: - AppListTestItemModel(const std::string& id, AppListTestModel* model); - virtual ~AppListTestItemModel(); + AppListTestItem(const std::string& id, AppListTestModel* model); + virtual ~AppListTestItem(); virtual void Activate(int event_flags) OVERRIDE; virtual const char* GetItemType() const OVERRIDE; @@ -29,13 +29,18 @@ class AppListTestModel : public AppListModel { private: AppListTestModel* model_; - DISALLOW_COPY_AND_ASSIGN(AppListTestItemModel); + DISALLOW_COPY_AND_ASSIGN(AppListTestItem); }; static const char kItemType[]; AppListTestModel(); + // Raw pointer version convenience versions of AppListModel methods. + AppListItem* AddItem(AppListItem* item); + AppListItem* AddItemToFolder(AppListItem* item, const std::string& folder_id); + void MoveItemToFolder(AppListItem* item, const std::string& folder_id); + // Generates a name based on |id|. std::string GetItemName(int id); @@ -49,8 +54,8 @@ class AppListTestModel : public AppListModel { std::string GetModelContent(); // Creates an item with |title| and |full_name|. Caller owns the result. - AppListTestItemModel* CreateItem(const std::string& title, - const std::string& full_name); + AppListTestItem* CreateItem(const std::string& title, + const std::string& full_name); // Creates and adds an item with |title| and |full_name| to the model. void CreateAndAddItem(const std::string& title, const std::string& full_name); @@ -65,7 +70,7 @@ class AppListTestModel : public AppListModel { AppListItem* last_activated() { return last_activated_; } private: - void ItemActivated(AppListTestItemModel* item); + void ItemActivated(AppListTestItem* item); int activate_count_; AppListItem* last_activated_; |