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.
5 #include "chromeos/dbus/fake_dbus_thread_manager.h"
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"
50 FakeDBusThreadManager::FakeDBusThreadManager() {
53 FakeDBusThreadManager::~FakeDBusThreadManager() {
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));
79 scoped_ptr<CrosDisksClient>(CrosDisksClient::Create(client_type)));
80 SetCrasAudioClient(scoped_ptr<CrasAudioClient>(new CrasAudioClientStubImpl));
81 SetCryptohomeClient(scoped_ptr<CryptohomeClient>(new FakeCryptohomeClient));
83 scoped_ptr<DebugDaemonClient>(new FakeDebugDaemonClient));
84 SetEasyUnlockClient(scoped_ptr<EasyUnlockClient>(new FakeEasyUnlockClient));
85 SetLorgnetteManagerClient(
86 scoped_ptr<LorgnetteManagerClient>(new FakeLorgnetteManagerClient));
88 SetFakeShillClients();
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));
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)));
119 SetPowerPolicyController(make_scoped_ptr(new PowerPolicyController));
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));
135 void FakeDBusThreadManager::SetupDefaultEnvironment() {
136 ShillManagerClient::TestInterface* manager =
137 shill_manager_client_->GetTestInterface();
139 manager->SetupDefaultEnvironment();
142 void FakeDBusThreadManager::SetBluetoothAdapterClient(
143 scoped_ptr<BluetoothAdapterClient> client) {
144 bluetooth_adapter_client_ = client.Pass();
147 void FakeDBusThreadManager::SetBluetoothAgentManagerClient(
148 scoped_ptr<BluetoothAgentManagerClient> client) {
149 bluetooth_agent_manager_client_ = client.Pass();
152 void FakeDBusThreadManager::SetBluetoothDeviceClient(
153 scoped_ptr<BluetoothDeviceClient> client) {
154 bluetooth_device_client_ = client.Pass();
157 void FakeDBusThreadManager::SetBluetoothGattCharacteristicClient(
158 scoped_ptr<BluetoothGattCharacteristicClient> client) {
159 bluetooth_gatt_characteristic_client_ = client.Pass();
162 void FakeDBusThreadManager::SetBluetoothGattDescriptorClient(
163 scoped_ptr<BluetoothGattDescriptorClient> client) {
164 bluetooth_gatt_descriptor_client_ = client.Pass();
167 void FakeDBusThreadManager::SetBluetoothGattManagerClient(
168 scoped_ptr<BluetoothGattManagerClient> client) {
169 bluetooth_gatt_manager_client_ = client.Pass();
172 void FakeDBusThreadManager::SetBluetoothGattServiceClient(
173 scoped_ptr<BluetoothGattServiceClient> client) {
174 bluetooth_gatt_service_client_ = client.Pass();
177 void FakeDBusThreadManager::SetBluetoothInputClient(
178 scoped_ptr<BluetoothInputClient> client) {
179 bluetooth_input_client_ = client.Pass();
182 void FakeDBusThreadManager::SetBluetoothProfileManagerClient(
183 scoped_ptr<BluetoothProfileManagerClient> client) {
184 bluetooth_profile_manager_client_ = client.Pass();
187 void FakeDBusThreadManager::SetCrasAudioClient(
188 scoped_ptr<CrasAudioClient> client) {
189 cras_audio_client_ = client.Pass();
192 void FakeDBusThreadManager::SetCrosDisksClient(
193 scoped_ptr<CrosDisksClient> client) {
194 cros_disks_client_ = client.Pass();
197 void FakeDBusThreadManager::SetCryptohomeClient(
198 scoped_ptr<CryptohomeClient> client) {
199 cryptohome_client_ = client.Pass();
202 void FakeDBusThreadManager::SetDebugDaemonClient(
203 scoped_ptr<DebugDaemonClient> client) {
204 debug_daemon_client_ = client.Pass();
207 void FakeDBusThreadManager::SetEasyUnlockClient(
208 scoped_ptr<EasyUnlockClient> client) {
209 easy_unlock_client_ = client.Pass();
212 void FakeDBusThreadManager::SetLorgnetteManagerClient(
213 scoped_ptr<LorgnetteManagerClient> client) {
214 lorgnette_manager_client_ = client.Pass();
217 void FakeDBusThreadManager::SetShillDeviceClient(
218 scoped_ptr<ShillDeviceClient> client) {
219 shill_device_client_ = client.Pass();
222 void FakeDBusThreadManager::SetShillIPConfigClient(
223 scoped_ptr<ShillIPConfigClient> client) {
224 shill_ipconfig_client_ = client.Pass();
227 void FakeDBusThreadManager::SetShillManagerClient(
228 scoped_ptr<ShillManagerClient> client) {
229 shill_manager_client_ = client.Pass();
232 void FakeDBusThreadManager::SetShillServiceClient(
233 scoped_ptr<ShillServiceClient> client) {
234 shill_service_client_ = client.Pass();
237 void FakeDBusThreadManager::SetShillProfileClient(
238 scoped_ptr<ShillProfileClient> client) {
239 shill_profile_client_ = client.Pass();
242 void FakeDBusThreadManager::SetGsmSMSClient(scoped_ptr<GsmSMSClient> client) {
243 gsm_sms_client_ = client.Pass();
246 void FakeDBusThreadManager::SetImageBurnerClient(
247 scoped_ptr<ImageBurnerClient> client) {
248 image_burner_client_ = client.Pass();
251 void FakeDBusThreadManager::SetIntrospectableClient(
252 scoped_ptr<IntrospectableClient> client) {
253 introspectable_client_ = client.Pass();
256 void FakeDBusThreadManager::SetModemMessagingClient(
257 scoped_ptr<ModemMessagingClient> client) {
258 modem_messaging_client_ = client.Pass();
261 void FakeDBusThreadManager::SetNfcAdapterClient(
262 scoped_ptr<NfcAdapterClient> client) {
263 nfc_adapter_client_ = client.Pass();
266 void FakeDBusThreadManager::SetNfcDeviceClient(
267 scoped_ptr<NfcDeviceClient> client) {
268 nfc_device_client_ = client.Pass();
271 void FakeDBusThreadManager::SetNfcManagerClient(
272 scoped_ptr<NfcManagerClient> client) {
273 nfc_manager_client_ = client.Pass();
276 void FakeDBusThreadManager::SetNfcRecordClient(
277 scoped_ptr<NfcRecordClient> client) {
278 nfc_record_client_ = client.Pass();
281 void FakeDBusThreadManager::SetNfcTagClient(scoped_ptr<NfcTagClient> client) {
282 nfc_tag_client_ = client.Pass();
285 void FakeDBusThreadManager::SetPermissionBrokerClient(
286 scoped_ptr<PermissionBrokerClient> client) {
287 permission_broker_client_ = client.Pass();
290 void FakeDBusThreadManager::SetPowerManagerClient(
291 scoped_ptr<PowerManagerClient> client) {
292 power_manager_client_ = client.Pass();
295 void FakeDBusThreadManager::SetPowerPolicyController(
296 scoped_ptr<PowerPolicyController> client) {
297 power_policy_controller_ = client.Pass();
300 void FakeDBusThreadManager::SetSessionManagerClient(
301 scoped_ptr<SessionManagerClient> client) {
302 session_manager_client_ = client.Pass();
305 void FakeDBusThreadManager::SetSMSClient(scoped_ptr<SMSClient> client) {
306 sms_client_ = client.Pass();
309 void FakeDBusThreadManager::SetSystemClockClient(
310 scoped_ptr<SystemClockClient> client) {
311 system_clock_client_ = client.Pass();
314 void FakeDBusThreadManager::SetUpdateEngineClient(
315 scoped_ptr<UpdateEngineClient> client) {
316 update_engine_client_ = client.Pass();
319 dbus::Bus* FakeDBusThreadManager::GetSystemBus() {
323 BluetoothAdapterClient* FakeDBusThreadManager::GetBluetoothAdapterClient() {
324 return bluetooth_adapter_client_.get();
327 BluetoothAgentManagerClient*
328 FakeDBusThreadManager::GetBluetoothAgentManagerClient() {
329 return bluetooth_agent_manager_client_.get();
332 BluetoothDeviceClient* FakeDBusThreadManager::GetBluetoothDeviceClient() {
333 return bluetooth_device_client_.get();
336 BluetoothGattCharacteristicClient*
337 FakeDBusThreadManager::GetBluetoothGattCharacteristicClient() {
338 return bluetooth_gatt_characteristic_client_.get();
341 BluetoothGattDescriptorClient*
342 FakeDBusThreadManager::GetBluetoothGattDescriptorClient() {
343 return bluetooth_gatt_descriptor_client_.get();
346 BluetoothGattManagerClient*
347 FakeDBusThreadManager::GetBluetoothGattManagerClient() {
348 return bluetooth_gatt_manager_client_.get();
351 BluetoothGattServiceClient*
352 FakeDBusThreadManager::GetBluetoothGattServiceClient() {
353 return bluetooth_gatt_service_client_.get();
356 BluetoothInputClient* FakeDBusThreadManager::GetBluetoothInputClient() {
357 return bluetooth_input_client_.get();
360 BluetoothProfileManagerClient*
361 FakeDBusThreadManager::GetBluetoothProfileManagerClient() {
362 return bluetooth_profile_manager_client_.get();
365 CrasAudioClient* FakeDBusThreadManager::GetCrasAudioClient() {
366 return cras_audio_client_.get();
369 CrosDisksClient* FakeDBusThreadManager::GetCrosDisksClient() {
370 return cros_disks_client_.get();
373 CryptohomeClient* FakeDBusThreadManager::GetCryptohomeClient() {
374 return cryptohome_client_.get();
377 DebugDaemonClient* FakeDBusThreadManager::GetDebugDaemonClient() {
378 return debug_daemon_client_.get();
381 EasyUnlockClient* FakeDBusThreadManager::GetEasyUnlockClient() {
382 return easy_unlock_client_.get();
384 LorgnetteManagerClient* FakeDBusThreadManager::GetLorgnetteManagerClient() {
385 return lorgnette_manager_client_.get();
388 ShillDeviceClient* FakeDBusThreadManager::GetShillDeviceClient() {
389 return shill_device_client_.get();
392 ShillIPConfigClient* FakeDBusThreadManager::GetShillIPConfigClient() {
393 return shill_ipconfig_client_.get();
396 ShillManagerClient* FakeDBusThreadManager::GetShillManagerClient() {
397 return shill_manager_client_.get();
400 ShillProfileClient* FakeDBusThreadManager::GetShillProfileClient() {
401 return shill_profile_client_.get();
404 ShillServiceClient* FakeDBusThreadManager::GetShillServiceClient() {
405 return shill_service_client_.get();
408 GsmSMSClient* FakeDBusThreadManager::GetGsmSMSClient() {
409 return gsm_sms_client_.get();
412 ImageBurnerClient* FakeDBusThreadManager::GetImageBurnerClient() {
413 return image_burner_client_.get();
416 IntrospectableClient* FakeDBusThreadManager::GetIntrospectableClient() {
417 return introspectable_client_.get();
420 ModemMessagingClient* FakeDBusThreadManager::GetModemMessagingClient() {
421 return modem_messaging_client_.get();
424 NfcAdapterClient* FakeDBusThreadManager::GetNfcAdapterClient() {
425 return nfc_adapter_client_.get();
428 NfcDeviceClient* FakeDBusThreadManager::GetNfcDeviceClient() {
429 return nfc_device_client_.get();
432 NfcManagerClient* FakeDBusThreadManager::GetNfcManagerClient() {
433 return nfc_manager_client_.get();
436 NfcTagClient* FakeDBusThreadManager::GetNfcTagClient() {
437 return nfc_tag_client_.get();
440 NfcRecordClient* FakeDBusThreadManager::GetNfcRecordClient() {
441 return nfc_record_client_.get();
444 PermissionBrokerClient* FakeDBusThreadManager::GetPermissionBrokerClient() {
445 return permission_broker_client_.get();
448 PowerManagerClient* FakeDBusThreadManager::GetPowerManagerClient() {
449 return power_manager_client_.get();
452 PowerPolicyController* FakeDBusThreadManager::GetPowerPolicyController() {
453 return power_policy_controller_.get();
456 SessionManagerClient* FakeDBusThreadManager::GetSessionManagerClient() {
457 return session_manager_client_.get();
460 SMSClient* FakeDBusThreadManager::GetSMSClient() {
461 return sms_client_.get();
464 SystemClockClient* FakeDBusThreadManager::GetSystemClockClient() {
465 return system_clock_client_.get();
468 UpdateEngineClient* FakeDBusThreadManager::GetUpdateEngineClient() {
469 return update_engine_client_.get();
472 } // namespace chromeos