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

Side by Side Diff: ui/app_list/test/app_list_test_model.cc

Issue 220393003: Add a unit test for resetting the app list on a reshow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trent_whole_app_list_unit_test
Patch Set: remove APP_LIST_EXPORTs Created 6 years, 7 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 unified diff | Download patch
OLDNEW
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 "grit/ui_resources.h"
10 #include "ui/base/resource/resource_bundle.h"
9 11
10 namespace app_list { 12 namespace app_list {
11 namespace test { 13 namespace test {
12 14
13 // static 15 // static
14 const char AppListTestModel::kItemType[] = "TestItem"; 16 const char AppListTestModel::kItemType[] = "TestItem";
15 17
16 // AppListTestModel::AppListTestItem 18 // AppListTestModel::AppListTestItem
17 19
18 AppListTestModel::AppListTestItem::AppListTestItem( 20 AppListTestModel::AppListTestItem::AppListTestItem(
19 const std::string& id, 21 const std::string& id,
20 AppListTestModel* model) 22 AppListTestModel* model)
21 : AppListItem(id), 23 : AppListItem(id),
22 model_(model) { 24 model_(model) {
25 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
26 SetIcon(*rb.GetImageNamed(IDR_DEFAULT_FAVICON_32).ToImageSkia(), false);
23 } 27 }
28
24 AppListTestModel::AppListTestItem::~AppListTestItem() { 29 AppListTestModel::AppListTestItem::~AppListTestItem() {
25 } 30 }
26 31
27 void AppListTestModel::AppListTestItem::Activate(int event_flags) { 32 void AppListTestModel::AppListTestItem::Activate(int event_flags) {
28 model_->ItemActivated(this); 33 model_->ItemActivated(this);
29 } 34 }
30 35
31 const char* AppListTestModel::AppListTestItem::GetItemType() const { 36 const char* AppListTestModel::AppListTestItem::GetItemType() const {
32 return AppListTestModel::kItemType; 37 return AppListTestModel::kItemType;
33 } 38 }
(...skipping 13 matching lines...) Expand all
47 AppListItem* AppListTestModel::AddItem(AppListItem* item) { 52 AppListItem* AppListTestModel::AddItem(AppListItem* item) {
48 return AppListModel::AddItem(make_scoped_ptr(item)); 53 return AppListModel::AddItem(make_scoped_ptr(item));
49 } 54 }
50 55
51 AppListItem* AppListTestModel::AddItemToFolder(AppListItem* item, 56 AppListItem* AppListTestModel::AddItemToFolder(AppListItem* item,
52 const std::string& folder_id) { 57 const std::string& folder_id) {
53 return AppListModel::AddItemToFolder(make_scoped_ptr(item), folder_id); 58 return AppListModel::AddItemToFolder(make_scoped_ptr(item), folder_id);
54 } 59 }
55 60
56 void AppListTestModel::MoveItemToFolder(AppListItem* item, 61 void AppListTestModel::MoveItemToFolder(AppListItem* item,
57 const std::string& folder_id) { 62 const std::string& folder_id) {
58 AppListModel::MoveItemToFolder(item, folder_id); 63 AppListModel::MoveItemToFolder(item, folder_id);
59 } 64 }
60 65
61 66
62 std::string AppListTestModel::GetItemName(int id) { 67 std::string AppListTestModel::GetItemName(int id) {
63 return base::StringPrintf("Item %d", id); 68 return base::StringPrintf("Item %d", id);
64 } 69 }
65 70
66 void AppListTestModel::PopulateApps(int n) { 71 void AppListTestModel::PopulateApps(int n) {
67 int start_index = static_cast<int>(top_level_item_list()->item_count()); 72 int start_index = static_cast<int>(top_level_item_list()->item_count());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 item->SetHighlighted(true); 136 item->SetHighlighted(true);
132 } 137 }
133 138
134 void AppListTestModel::ItemActivated(AppListTestItem* item) { 139 void AppListTestModel::ItemActivated(AppListTestItem* item) {
135 last_activated_ = item; 140 last_activated_ = item;
136 ++activate_count_; 141 ++activate_count_;
137 } 142 }
138 143
139 } // namespace test 144 } // namespace test
140 } // namespace app_list 145 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698