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

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

Issue 1534423002: Revert of arc-bridge: Move most methods to Mojo interfaces (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: 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
7 namespace arc { 11 namespace arc {
8 12
9 FakeArcBridgeService::FakeArcBridgeService() { 13 FakeArcBridgeService::FakeArcBridgeService() {
10 } 14 }
11 15
12 FakeArcBridgeService::~FakeArcBridgeService() { 16 FakeArcBridgeService::~FakeArcBridgeService() {
13 if (state() != State::STOPPED) { 17 if (state() != State::STOPPED) {
14 SetState(State::STOPPED); 18 SetState(State::STOPPED);
15 } 19 }
16 } 20 }
17 21
18 void FakeArcBridgeService::DetectAvailability() { 22 void FakeArcBridgeService::DetectAvailability() {
19 } 23 }
20 24
21 void FakeArcBridgeService::HandleStartup() { 25 void FakeArcBridgeService::HandleStartup() {
22 } 26 }
23 27
24 void FakeArcBridgeService::Shutdown() { 28 void FakeArcBridgeService::Shutdown() {
25 } 29 }
26 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::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
27 void FakeArcBridgeService::SetReady() { 72 void FakeArcBridgeService::SetReady() {
28 SetState(State::READY); 73 SetState(State::READY);
29 } 74 }
30 75
31 void FakeArcBridgeService::SetStopped() { 76 void FakeArcBridgeService::SetStopped() {
32 SetState(State::STOPPED); 77 SetState(State::STOPPED);
33 } 78 }
34 79
35 bool FakeArcBridgeService::HasObserver(const Observer* observer) { 80 bool FakeArcBridgeService::HasObserver(const Observer* observer) {
36 return observer_list().HasObserver(observer); 81 return observer_list().HasObserver(observer);
37 } 82 }
38 83
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
39 } // namespace arc 156 } // 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