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

Side by Side Diff: athena/test/test_app_model_builder.cc

Issue 311113005: AppModelBuilder to athena. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « athena/test/test_app_model_builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "athena/test/test_app_model_builder.h"
6
7 #include "ui/app_list/app_list_item.h"
8 #include "ui/app_list/app_list_model.h"
9
10 namespace athena {
11
12 namespace {
13
14 const int kIconSize = 64;
15
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,
25 };
26
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;
41 }
42 NOTREACHED();
43 return "";
44 }
45
46 static std::string GetId(Type type) {
47 return std::string("id-") + GetTitle(type);
48 }
49
50 explicit DummyItem(Type type)
51 : app_list::AppListItem(GetId(type)),
52 type_(type) {
53 SetIcon(GetIcon(), false /* has_shadow */);
54 SetName(GetTitle(type_));
55 }
56
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;
79 }
80 SkBitmap bitmap;
81 bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize);
82 bitmap.allocPixels();
83 bitmap.eraseColor(color);
84 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
85 }
86
87 Type type_;
88
89 DISALLOW_COPY_AND_ASSIGN(DummyItem);
90 };
91
92 } // namespace
93
94 TestAppModelBuilder::TestAppModelBuilder() {
95 }
96
97 TestAppModelBuilder::~TestAppModelBuilder() {
98 }
99
100 void TestAppModelBuilder::PopulateApps(app_list::AppListModel* model) {
101 for (int i = 0; i < static_cast<int>(DummyItem::LAST_TYPE); ++i) {
102 model->AddItem(scoped_ptr<app_list::AppListItem>(
103 new DummyItem(static_cast<DummyItem::Type>(i))));
104 }
105 }
106
107 } // namespace athena
OLDNEW
« no previous file with comments | « athena/test/test_app_model_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698