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

Unified Diff: ui/app_list/test/app_list_test_model.cc

Issue 298963004: app_list: Fix possible out of bounds index. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK -> CHECK 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/test/app_list_test_model.h ('k') | ui/app_list/views/app_list_main_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/test/app_list_test_model.cc
diff --git a/ui/app_list/test/app_list_test_model.cc b/ui/app_list/test/app_list_test_model.cc
index 70b60a882f930ac8aec194fe6ed1af6a042912e7..9a81aab40014917b9183e358394a082b830319df 100644
--- a/ui/app_list/test/app_list_test_model.cc
+++ b/ui/app_list/test/app_list_test_model.cc
@@ -7,11 +7,22 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "grit/ui_resources.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/app_list/app_list_constants.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image_skia.h"
namespace app_list {
namespace test {
+gfx::ImageSkia CreateImageSkia(int width, int height) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.allocPixels();
+ bitmap.eraseARGB(255, 0, 255, 0);
+ return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
+}
+
// static
const char AppListTestModel::kItemType[] = "TestItem";
@@ -22,6 +33,8 @@ AppListTestModel::AppListTestItem::AppListTestItem(
AppListTestModel* model)
: AppListItem(id),
model_(model) {
+ SetIcon(CreateImageSkia(kPreferredIconDimension, kPreferredIconDimension),
+ false /* has_shadow */);
}
AppListTestModel::AppListTestItem::~AppListTestItem() {
@@ -93,6 +106,16 @@ AppListFolderItem* AppListTestModel::CreateAndAddOemFolder(
return static_cast<AppListFolderItem*>(AddItem(folder));
}
+AppListFolderItem* AppListTestModel::CreateSingleItemFolder(
+ const std::string& folder_id,
+ const std::string& item_id) {
+ AppListTestItem* item = CreateItem(item_id);
+ AddItemToFolder(item, folder_id);
+ AppListItem* folder_item = FindItem(folder_id);
+ DCHECK(folder_item->GetItemType() == AppListFolderItem::kItemType);
+ return static_cast<AppListFolderItem*>(folder_item);
+}
+
void AppListTestModel::PopulateAppWithId(int id) {
CreateAndAddItem(GetItemName(id));
}
« no previous file with comments | « ui/app_list/test/app_list_test_model.h ('k') | ui/app_list/views/app_list_main_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698