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

Side by Side Diff: components/arc/test/fake_arc_bridge_service.cc

Issue 1413153007: arc-app-launcher: Minimal support for ARC app launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing links to BUILD.gn Created 5 years 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
« no previous file with comments | « components/arc/test/fake_arc_bridge_service.h ('k') | components/test/data/arc/icon_100p.png » ('j') | 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 2015 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 "components/arc/test/fake_arc_bridge_service.h"
6
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "base/path_service.h"
10
11 namespace arc {
12
13 FakeArcBridgeService::FakeArcBridgeService() {
14 }
15
16 FakeArcBridgeService::~FakeArcBridgeService() {
17 if (state() != State::STOPPED) {
18 SetState(State::STOPPED);
19 }
20 }
21
22 void FakeArcBridgeService::DetectAvailability() {
23 }
24
25 void FakeArcBridgeService::HandleStartup() {
26 }
27
28 void FakeArcBridgeService::Shutdown() {
29 }
30
31 bool FakeArcBridgeService::RegisterInputDevice(const std::string& name,
32 const std::string& device_type,
33 base::ScopedFD fd) {
34 return true;
35 }
36
37 bool FakeArcBridgeService::SendNotificationEventToAndroid(
38 const std::string& key,
39 ArcNotificationEvent event) {
40 return true;
41 }
42
43 bool FakeArcBridgeService::RefreshAppList() {
44 ++refresh_app_list_count_;
45 return true;
46 }
47
48 bool FakeArcBridgeService::LaunchApp(const std::string& package,
49 const std::string& activity) {
50 launch_requests_.push_back(new Request(package, activity));
51 return true;
52 }
53
54 bool FakeArcBridgeService::RequestAppIcon(const std::string& package,
55 const std::string& activity,
56 ScaleFactor scale_factor) {
57 icon_requests_.push_back(new IconRequest(package, activity, scale_factor));
58 return true;
59 }
60
61 void FakeArcBridgeService::SetReady() {
62 SetState(State::READY);
63 }
64
65 void FakeArcBridgeService::SetStopped() {
66 SetState(State::STOPPED);
67 }
68
69 bool FakeArcBridgeService::HasObserver(const Observer* observer) {
70 return observer_list().HasObserver(observer);
71 }
72
73 bool FakeArcBridgeService::HasAppObserver(const AppObserver* observer) {
74 return app_observer_list().HasObserver(observer);
75 }
76
77 void FakeArcBridgeService::SendRefreshAppList(
78 const std::vector<AppInfo>& apps) {
79 FOR_EACH_OBSERVER(AppObserver, app_observer_list(), OnAppListRefreshed(apps));
80 }
81
82 bool FakeArcBridgeService::GenerateAndSendIcon(
83 const AppInfo& app,
84 ScaleFactor scale_factor,
85 std::string* png_data_as_string) {
86 CHECK(png_data_as_string != nullptr);
87 std::string icon_file_name;
88 switch(scale_factor) {
89 case SCALE_FACTOR_100P:
90 icon_file_name = "icon_100p.png";
91 break;
92 case SCALE_FACTOR_125P:
93 icon_file_name = "icon_125p.png";
94 break;
95 case SCALE_FACTOR_133P:
96 icon_file_name = "icon_133p.png";
97 break;
98 case SCALE_FACTOR_140P:
99 icon_file_name = "icon_140p.png";
100 break;
101 case SCALE_FACTOR_150P:
102 icon_file_name = "icon_150p.png";
103 break;
104 case SCALE_FACTOR_180P:
105 icon_file_name = "icon_180p.png";
106 break;
107 case SCALE_FACTOR_200P:
108 icon_file_name = "icon_200p.png";
109 break;
110 case SCALE_FACTOR_250P:
111 icon_file_name = "icon_250p.png";
112 break;
113 case SCALE_FACTOR_300P:
114 icon_file_name = "icon_300p.png";
115 break;
116 default:
117 NOTREACHED();
118 return false;
119 }
120
121 base::FilePath base_path;
122 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &base_path));
123 base::FilePath icon_file_path = base_path
124 .AppendASCII("components")
125 .AppendASCII("test")
126 .AppendASCII("data")
127 .AppendASCII("arc")
128 .AppendASCII(icon_file_name);
129 CHECK(base::PathExists(icon_file_path));
130 CHECK(base::ReadFileToString(icon_file_path, png_data_as_string));
131
132 std::vector<uint8_t> png_data(png_data_as_string->begin(),
133 png_data_as_string->end());
134
135 FOR_EACH_OBSERVER(AppObserver,
136 app_observer_list(),
137 OnAppIcon(app.package,
138 app.activity,
139 scale_factor,
140 png_data));
141
142 return true;
143 }
144
145 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/test/fake_arc_bridge_service.h ('k') | components/test/data/arc/icon_100p.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698