Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/app_list/test/app_list_test_model.h" | 5 #include "ui/app_list/test/app_list_test_model.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "ui/gfx/image/image_skia.h" | |
| 9 | 10 |
| 10 namespace app_list { | 11 namespace app_list { |
| 11 namespace test { | 12 namespace test { |
| 12 | 13 |
| 13 // static | 14 // static |
| 14 const char AppListTestModel::kItemType[] = "TestItem"; | 15 const char AppListTestModel::kItemType[] = "TestItem"; |
| 15 | 16 |
| 16 // AppListTestModel::AppListTestItem | 17 // AppListTestModel::AppListTestItem |
| 17 | 18 |
| 18 AppListTestModel::AppListTestItem::AppListTestItem( | 19 AppListTestModel::AppListTestItem::AppListTestItem( |
| 19 const std::string& id, | 20 const std::string& id, |
| 20 AppListTestModel* model) | 21 AppListTestModel* model) |
| 21 : AppListItem(id), | 22 : AppListItem(id), |
| 22 model_(model) { | 23 model_(model) { |
| 24 SkBitmap bitmap; | |
|
tapted
2014/04/01 06:28:27
In my demo code I'm doing
ui::ResourceBundle& r
calamity
2014/04/01 08:08:46
Done.
| |
| 25 const int kBitmapSize = 48; | |
| 26 bitmap.setConfig(SkBitmap::kARGB_8888_Config, kBitmapSize, kBitmapSize); | |
| 27 SetIcon(gfx::ImageSkia::CreateFrom1xBitmap(bitmap), false); | |
| 23 } | 28 } |
| 29 | |
| 24 AppListTestModel::AppListTestItem::~AppListTestItem() { | 30 AppListTestModel::AppListTestItem::~AppListTestItem() { |
| 25 } | 31 } |
| 26 | 32 |
| 27 void AppListTestModel::AppListTestItem::Activate(int event_flags) { | 33 void AppListTestModel::AppListTestItem::Activate(int event_flags) { |
| 28 model_->ItemActivated(this); | 34 model_->ItemActivated(this); |
| 29 } | 35 } |
| 30 | 36 |
| 31 const char* AppListTestModel::AppListTestItem::GetItemType() const { | 37 const char* AppListTestModel::AppListTestItem::GetItemType() const { |
| 32 return AppListTestModel::kItemType; | 38 return AppListTestModel::kItemType; |
| 33 } | 39 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 47 AppListItem* AppListTestModel::AddItem(AppListItem* item) { | 53 AppListItem* AppListTestModel::AddItem(AppListItem* item) { |
| 48 return AppListModel::AddItem(make_scoped_ptr(item)); | 54 return AppListModel::AddItem(make_scoped_ptr(item)); |
| 49 } | 55 } |
| 50 | 56 |
| 51 AppListItem* AppListTestModel::AddItemToFolder(AppListItem* item, | 57 AppListItem* AppListTestModel::AddItemToFolder(AppListItem* item, |
| 52 const std::string& folder_id) { | 58 const std::string& folder_id) { |
| 53 return AppListModel::AddItemToFolder(make_scoped_ptr(item), folder_id); | 59 return AppListModel::AddItemToFolder(make_scoped_ptr(item), folder_id); |
| 54 } | 60 } |
| 55 | 61 |
| 56 void AppListTestModel::MoveItemToFolder(AppListItem* item, | 62 void AppListTestModel::MoveItemToFolder(AppListItem* item, |
| 57 const std::string& folder_id) { | 63 const std::string& folder_id) { |
| 58 AppListModel::MoveItemToFolder(item, folder_id); | 64 AppListModel::MoveItemToFolder(item, folder_id); |
| 59 } | 65 } |
| 60 | 66 |
| 61 | 67 |
| 62 std::string AppListTestModel::GetItemName(int id) { | 68 std::string AppListTestModel::GetItemName(int id) { |
| 63 return base::StringPrintf("Item %d", id); | 69 return base::StringPrintf("Item %d", id); |
| 64 } | 70 } |
| 65 | 71 |
| 66 void AppListTestModel::PopulateApps(int n) { | 72 void AppListTestModel::PopulateApps(int n) { |
| 67 int start_index = static_cast<int>(top_level_item_list()->item_count()); | 73 int start_index = static_cast<int>(top_level_item_list()->item_count()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 item->SetHighlighted(true); | 137 item->SetHighlighted(true); |
| 132 } | 138 } |
| 133 | 139 |
| 134 void AppListTestModel::ItemActivated(AppListTestItem* item) { | 140 void AppListTestModel::ItemActivated(AppListTestItem* item) { |
| 135 last_activated_ = item; | 141 last_activated_ = item; |
| 136 ++activate_count_; | 142 ++activate_count_; |
| 137 } | 143 } |
| 138 | 144 |
| 139 } // namespace test | 145 } // namespace test |
| 140 } // namespace app_list | 146 } // namespace app_list |
| OLD | NEW |