blob: c4b53871634a82d0adc5c8867b5b634c0a1b748e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/test/test_app_model_builder.h"
#include "ui/app_list/app_list_item.h"
#include "ui/app_list/app_list_model.h"
namespace athena {
namespace {
const int kIconSize = 64;
class DummyItem : public app_list::AppListItem {
public:
enum Type {
DUMMY_MAIL,
DUMMY_CALENDAR,
DUMMY_VIDEO,
DUMMY_MUSIC,
DUMMY_CONTACT,
LAST_TYPE,
};
static std::string GetTitle(Type type) {
switch (type) {
case DUMMY_MAIL:
return "mail";
case DUMMY_CALENDAR:
return "calendar";
case DUMMY_VIDEO:
return "video";
case DUMMY_MUSIC:
return "music";
case DUMMY_CONTACT:
return "contact";
case LAST_TYPE:
break;
}
NOTREACHED();
return "";
}
static std::string GetId(Type type) {
return std::string("id-") + GetTitle(type);
}
explicit DummyItem(Type type)
: app_list::AppListItem(GetId(type)),
type_(type) {
SetIcon(GetIcon(), false /* has_shadow */);
SetName(GetTitle(type_));
}
private:
gfx::ImageSkia GetIcon() const {
SkColor color = SK_ColorWHITE;
switch (type_) {
case DUMMY_MAIL:
color = SK_ColorRED;
break;
case DUMMY_CALENDAR:
color = SK_ColorBLUE;
break;
case DUMMY_VIDEO:
color = SK_ColorGREEN;
break;
case DUMMY_MUSIC:
color = SK_ColorYELLOW;
break;
case DUMMY_CONTACT:
color = SK_ColorCYAN;
break;
case LAST_TYPE:
NOTREACHED();
break;
}
SkBitmap bitmap;
bitmap.allocN32Pixels(kIconSize, kIconSize);
bitmap.eraseColor(color);
return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
}
Type type_;
DISALLOW_COPY_AND_ASSIGN(DummyItem);
};
} // namespace
TestAppModelBuilder::TestAppModelBuilder() {
}
TestAppModelBuilder::~TestAppModelBuilder() {
}
void TestAppModelBuilder::PopulateApps(app_list::AppListModel* model) {
for (int i = 0; i < static_cast<int>(DummyItem::LAST_TYPE); ++i) {
model->AddItem(scoped_ptr<app_list::AppListItem>(
new DummyItem(static_cast<DummyItem::Type>(i))));
}
}
} // namespace athena
|