Revert of Cleanup: Remove remaining generated extensions APIs on Android. (patchset...
[chromium-blink-merge.git] / athena / test / test_app_model_builder.cc
blobc4b53871634a82d0adc5c8867b5b634c0a1b748e
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "athena/test/test_app_model_builder.h"
7 #include "ui/app_list/app_list_item.h"
8 #include "ui/app_list/app_list_model.h"
10 namespace athena {
12 namespace {
14 const int kIconSize = 64;
16 class DummyItem : public app_list::AppListItem {
17 public:
18 enum Type {
19 DUMMY_MAIL,
20 DUMMY_CALENDAR,
21 DUMMY_VIDEO,
22 DUMMY_MUSIC,
23 DUMMY_CONTACT,
24 LAST_TYPE,
27 static std::string GetTitle(Type type) {
28 switch (type) {
29 case DUMMY_MAIL:
30 return "mail";
31 case DUMMY_CALENDAR:
32 return "calendar";
33 case DUMMY_VIDEO:
34 return "video";
35 case DUMMY_MUSIC:
36 return "music";
37 case DUMMY_CONTACT:
38 return "contact";
39 case LAST_TYPE:
40 break;
42 NOTREACHED();
43 return "";
46 static std::string GetId(Type type) {
47 return std::string("id-") + GetTitle(type);
50 explicit DummyItem(Type type)
51 : app_list::AppListItem(GetId(type)),
52 type_(type) {
53 SetIcon(GetIcon(), false /* has_shadow */);
54 SetName(GetTitle(type_));
57 private:
58 gfx::ImageSkia GetIcon() const {
59 SkColor color = SK_ColorWHITE;
60 switch (type_) {
61 case DUMMY_MAIL:
62 color = SK_ColorRED;
63 break;
64 case DUMMY_CALENDAR:
65 color = SK_ColorBLUE;
66 break;
67 case DUMMY_VIDEO:
68 color = SK_ColorGREEN;
69 break;
70 case DUMMY_MUSIC:
71 color = SK_ColorYELLOW;
72 break;
73 case DUMMY_CONTACT:
74 color = SK_ColorCYAN;
75 break;
76 case LAST_TYPE:
77 NOTREACHED();
78 break;
80 SkBitmap bitmap;
81 bitmap.allocN32Pixels(kIconSize, kIconSize);
82 bitmap.eraseColor(color);
83 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
86 Type type_;
88 DISALLOW_COPY_AND_ASSIGN(DummyItem);
91 } // namespace
93 TestAppModelBuilder::TestAppModelBuilder() {
96 TestAppModelBuilder::~TestAppModelBuilder() {
99 void TestAppModelBuilder::PopulateApps(app_list::AppListModel* model) {
100 for (int i = 0; i < static_cast<int>(DummyItem::LAST_TYPE); ++i) {
101 model->AddItem(scoped_ptr<app_list::AppListItem>(
102 new DummyItem(static_cast<DummyItem::Type>(i))));
106 } // namespace athena