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

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

Issue 1523643002: arc-bridge: Move most methods to Mojo interfaces (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Rebased to ToT 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') | 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/arc/test/fake_arc_bridge_service.h" 5 #include "components/arc/test/fake_arc_bridge_service.h"
6 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 { 7 namespace arc {
12 8
13 FakeArcBridgeService::FakeArcBridgeService() { 9 FakeArcBridgeService::FakeArcBridgeService() {
14 } 10 }
15 11
16 FakeArcBridgeService::~FakeArcBridgeService() { 12 FakeArcBridgeService::~FakeArcBridgeService() {
17 if (state() != State::STOPPED) { 13 if (state() != State::STOPPED) {
18 SetState(State::STOPPED); 14 SetState(State::STOPPED);
19 } 15 }
20 } 16 }
21 17
22 void FakeArcBridgeService::DetectAvailability() { 18 void FakeArcBridgeService::DetectAvailability() {
23 } 19 }
24 20
25 void FakeArcBridgeService::HandleStartup() { 21 void FakeArcBridgeService::HandleStartup() {
26 } 22 }
27 23
28 void FakeArcBridgeService::Shutdown() { 24 void FakeArcBridgeService::Shutdown() {
29 } 25 }
30 26
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::SendBroadcast(const std::string& action,
38 const std::string& package,
39 const std::string& clazz,
40 const base::DictionaryValue& extras) {
41 return true;
42 }
43
44 bool FakeArcBridgeService::SendNotificationEventToAndroid(
45 const std::string& key,
46 ArcNotificationEvent event) {
47 return true;
48 }
49
50 bool FakeArcBridgeService::RefreshAppList() {
51 ++refresh_app_list_count_;
52 return true;
53 }
54
55 bool FakeArcBridgeService::LaunchApp(const std::string& package,
56 const std::string& activity) {
57 launch_requests_.push_back(new Request(package, activity));
58 return true;
59 }
60
61 bool FakeArcBridgeService::RequestAppIcon(const std::string& package,
62 const std::string& activity,
63 ScaleFactor scale_factor) {
64 icon_requests_.push_back(new IconRequest(package, activity, scale_factor));
65 return true;
66 }
67
68 bool FakeArcBridgeService::RequestProcessList() {
69 return true;
70 }
71
72 void FakeArcBridgeService::SetReady() { 27 void FakeArcBridgeService::SetReady() {
73 SetState(State::READY); 28 SetState(State::READY);
74 } 29 }
75 30
76 void FakeArcBridgeService::SetStopped() { 31 void FakeArcBridgeService::SetStopped() {
77 SetState(State::STOPPED); 32 SetState(State::STOPPED);
78 } 33 }
79 34
80 bool FakeArcBridgeService::HasObserver(const Observer* observer) { 35 bool FakeArcBridgeService::HasObserver(const Observer* observer) {
81 return observer_list().HasObserver(observer); 36 return observer_list().HasObserver(observer);
82 } 37 }
83 38
84 bool FakeArcBridgeService::HasAppObserver(const AppObserver* observer) {
85 return app_observer_list().HasObserver(observer);
86 }
87
88 void FakeArcBridgeService::SendRefreshAppList(
89 const std::vector<AppInfo>& apps) {
90 FOR_EACH_OBSERVER(AppObserver, app_observer_list(), OnAppListRefreshed(apps));
91 }
92
93 bool FakeArcBridgeService::GenerateAndSendIcon(
94 const AppInfo& app,
95 ScaleFactor scale_factor,
96 std::string* png_data_as_string) {
97 CHECK(png_data_as_string != nullptr);
98 std::string icon_file_name;
99 switch (scale_factor) {
100 case SCALE_FACTOR_SCALE_FACTOR_100P:
101 icon_file_name = "icon_100p.png";
102 break;
103 case SCALE_FACTOR_SCALE_FACTOR_125P:
104 icon_file_name = "icon_125p.png";
105 break;
106 case SCALE_FACTOR_SCALE_FACTOR_133P:
107 icon_file_name = "icon_133p.png";
108 break;
109 case SCALE_FACTOR_SCALE_FACTOR_140P:
110 icon_file_name = "icon_140p.png";
111 break;
112 case SCALE_FACTOR_SCALE_FACTOR_150P:
113 icon_file_name = "icon_150p.png";
114 break;
115 case SCALE_FACTOR_SCALE_FACTOR_180P:
116 icon_file_name = "icon_180p.png";
117 break;
118 case SCALE_FACTOR_SCALE_FACTOR_200P:
119 icon_file_name = "icon_200p.png";
120 break;
121 case SCALE_FACTOR_SCALE_FACTOR_250P:
122 icon_file_name = "icon_250p.png";
123 break;
124 case SCALE_FACTOR_SCALE_FACTOR_300P:
125 icon_file_name = "icon_300p.png";
126 break;
127 default:
128 NOTREACHED();
129 return false;
130 }
131
132 base::FilePath base_path;
133 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &base_path));
134 base::FilePath icon_file_path = base_path
135 .AppendASCII("components")
136 .AppendASCII("test")
137 .AppendASCII("data")
138 .AppendASCII("arc")
139 .AppendASCII(icon_file_name);
140 CHECK(base::PathExists(icon_file_path));
141 CHECK(base::ReadFileToString(icon_file_path, png_data_as_string));
142
143 std::vector<uint8_t> png_data(png_data_as_string->begin(),
144 png_data_as_string->end());
145
146 FOR_EACH_OBSERVER(AppObserver,
147 app_observer_list(),
148 OnAppIcon(app.package,
149 app.activity,
150 scale_factor,
151 png_data));
152
153 return true;
154 }
155
156 } // namespace arc 39 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/test/fake_arc_bridge_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698