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 | 9 |
10 namespace app_list { | 10 namespace app_list { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 std::string AppListTestModel::GetItemName(int id) { | 62 std::string AppListTestModel::GetItemName(int id) { |
63 return base::StringPrintf("Item %d", id); | 63 return base::StringPrintf("Item %d", id); |
64 } | 64 } |
65 | 65 |
66 void AppListTestModel::PopulateApps(int n) { | 66 void AppListTestModel::PopulateApps(int n) { |
67 int start_index = static_cast<int>(top_level_item_list()->item_count()); | 67 int start_index = static_cast<int>(top_level_item_list()->item_count()); |
68 for (int i = 0; i < n; ++i) | 68 for (int i = 0; i < n; ++i) |
69 CreateAndAddItem(GetItemName(start_index + i)); | 69 CreateAndAddItem(GetItemName(start_index + i)); |
70 } | 70 } |
71 | 71 |
72 void AppListTestModel::CreateAndPopulateFolderWithApps(int n) { | 72 AppListFolderItem* AppListTestModel::CreateAndPopulateFolderWithApps(int n) { |
73 DCHECK_GT(n, 1); | 73 DCHECK_GT(n, 1); |
74 int start_index = static_cast<int>(top_level_item_list()->item_count()); | 74 int start_index = static_cast<int>(top_level_item_list()->item_count()); |
75 AppListTestItem* item = CreateAndAddItem(GetItemName(start_index)); | 75 AppListTestItem* item = CreateAndAddItem(GetItemName(start_index)); |
76 std::string merged_item_id = item->id(); | 76 std::string merged_item_id = item->id(); |
77 for (int i = 1; i < n; ++i) { | 77 for (int i = 1; i < n; ++i) { |
78 AppListTestItem* new_item = CreateAndAddItem(GetItemName(start_index + i)); | 78 AppListTestItem* new_item = CreateAndAddItem(GetItemName(start_index + i)); |
79 merged_item_id = AppListModel::MergeItems(merged_item_id, new_item->id()); | 79 merged_item_id = AppListModel::MergeItems(merged_item_id, new_item->id()); |
80 } | 80 } |
| 81 AppListItem* merged_item = FindItem(merged_item_id); |
| 82 DCHECK(merged_item->GetItemType() == AppListFolderItem::kItemType); |
| 83 return static_cast<AppListFolderItem*>(merged_item); |
| 84 } |
| 85 |
| 86 AppListFolderItem* AppListTestModel::CreateAndAddOemFolder( |
| 87 const std::string& id) { |
| 88 AppListFolderItem* folder = |
| 89 new AppListFolderItem(id, AppListFolderItem::FOLDER_TYPE_OEM); |
| 90 return static_cast<AppListFolderItem*>(AddItem(folder)); |
81 } | 91 } |
82 | 92 |
83 void AppListTestModel::PopulateAppWithId(int id) { | 93 void AppListTestModel::PopulateAppWithId(int id) { |
84 CreateAndAddItem(GetItemName(id)); | 94 CreateAndAddItem(GetItemName(id)); |
85 } | 95 } |
86 | 96 |
87 std::string AppListTestModel::GetModelContent() { | 97 std::string AppListTestModel::GetModelContent() { |
88 std::string content; | 98 std::string content; |
89 for (size_t i = 0; i < top_level_item_list()->item_count(); ++i) { | 99 for (size_t i = 0; i < top_level_item_list()->item_count(); ++i) { |
90 if (i > 0) | 100 if (i > 0) |
(...skipping 30 matching lines...) Expand all Loading... |
121 item->SetHighlighted(true); | 131 item->SetHighlighted(true); |
122 } | 132 } |
123 | 133 |
124 void AppListTestModel::ItemActivated(AppListTestItem* item) { | 134 void AppListTestModel::ItemActivated(AppListTestItem* item) { |
125 last_activated_ = item; | 135 last_activated_ = item; |
126 ++activate_count_; | 136 ++activate_count_; |
127 } | 137 } |
128 | 138 |
129 } // namespace test | 139 } // namespace test |
130 } // namespace app_list | 140 } // namespace app_list |
OLD | NEW |