// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromeos/dbus/fake_dbus_thread_manager.h" #include "base/command_line.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/cras_audio_client_stub_impl.h" #include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/dbus_client.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager_observer.h" #include "chromeos/dbus/fake_bluetooth_adapter_client.h" #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" #include "chromeos/dbus/fake_bluetooth_device_client.h" #include "chromeos/dbus/fake_bluetooth_input_client.h" #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" #include "chromeos/dbus/fake_cryptohome_client.h" #include "chromeos/dbus/fake_debug_daemon_client.h" #include "chromeos/dbus/fake_gsm_sms_client.h" #include "chromeos/dbus/fake_image_burner_client.h" #include "chromeos/dbus/fake_introspectable_client.h" #include "chromeos/dbus/fake_modem_messaging_client.h" #include "chromeos/dbus/fake_nfc_adapter_client.h" #include "chromeos/dbus/fake_nfc_device_client.h" #include "chromeos/dbus/fake_nfc_manager_client.h" #include "chromeos/dbus/fake_nfc_record_client.h" #include "chromeos/dbus/fake_nfc_tag_client.h" #include "chromeos/dbus/fake_permission_broker_client.h" #include "chromeos/dbus/fake_shill_device_client.h" #include "chromeos/dbus/fake_shill_ipconfig_client.h" #include "chromeos/dbus/fake_shill_manager_client.h" #include "chromeos/dbus/fake_shill_profile_client.h" #include "chromeos/dbus/fake_shill_service_client.h" #include "chromeos/dbus/fake_sms_client.h" #include "chromeos/dbus/fake_system_clock_client.h" #include "chromeos/dbus/power_manager_client.h" #include "chromeos/dbus/power_policy_controller.h" #include "chromeos/dbus/session_manager_client.h" #include "chromeos/dbus/update_engine_client.h" namespace chromeos { FakeDBusThreadManager::FakeDBusThreadManager() { } FakeDBusThreadManager::~FakeDBusThreadManager() { FOR_EACH_OBSERVER(DBusThreadManagerObserver, observers_, OnDBusThreadManagerDestroying(this)); } void FakeDBusThreadManager::SetFakeClients() { const DBusClientImplementationType client_type = STUB_DBUS_CLIENT_IMPLEMENTATION; SetBluetoothAdapterClient( scoped_ptr(new FakeBluetoothAdapterClient)); SetBluetoothAgentManagerClient(scoped_ptr( new FakeBluetoothAgentManagerClient)); SetBluetoothDeviceClient( scoped_ptr(new FakeBluetoothDeviceClient)); SetBluetoothInputClient( scoped_ptr(new FakeBluetoothInputClient)); SetBluetoothProfileManagerClient(scoped_ptr( new FakeBluetoothProfileManagerClient)); SetCrosDisksClient( scoped_ptr(CrosDisksClient::Create(client_type))); SetCrasAudioClient(scoped_ptr(new CrasAudioClientStubImpl)); SetCryptohomeClient(scoped_ptr(new FakeCryptohomeClient)); SetDebugDaemonClient( scoped_ptr(new FakeDebugDaemonClient)); SetShillManagerClient( scoped_ptr(new FakeShillManagerClient)); SetShillDeviceClient( scoped_ptr(new FakeShillDeviceClient)); SetShillIPConfigClient( scoped_ptr(new FakeShillIPConfigClient)); SetShillServiceClient( scoped_ptr(new FakeShillServiceClient)); SetShillProfileClient( scoped_ptr(new FakeShillProfileClient)); FakeGsmSMSClient* gsm_sms_client = new FakeGsmSMSClient(); gsm_sms_client->set_sms_test_message_switch_present( CommandLine::ForCurrentProcess()->HasSwitch( chromeos::switches::kSmsTestMessages)); SetGsmSMSClient(scoped_ptr(gsm_sms_client)); SetImageBurnerClient( scoped_ptr(new FakeImageBurnerClient)); SetIntrospectableClient( scoped_ptr(new FakeIntrospectableClient)); SetModemMessagingClient( scoped_ptr(new FakeModemMessagingClient)); SetNfcAdapterClient(scoped_ptr(new FakeNfcAdapterClient)); SetNfcDeviceClient(scoped_ptr(new FakeNfcDeviceClient)); SetNfcManagerClient(scoped_ptr(new FakeNfcManagerClient)); SetNfcRecordClient(scoped_ptr(new FakeNfcRecordClient)); SetNfcTagClient(scoped_ptr(new FakeNfcTagClient)); SetPermissionBrokerClient( scoped_ptr(new FakePermissionBrokerClient)); SetPowerManagerClient( scoped_ptr(PowerManagerClient::Create(client_type))); SetSessionManagerClient(scoped_ptr( SessionManagerClient::Create(client_type))); SetSMSClient(scoped_ptr(new FakeSMSClient)); SetSystemClockClient( scoped_ptr(new FakeSystemClockClient)); SetUpdateEngineClient( scoped_ptr(UpdateEngineClient::Create(client_type))); SetPowerPolicyController(make_scoped_ptr(new PowerPolicyController)); } void FakeDBusThreadManager::SetBluetoothAdapterClient( scoped_ptr client) { bluetooth_adapter_client_ = client.Pass(); } void FakeDBusThreadManager::SetBluetoothAgentManagerClient( scoped_ptr client) { bluetooth_agent_manager_client_ = client.Pass(); } void FakeDBusThreadManager::SetBluetoothDeviceClient( scoped_ptr client) { bluetooth_device_client_ = client.Pass(); } void FakeDBusThreadManager::SetBluetoothInputClient( scoped_ptr client) { bluetooth_input_client_ = client.Pass(); } void FakeDBusThreadManager::SetBluetoothProfileManagerClient( scoped_ptr client) { bluetooth_profile_manager_client_ = client.Pass(); } void FakeDBusThreadManager::SetCrasAudioClient( scoped_ptr client) { cras_audio_client_ = client.Pass(); } void FakeDBusThreadManager::SetCrosDisksClient( scoped_ptr client) { cros_disks_client_ = client.Pass(); } void FakeDBusThreadManager::SetCryptohomeClient( scoped_ptr client) { cryptohome_client_ = client.Pass(); } void FakeDBusThreadManager::SetDebugDaemonClient( scoped_ptr client) { debug_daemon_client_ = client.Pass(); } void FakeDBusThreadManager::SetShillDeviceClient( scoped_ptr client) { shill_device_client_ = client.Pass(); } void FakeDBusThreadManager::SetShillIPConfigClient( scoped_ptr client) { shill_ipconfig_client_ = client.Pass(); } void FakeDBusThreadManager::SetShillManagerClient( scoped_ptr client) { shill_manager_client_ = client.Pass(); } void FakeDBusThreadManager::SetShillServiceClient( scoped_ptr client) { shill_service_client_ = client.Pass(); } void FakeDBusThreadManager::SetShillProfileClient( scoped_ptr client) { shill_profile_client_ = client.Pass(); } void FakeDBusThreadManager::SetGsmSMSClient( scoped_ptr client) { gsm_sms_client_ = client.Pass(); } void FakeDBusThreadManager::SetImageBurnerClient( scoped_ptr client) { image_burner_client_ = client.Pass(); } void FakeDBusThreadManager::SetIntrospectableClient( scoped_ptr client) { introspectable_client_ = client.Pass(); } void FakeDBusThreadManager::SetModemMessagingClient( scoped_ptr client) { modem_messaging_client_ = client.Pass(); } void FakeDBusThreadManager::SetNfcAdapterClient( scoped_ptr client) { nfc_adapter_client_ = client.Pass(); } void FakeDBusThreadManager::SetNfcDeviceClient( scoped_ptr client) { nfc_device_client_ = client.Pass(); } void FakeDBusThreadManager::SetNfcManagerClient( scoped_ptr client) { nfc_manager_client_ = client.Pass(); } void FakeDBusThreadManager::SetNfcRecordClient( scoped_ptr client) { nfc_record_client_ = client.Pass(); } void FakeDBusThreadManager::SetNfcTagClient( scoped_ptr client) { nfc_tag_client_ = client.Pass(); } void FakeDBusThreadManager::SetPermissionBrokerClient( scoped_ptr client) { permission_broker_client_ = client.Pass(); } void FakeDBusThreadManager::SetPowerManagerClient( scoped_ptr client) { power_manager_client_ = client.Pass(); } void FakeDBusThreadManager::SetPowerPolicyController( scoped_ptr client) { power_policy_controller_ = client.Pass(); } void FakeDBusThreadManager::SetSessionManagerClient( scoped_ptr client) { session_manager_client_ = client.Pass(); } void FakeDBusThreadManager::SetSMSClient(scoped_ptr client) { sms_client_ = client.Pass(); } void FakeDBusThreadManager::SetSystemClockClient( scoped_ptr client) { system_clock_client_ = client.Pass(); } void FakeDBusThreadManager::SetUpdateEngineClient( scoped_ptr client) { update_engine_client_ = client.Pass(); } void FakeDBusThreadManager::AddObserver( DBusThreadManagerObserver* observer) { DCHECK(observer); observers_.AddObserver(observer); } void FakeDBusThreadManager::RemoveObserver( DBusThreadManagerObserver* observer) { DCHECK(observer); observers_.RemoveObserver(observer); } dbus::Bus* FakeDBusThreadManager::GetSystemBus() { return NULL; } BluetoothAdapterClient* FakeDBusThreadManager::GetBluetoothAdapterClient() { return bluetooth_adapter_client_.get(); } BluetoothAgentManagerClient* FakeDBusThreadManager::GetBluetoothAgentManagerClient() { return bluetooth_agent_manager_client_.get(); } BluetoothDeviceClient* FakeDBusThreadManager::GetBluetoothDeviceClient() { return bluetooth_device_client_.get(); } BluetoothInputClient* FakeDBusThreadManager::GetBluetoothInputClient() { return bluetooth_input_client_.get(); } BluetoothProfileManagerClient* FakeDBusThreadManager::GetBluetoothProfileManagerClient() { return bluetooth_profile_manager_client_.get(); } CrasAudioClient* FakeDBusThreadManager::GetCrasAudioClient() { return cras_audio_client_.get(); } CrosDisksClient* FakeDBusThreadManager::GetCrosDisksClient() { return cros_disks_client_.get(); } CryptohomeClient* FakeDBusThreadManager::GetCryptohomeClient() { return cryptohome_client_.get(); } DebugDaemonClient* FakeDBusThreadManager::GetDebugDaemonClient() { return debug_daemon_client_.get(); } ShillDeviceClient* FakeDBusThreadManager::GetShillDeviceClient() { return shill_device_client_.get(); } ShillIPConfigClient* FakeDBusThreadManager::GetShillIPConfigClient() { return shill_ipconfig_client_.get(); } ShillManagerClient* FakeDBusThreadManager::GetShillManagerClient() { return shill_manager_client_.get(); } ShillProfileClient* FakeDBusThreadManager::GetShillProfileClient() { return shill_profile_client_.get(); } ShillServiceClient* FakeDBusThreadManager::GetShillServiceClient() { return shill_service_client_.get(); } GsmSMSClient* FakeDBusThreadManager::GetGsmSMSClient() { return gsm_sms_client_.get(); } ImageBurnerClient* FakeDBusThreadManager::GetImageBurnerClient() { return image_burner_client_.get(); } IntrospectableClient* FakeDBusThreadManager::GetIntrospectableClient() { return introspectable_client_.get(); } ModemMessagingClient* FakeDBusThreadManager::GetModemMessagingClient() { return modem_messaging_client_.get(); } NfcAdapterClient* FakeDBusThreadManager::GetNfcAdapterClient() { return nfc_adapter_client_.get(); } NfcDeviceClient* FakeDBusThreadManager::GetNfcDeviceClient() { return nfc_device_client_.get(); } NfcManagerClient* FakeDBusThreadManager::GetNfcManagerClient() { return nfc_manager_client_.get(); } NfcTagClient* FakeDBusThreadManager::GetNfcTagClient() { return nfc_tag_client_.get(); } NfcRecordClient* FakeDBusThreadManager::GetNfcRecordClient() { return nfc_record_client_.get(); } PermissionBrokerClient* FakeDBusThreadManager::GetPermissionBrokerClient() { return permission_broker_client_.get(); } PowerManagerClient* FakeDBusThreadManager::GetPowerManagerClient() { return power_manager_client_.get(); } PowerPolicyController* FakeDBusThreadManager::GetPowerPolicyController() { return power_policy_controller_.get(); } SessionManagerClient* FakeDBusThreadManager::GetSessionManagerClient() { return session_manager_client_.get(); } SMSClient* FakeDBusThreadManager::GetSMSClient() { return sms_client_.get(); } SystemClockClient* FakeDBusThreadManager::GetSystemClockClient() { return system_clock_client_.get(); } UpdateEngineClient* FakeDBusThreadManager::GetUpdateEngineClient() { return update_engine_client_.get(); } } // namespace chromeos