OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 "chromeos/dbus/fake_dbus_thread_manager.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "chromeos/chromeos_switches.h" | |
9 #include "chromeos/dbus/cras_audio_client_stub_impl.h" | |
10 #include "chromeos/dbus/cros_disks_client.h" | |
11 #include "chromeos/dbus/dbus_client.h" | |
12 #include "chromeos/dbus/dbus_thread_manager.h" | |
13 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | |
14 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | |
15 #include "chromeos/dbus/fake_bluetooth_device_client.h" | |
16 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" | |
17 #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" | |
18 #include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" | |
19 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" | |
20 #include "chromeos/dbus/fake_bluetooth_input_client.h" | |
21 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" | |
22 #include "chromeos/dbus/fake_cryptohome_client.h" | |
23 #include "chromeos/dbus/fake_debug_daemon_client.h" | |
24 #include "chromeos/dbus/fake_easy_unlock_client.h" | |
25 #include "chromeos/dbus/fake_gsm_sms_client.h" | |
26 #include "chromeos/dbus/fake_image_burner_client.h" | |
27 #include "chromeos/dbus/fake_introspectable_client.h" | |
28 #include "chromeos/dbus/fake_lorgnette_manager_client.h" | |
29 #include "chromeos/dbus/fake_modem_messaging_client.h" | |
30 #include "chromeos/dbus/fake_nfc_adapter_client.h" | |
31 #include "chromeos/dbus/fake_nfc_device_client.h" | |
32 #include "chromeos/dbus/fake_nfc_manager_client.h" | |
33 #include "chromeos/dbus/fake_nfc_record_client.h" | |
34 #include "chromeos/dbus/fake_nfc_tag_client.h" | |
35 #include "chromeos/dbus/fake_permission_broker_client.h" | |
36 #include "chromeos/dbus/fake_shill_device_client.h" | |
37 #include "chromeos/dbus/fake_shill_ipconfig_client.h" | |
38 #include "chromeos/dbus/fake_shill_manager_client.h" | |
39 #include "chromeos/dbus/fake_shill_profile_client.h" | |
40 #include "chromeos/dbus/fake_shill_service_client.h" | |
41 #include "chromeos/dbus/fake_sms_client.h" | |
42 #include "chromeos/dbus/fake_system_clock_client.h" | |
43 #include "chromeos/dbus/power_manager_client.h" | |
44 #include "chromeos/dbus/power_policy_controller.h" | |
45 #include "chromeos/dbus/session_manager_client.h" | |
46 #include "chromeos/dbus/update_engine_client.h" | |
47 | |
48 namespace chromeos { | |
49 | |
50 FakeDBusThreadManager::FakeDBusThreadManager() { | |
51 } | |
52 | |
53 FakeDBusThreadManager::~FakeDBusThreadManager() { | |
54 } | |
55 | |
56 void FakeDBusThreadManager::SetFakeClients() { | |
57 const DBusClientImplementationType client_type = | |
58 STUB_DBUS_CLIENT_IMPLEMENTATION; | |
59 SetBluetoothAdapterClient( | |
60 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); | |
61 SetBluetoothAgentManagerClient(scoped_ptr<BluetoothAgentManagerClient>( | |
62 new FakeBluetoothAgentManagerClient)); | |
63 SetBluetoothDeviceClient( | |
64 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); | |
65 SetBluetoothGattCharacteristicClient( | |
66 scoped_ptr<BluetoothGattCharacteristicClient>( | |
67 new FakeBluetoothGattCharacteristicClient)); | |
68 SetBluetoothGattDescriptorClient(scoped_ptr<BluetoothGattDescriptorClient>( | |
69 new FakeBluetoothGattDescriptorClient)); | |
70 SetBluetoothGattManagerClient(scoped_ptr<BluetoothGattManagerClient>( | |
71 new FakeBluetoothGattManagerClient)); | |
72 SetBluetoothGattServiceClient(scoped_ptr<BluetoothGattServiceClient>( | |
73 new FakeBluetoothGattServiceClient)); | |
74 SetBluetoothInputClient( | |
75 scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); | |
76 SetBluetoothProfileManagerClient(scoped_ptr<BluetoothProfileManagerClient>( | |
77 new FakeBluetoothProfileManagerClient)); | |
78 SetCrosDisksClient( | |
79 scoped_ptr<CrosDisksClient>(CrosDisksClient::Create(client_type))); | |
80 SetCrasAudioClient(scoped_ptr<CrasAudioClient>(new CrasAudioClientStubImpl)); | |
81 SetCryptohomeClient(scoped_ptr<CryptohomeClient>(new FakeCryptohomeClient)); | |
82 SetDebugDaemonClient( | |
83 scoped_ptr<DebugDaemonClient>(new FakeDebugDaemonClient)); | |
84 SetEasyUnlockClient(scoped_ptr<EasyUnlockClient>(new FakeEasyUnlockClient)); | |
85 SetLorgnetteManagerClient( | |
86 scoped_ptr<LorgnetteManagerClient>(new FakeLorgnetteManagerClient)); | |
87 | |
88 SetFakeShillClients(); | |
89 | |
90 FakeGsmSMSClient* gsm_sms_client = new FakeGsmSMSClient(); | |
91 gsm_sms_client->set_sms_test_message_switch_present( | |
92 CommandLine::ForCurrentProcess()->HasSwitch( | |
93 chromeos::switches::kSmsTestMessages)); | |
94 SetGsmSMSClient(scoped_ptr<GsmSMSClient>(gsm_sms_client)); | |
95 | |
96 SetImageBurnerClient( | |
97 scoped_ptr<ImageBurnerClient>(new FakeImageBurnerClient)); | |
98 SetIntrospectableClient( | |
99 scoped_ptr<IntrospectableClient>(new FakeIntrospectableClient)); | |
100 SetModemMessagingClient( | |
101 scoped_ptr<ModemMessagingClient>(new FakeModemMessagingClient)); | |
102 SetNfcAdapterClient(scoped_ptr<NfcAdapterClient>(new FakeNfcAdapterClient)); | |
103 SetNfcDeviceClient(scoped_ptr<NfcDeviceClient>(new FakeNfcDeviceClient)); | |
104 SetNfcManagerClient(scoped_ptr<NfcManagerClient>(new FakeNfcManagerClient)); | |
105 SetNfcRecordClient(scoped_ptr<NfcRecordClient>(new FakeNfcRecordClient)); | |
106 SetNfcTagClient(scoped_ptr<NfcTagClient>(new FakeNfcTagClient)); | |
107 SetPermissionBrokerClient( | |
108 scoped_ptr<PermissionBrokerClient>(new FakePermissionBrokerClient)); | |
109 SetPowerManagerClient( | |
110 scoped_ptr<PowerManagerClient>(PowerManagerClient::Create(client_type))); | |
111 SetSessionManagerClient(scoped_ptr<SessionManagerClient>( | |
112 SessionManagerClient::Create(client_type))); | |
113 SetSMSClient(scoped_ptr<SMSClient>(new FakeSMSClient)); | |
114 SetSystemClockClient( | |
115 scoped_ptr<SystemClockClient>(new FakeSystemClockClient)); | |
116 SetUpdateEngineClient( | |
117 scoped_ptr<UpdateEngineClient>(UpdateEngineClient::Create(client_type))); | |
118 | |
119 SetPowerPolicyController(make_scoped_ptr(new PowerPolicyController)); | |
120 } | |
121 | |
122 void FakeDBusThreadManager::SetFakeShillClients() { | |
123 SetShillManagerClient( | |
124 scoped_ptr<ShillManagerClient>(new FakeShillManagerClient)); | |
125 SetShillDeviceClient( | |
126 scoped_ptr<ShillDeviceClient>(new FakeShillDeviceClient)); | |
127 SetShillIPConfigClient( | |
128 scoped_ptr<ShillIPConfigClient>(new FakeShillIPConfigClient)); | |
129 SetShillServiceClient( | |
130 scoped_ptr<ShillServiceClient>(new FakeShillServiceClient)); | |
131 SetShillProfileClient( | |
132 scoped_ptr<ShillProfileClient>(new FakeShillProfileClient)); | |
133 } | |
134 | |
135 void FakeDBusThreadManager::SetupDefaultEnvironment() { | |
136 ShillManagerClient::TestInterface* manager = | |
137 shill_manager_client_->GetTestInterface(); | |
138 if (manager) | |
139 manager->SetupDefaultEnvironment(); | |
140 } | |
141 | |
142 void FakeDBusThreadManager::SetBluetoothAdapterClient( | |
143 scoped_ptr<BluetoothAdapterClient> client) { | |
144 bluetooth_adapter_client_ = client.Pass(); | |
145 } | |
146 | |
147 void FakeDBusThreadManager::SetBluetoothAgentManagerClient( | |
148 scoped_ptr<BluetoothAgentManagerClient> client) { | |
149 bluetooth_agent_manager_client_ = client.Pass(); | |
150 } | |
151 | |
152 void FakeDBusThreadManager::SetBluetoothDeviceClient( | |
153 scoped_ptr<BluetoothDeviceClient> client) { | |
154 bluetooth_device_client_ = client.Pass(); | |
155 } | |
156 | |
157 void FakeDBusThreadManager::SetBluetoothGattCharacteristicClient( | |
158 scoped_ptr<BluetoothGattCharacteristicClient> client) { | |
159 bluetooth_gatt_characteristic_client_ = client.Pass(); | |
160 } | |
161 | |
162 void FakeDBusThreadManager::SetBluetoothGattDescriptorClient( | |
163 scoped_ptr<BluetoothGattDescriptorClient> client) { | |
164 bluetooth_gatt_descriptor_client_ = client.Pass(); | |
165 } | |
166 | |
167 void FakeDBusThreadManager::SetBluetoothGattManagerClient( | |
168 scoped_ptr<BluetoothGattManagerClient> client) { | |
169 bluetooth_gatt_manager_client_ = client.Pass(); | |
170 } | |
171 | |
172 void FakeDBusThreadManager::SetBluetoothGattServiceClient( | |
173 scoped_ptr<BluetoothGattServiceClient> client) { | |
174 bluetooth_gatt_service_client_ = client.Pass(); | |
175 } | |
176 | |
177 void FakeDBusThreadManager::SetBluetoothInputClient( | |
178 scoped_ptr<BluetoothInputClient> client) { | |
179 bluetooth_input_client_ = client.Pass(); | |
180 } | |
181 | |
182 void FakeDBusThreadManager::SetBluetoothProfileManagerClient( | |
183 scoped_ptr<BluetoothProfileManagerClient> client) { | |
184 bluetooth_profile_manager_client_ = client.Pass(); | |
185 } | |
186 | |
187 void FakeDBusThreadManager::SetCrasAudioClient( | |
188 scoped_ptr<CrasAudioClient> client) { | |
189 cras_audio_client_ = client.Pass(); | |
190 } | |
191 | |
192 void FakeDBusThreadManager::SetCrosDisksClient( | |
193 scoped_ptr<CrosDisksClient> client) { | |
194 cros_disks_client_ = client.Pass(); | |
195 } | |
196 | |
197 void FakeDBusThreadManager::SetCryptohomeClient( | |
198 scoped_ptr<CryptohomeClient> client) { | |
199 cryptohome_client_ = client.Pass(); | |
200 } | |
201 | |
202 void FakeDBusThreadManager::SetDebugDaemonClient( | |
203 scoped_ptr<DebugDaemonClient> client) { | |
204 debug_daemon_client_ = client.Pass(); | |
205 } | |
206 | |
207 void FakeDBusThreadManager::SetEasyUnlockClient( | |
208 scoped_ptr<EasyUnlockClient> client) { | |
209 easy_unlock_client_ = client.Pass(); | |
210 } | |
211 | |
212 void FakeDBusThreadManager::SetLorgnetteManagerClient( | |
213 scoped_ptr<LorgnetteManagerClient> client) { | |
214 lorgnette_manager_client_ = client.Pass(); | |
215 } | |
216 | |
217 void FakeDBusThreadManager::SetShillDeviceClient( | |
218 scoped_ptr<ShillDeviceClient> client) { | |
219 shill_device_client_ = client.Pass(); | |
220 } | |
221 | |
222 void FakeDBusThreadManager::SetShillIPConfigClient( | |
223 scoped_ptr<ShillIPConfigClient> client) { | |
224 shill_ipconfig_client_ = client.Pass(); | |
225 } | |
226 | |
227 void FakeDBusThreadManager::SetShillManagerClient( | |
228 scoped_ptr<ShillManagerClient> client) { | |
229 shill_manager_client_ = client.Pass(); | |
230 } | |
231 | |
232 void FakeDBusThreadManager::SetShillServiceClient( | |
233 scoped_ptr<ShillServiceClient> client) { | |
234 shill_service_client_ = client.Pass(); | |
235 } | |
236 | |
237 void FakeDBusThreadManager::SetShillProfileClient( | |
238 scoped_ptr<ShillProfileClient> client) { | |
239 shill_profile_client_ = client.Pass(); | |
240 } | |
241 | |
242 void FakeDBusThreadManager::SetGsmSMSClient(scoped_ptr<GsmSMSClient> client) { | |
243 gsm_sms_client_ = client.Pass(); | |
244 } | |
245 | |
246 void FakeDBusThreadManager::SetImageBurnerClient( | |
247 scoped_ptr<ImageBurnerClient> client) { | |
248 image_burner_client_ = client.Pass(); | |
249 } | |
250 | |
251 void FakeDBusThreadManager::SetIntrospectableClient( | |
252 scoped_ptr<IntrospectableClient> client) { | |
253 introspectable_client_ = client.Pass(); | |
254 } | |
255 | |
256 void FakeDBusThreadManager::SetModemMessagingClient( | |
257 scoped_ptr<ModemMessagingClient> client) { | |
258 modem_messaging_client_ = client.Pass(); | |
259 } | |
260 | |
261 void FakeDBusThreadManager::SetNfcAdapterClient( | |
262 scoped_ptr<NfcAdapterClient> client) { | |
263 nfc_adapter_client_ = client.Pass(); | |
264 } | |
265 | |
266 void FakeDBusThreadManager::SetNfcDeviceClient( | |
267 scoped_ptr<NfcDeviceClient> client) { | |
268 nfc_device_client_ = client.Pass(); | |
269 } | |
270 | |
271 void FakeDBusThreadManager::SetNfcManagerClient( | |
272 scoped_ptr<NfcManagerClient> client) { | |
273 nfc_manager_client_ = client.Pass(); | |
274 } | |
275 | |
276 void FakeDBusThreadManager::SetNfcRecordClient( | |
277 scoped_ptr<NfcRecordClient> client) { | |
278 nfc_record_client_ = client.Pass(); | |
279 } | |
280 | |
281 void FakeDBusThreadManager::SetNfcTagClient(scoped_ptr<NfcTagClient> client) { | |
282 nfc_tag_client_ = client.Pass(); | |
283 } | |
284 | |
285 void FakeDBusThreadManager::SetPermissionBrokerClient( | |
286 scoped_ptr<PermissionBrokerClient> client) { | |
287 permission_broker_client_ = client.Pass(); | |
288 } | |
289 | |
290 void FakeDBusThreadManager::SetPowerManagerClient( | |
291 scoped_ptr<PowerManagerClient> client) { | |
292 power_manager_client_ = client.Pass(); | |
293 } | |
294 | |
295 void FakeDBusThreadManager::SetPowerPolicyController( | |
296 scoped_ptr<PowerPolicyController> client) { | |
297 power_policy_controller_ = client.Pass(); | |
298 } | |
299 | |
300 void FakeDBusThreadManager::SetSessionManagerClient( | |
301 scoped_ptr<SessionManagerClient> client) { | |
302 session_manager_client_ = client.Pass(); | |
303 } | |
304 | |
305 void FakeDBusThreadManager::SetSMSClient(scoped_ptr<SMSClient> client) { | |
306 sms_client_ = client.Pass(); | |
307 } | |
308 | |
309 void FakeDBusThreadManager::SetSystemClockClient( | |
310 scoped_ptr<SystemClockClient> client) { | |
311 system_clock_client_ = client.Pass(); | |
312 } | |
313 | |
314 void FakeDBusThreadManager::SetUpdateEngineClient( | |
315 scoped_ptr<UpdateEngineClient> client) { | |
316 update_engine_client_ = client.Pass(); | |
317 } | |
318 | |
319 dbus::Bus* FakeDBusThreadManager::GetSystemBus() { | |
320 return NULL; | |
321 } | |
322 | |
323 BluetoothAdapterClient* FakeDBusThreadManager::GetBluetoothAdapterClient() { | |
324 return bluetooth_adapter_client_.get(); | |
325 } | |
326 | |
327 BluetoothAgentManagerClient* | |
328 FakeDBusThreadManager::GetBluetoothAgentManagerClient() { | |
329 return bluetooth_agent_manager_client_.get(); | |
330 } | |
331 | |
332 BluetoothDeviceClient* FakeDBusThreadManager::GetBluetoothDeviceClient() { | |
333 return bluetooth_device_client_.get(); | |
334 } | |
335 | |
336 BluetoothGattCharacteristicClient* | |
337 FakeDBusThreadManager::GetBluetoothGattCharacteristicClient() { | |
338 return bluetooth_gatt_characteristic_client_.get(); | |
339 } | |
340 | |
341 BluetoothGattDescriptorClient* | |
342 FakeDBusThreadManager::GetBluetoothGattDescriptorClient() { | |
343 return bluetooth_gatt_descriptor_client_.get(); | |
344 } | |
345 | |
346 BluetoothGattManagerClient* | |
347 FakeDBusThreadManager::GetBluetoothGattManagerClient() { | |
348 return bluetooth_gatt_manager_client_.get(); | |
349 } | |
350 | |
351 BluetoothGattServiceClient* | |
352 FakeDBusThreadManager::GetBluetoothGattServiceClient() { | |
353 return bluetooth_gatt_service_client_.get(); | |
354 } | |
355 | |
356 BluetoothInputClient* FakeDBusThreadManager::GetBluetoothInputClient() { | |
357 return bluetooth_input_client_.get(); | |
358 } | |
359 | |
360 BluetoothProfileManagerClient* | |
361 FakeDBusThreadManager::GetBluetoothProfileManagerClient() { | |
362 return bluetooth_profile_manager_client_.get(); | |
363 } | |
364 | |
365 CrasAudioClient* FakeDBusThreadManager::GetCrasAudioClient() { | |
366 return cras_audio_client_.get(); | |
367 } | |
368 | |
369 CrosDisksClient* FakeDBusThreadManager::GetCrosDisksClient() { | |
370 return cros_disks_client_.get(); | |
371 } | |
372 | |
373 CryptohomeClient* FakeDBusThreadManager::GetCryptohomeClient() { | |
374 return cryptohome_client_.get(); | |
375 } | |
376 | |
377 DebugDaemonClient* FakeDBusThreadManager::GetDebugDaemonClient() { | |
378 return debug_daemon_client_.get(); | |
379 } | |
380 | |
381 EasyUnlockClient* FakeDBusThreadManager::GetEasyUnlockClient() { | |
382 return easy_unlock_client_.get(); | |
383 } | |
384 LorgnetteManagerClient* FakeDBusThreadManager::GetLorgnetteManagerClient() { | |
385 return lorgnette_manager_client_.get(); | |
386 } | |
387 | |
388 ShillDeviceClient* FakeDBusThreadManager::GetShillDeviceClient() { | |
389 return shill_device_client_.get(); | |
390 } | |
391 | |
392 ShillIPConfigClient* FakeDBusThreadManager::GetShillIPConfigClient() { | |
393 return shill_ipconfig_client_.get(); | |
394 } | |
395 | |
396 ShillManagerClient* FakeDBusThreadManager::GetShillManagerClient() { | |
397 return shill_manager_client_.get(); | |
398 } | |
399 | |
400 ShillProfileClient* FakeDBusThreadManager::GetShillProfileClient() { | |
401 return shill_profile_client_.get(); | |
402 } | |
403 | |
404 ShillServiceClient* FakeDBusThreadManager::GetShillServiceClient() { | |
405 return shill_service_client_.get(); | |
406 } | |
407 | |
408 GsmSMSClient* FakeDBusThreadManager::GetGsmSMSClient() { | |
409 return gsm_sms_client_.get(); | |
410 } | |
411 | |
412 ImageBurnerClient* FakeDBusThreadManager::GetImageBurnerClient() { | |
413 return image_burner_client_.get(); | |
414 } | |
415 | |
416 IntrospectableClient* FakeDBusThreadManager::GetIntrospectableClient() { | |
417 return introspectable_client_.get(); | |
418 } | |
419 | |
420 ModemMessagingClient* FakeDBusThreadManager::GetModemMessagingClient() { | |
421 return modem_messaging_client_.get(); | |
422 } | |
423 | |
424 NfcAdapterClient* FakeDBusThreadManager::GetNfcAdapterClient() { | |
425 return nfc_adapter_client_.get(); | |
426 } | |
427 | |
428 NfcDeviceClient* FakeDBusThreadManager::GetNfcDeviceClient() { | |
429 return nfc_device_client_.get(); | |
430 } | |
431 | |
432 NfcManagerClient* FakeDBusThreadManager::GetNfcManagerClient() { | |
433 return nfc_manager_client_.get(); | |
434 } | |
435 | |
436 NfcTagClient* FakeDBusThreadManager::GetNfcTagClient() { | |
437 return nfc_tag_client_.get(); | |
438 } | |
439 | |
440 NfcRecordClient* FakeDBusThreadManager::GetNfcRecordClient() { | |
441 return nfc_record_client_.get(); | |
442 } | |
443 | |
444 PermissionBrokerClient* FakeDBusThreadManager::GetPermissionBrokerClient() { | |
445 return permission_broker_client_.get(); | |
446 } | |
447 | |
448 PowerManagerClient* FakeDBusThreadManager::GetPowerManagerClient() { | |
449 return power_manager_client_.get(); | |
450 } | |
451 | |
452 PowerPolicyController* FakeDBusThreadManager::GetPowerPolicyController() { | |
453 return power_policy_controller_.get(); | |
454 } | |
455 | |
456 SessionManagerClient* FakeDBusThreadManager::GetSessionManagerClient() { | |
457 return session_manager_client_.get(); | |
458 } | |
459 | |
460 SMSClient* FakeDBusThreadManager::GetSMSClient() { | |
461 return sms_client_.get(); | |
462 } | |
463 | |
464 SystemClockClient* FakeDBusThreadManager::GetSystemClockClient() { | |
465 return system_clock_client_.get(); | |
466 } | |
467 | |
468 UpdateEngineClient* FakeDBusThreadManager::GetUpdateEngineClient() { | |
469 return update_engine_client_.get(); | |
470 } | |
471 | |
472 } // namespace chromeos | |
OLD | NEW |