summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorzelidrag <zelidrag@chromium.org>2014-08-26 18:44:48 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-27 01:45:47 +0000
commit29fe338316a08c2669d2e011889dff2b91dfb616 (patch)
treeb4b49dbe5a9eae924bee60892b2bdda369b440cc /chromeos
parent71d115dac733c9532ab73c9e521f1ab545304d14 (diff)
downloadchromium_src-29fe338316a08c2669d2e011889dff2b91dfb616.zip
chromium_src-29fe338316a08c2669d2e011889dff2b91dfb616.tar.gz
chromium_src-29fe338316a08c2669d2e011889dff2b91dfb616.tar.bz2
Part 3: Merged FakedDBusThreadManager with DBusThreadManager.
BUG=401192 TEST=existing tests TBR=sky,stevenjb,keybuk Review URL: https://codereview.chromium.org/477663004 Cr-Commit-Position: refs/heads/master@{#292072}
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/audio/cras_audio_handler_unittest.cc2
-rw-r--r--chromeos/chromeos.gyp2
-rw-r--r--chromeos/cryptohome/system_salt_getter_unittest.cc6
-rw-r--r--chromeos/dbus/dbus_client.h4
-rw-r--r--chromeos/dbus/dbus_client_bundle.cc2
-rw-r--r--chromeos/dbus/dbus_client_bundle.h4
-rw-r--r--chromeos/dbus/dbus_thread_manager.cc706
-rw-r--r--chromeos/dbus/dbus_thread_manager.h187
-rw-r--r--chromeos/dbus/fake_dbus_thread_manager.cc472
-rw-r--r--chromeos/dbus/fake_dbus_thread_manager.h167
-rw-r--r--chromeos/dbus/fake_shill_manager_client.cc5
-rw-r--r--chromeos/dbus/power_policy_controller_unittest.cc12
-rw-r--r--chromeos/disks/disk_mount_manager_unittest.cc8
-rw-r--r--chromeos/network/client_cert_resolver_unittest.cc2
-rw-r--r--chromeos/network/geolocation_handler_unittest.cc2
-rw-r--r--chromeos/network/host_resolver_impl_chromeos_unittest.cc2
-rw-r--r--chromeos/network/managed_network_configuration_handler_unittest.cc10
-rw-r--r--chromeos/network/network_cert_migrator_unittest.cc2
-rw-r--r--chromeos/network/network_configuration_handler_unittest.cc14
-rw-r--r--chromeos/network/network_connection_handler_unittest.cc7
-rw-r--r--chromeos/network/network_device_handler_unittest.cc8
-rw-r--r--chromeos/network/network_sms_handler_unittest.cc2
-rw-r--r--chromeos/network/network_state_handler_unittest.cc2
-rw-r--r--chromeos/network/shill_property_handler_unittest.cc2
24 files changed, 603 insertions, 1027 deletions
diff --git a/chromeos/audio/cras_audio_handler_unittest.cc b/chromeos/audio/cras_audio_handler_unittest.cc
index 58dbe04..dec728e 100644
--- a/chromeos/audio/cras_audio_handler_unittest.cc
+++ b/chromeos/audio/cras_audio_handler_unittest.cc
@@ -252,7 +252,7 @@ class CrasAudioHandlerTest : public testing::Test {
}
void SetUpCrasAudioHandler(const AudioNodeList& audio_nodes) {
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
cras_audio_client_stub_ = static_cast<CrasAudioClientStubImpl*>(
DBusThreadManager::Get()->GetCrasAudioClient());
cras_audio_client_stub_->SetAudioDevices(audio_nodes);
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
index 6a28795..563a2b7 100644
--- a/chromeos/chromeos.gyp
+++ b/chromeos/chromeos.gyp
@@ -155,8 +155,6 @@
'dbus/fake_bluetooth_profile_service_provider.h',
'dbus/fake_cryptohome_client.cc',
'dbus/fake_cryptohome_client.h',
- 'dbus/fake_dbus_thread_manager.cc',
- 'dbus/fake_dbus_thread_manager.h',
'dbus/fake_debug_daemon_client.cc',
'dbus/fake_debug_daemon_client.h',
'dbus/fake_easy_unlock_client.cc',
diff --git a/chromeos/cryptohome/system_salt_getter_unittest.cc b/chromeos/cryptohome/system_salt_getter_unittest.cc
index f1b5230..db6bc7b 100644
--- a/chromeos/cryptohome/system_salt_getter_unittest.cc
+++ b/chromeos/cryptohome/system_salt_getter_unittest.cc
@@ -7,8 +7,8 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_cryptohome_client.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
@@ -25,11 +25,9 @@ class SystemSaltGetterTest : public testing::Test {
SystemSaltGetterTest() : fake_cryptohome_client_(NULL) {}
virtual void SetUp() OVERRIDE {
- FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager;
fake_cryptohome_client_ = new FakeCryptohomeClient;
- dbus_thread_manager->SetCryptohomeClient(
+ DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient(
scoped_ptr<CryptohomeClient>(fake_cryptohome_client_));
- DBusThreadManager::InitializeForTesting(dbus_thread_manager);
EXPECT_FALSE(SystemSaltGetter::IsInitialized());
SystemSaltGetter::Initialize();
diff --git a/chromeos/dbus/dbus_client.h b/chromeos/dbus/dbus_client.h
index e166c5f..e05c667 100644
--- a/chromeos/dbus/dbus_client.h
+++ b/chromeos/dbus/dbus_client.h
@@ -18,8 +18,6 @@ namespace chromeos {
// incorrect calls. Stub clients may lift that restriction however.
class DBusClient {
protected:
- friend class DBusThreadManager;
-
virtual ~DBusClient() {}
// This function is called by DBusThreadManager. Only in unit tests, which
@@ -28,6 +26,8 @@ class DBusClient {
virtual void Init(dbus::Bus* bus) = 0;
private:
+ friend class DBusThreadManager;
+
DISALLOW_ASSIGN(DBusClient);
};
diff --git a/chromeos/dbus/dbus_client_bundle.cc b/chromeos/dbus/dbus_client_bundle.cc
index 22d1a99..159b3f2 100644
--- a/chromeos/dbus/dbus_client_bundle.cc
+++ b/chromeos/dbus/dbus_client_bundle.cc
@@ -220,7 +220,7 @@ DBusClientBundle::DBusClientBundle() {
if (!DBusThreadManager::IsUsingStub(MODEM_MESSAGING))
modem_messaging_client_.reset(ModemMessagingClient::Create());
else
- modem_messaging_client_.reset(ModemMessagingClient::Create());
+ modem_messaging_client_.reset(new FakeModemMessagingClient);
// Create the NFC clients in the correct order based on their dependencies.
if (!DBusThreadManager::IsUsingStub(NFC)) {
diff --git a/chromeos/dbus/dbus_client_bundle.h b/chromeos/dbus/dbus_client_bundle.h
index 9d5d22d..e4710a8 100644
--- a/chromeos/dbus/dbus_client_bundle.h
+++ b/chromeos/dbus/dbus_client_bundle.h
@@ -80,7 +80,7 @@ class CHROMEOS_EXPORT DBusClientBundle {
};
DBusClientBundle();
- virtual ~DBusClientBundle();
+ ~DBusClientBundle();
// Initialize proper runtime environment for its dbus clients.
void SetupDefaultEnvironment();
@@ -230,6 +230,8 @@ class CHROMEOS_EXPORT DBusClientBundle {
}
private:
+ friend class DBusThreadManagerSetter;
+
scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_;
scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_;
scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_;
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc
index f2edfad..1df4d0e 100644
--- a/chromeos/dbus/dbus_thread_manager.cc
+++ b/chromeos/dbus/dbus_thread_manager.cc
@@ -24,7 +24,6 @@
#include "chromeos/dbus/dbus_client_bundle.h"
#include "chromeos/dbus/debug_daemon_client.h"
#include "chromeos/dbus/easy_unlock_client.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
#include "chromeos/dbus/gsm_sms_client.h"
#include "chromeos/dbus/image_burner_client.h"
#include "chromeos/dbus/introspectable_client.h"
@@ -53,15 +52,14 @@
namespace chromeos {
static DBusThreadManager* g_dbus_thread_manager = NULL;
-static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL;
+static bool g_using_dbus_thread_manager_for_testing = false;
DBusClientBundle::DBusClientTypeMask
DBusThreadManager::unstub_client_mask_ = DBusClientBundle::NO_CLIENTS;
-// The DBusThreadManager implementation used in production.
-class DBusThreadManagerImpl : public DBusThreadManager {
- public:
- DBusThreadManagerImpl() {
+DBusThreadManager::DBusThreadManager() {
+ dbus::statistics::Initialize();
+ if (!DBusThreadManager::IsUsingStub(DBusClientBundle::ALL_CLIENTS)) {
// Create the D-Bus thread.
base::Thread::Options thread_options;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
@@ -74,197 +72,262 @@ class DBusThreadManagerImpl : public DBusThreadManager {
system_bus_options.connection_type = dbus::Bus::PRIVATE;
system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
system_bus_ = new dbus::Bus(system_bus_options);
-
- CreateDefaultClients();
}
- virtual ~DBusThreadManagerImpl() {
- // PowerPolicyController's destructor depends on PowerManagerClient.
- power_policy_controller_.reset();
+ CreateDefaultClients();
+}
+
+DBusThreadManager::~DBusThreadManager() {
+ // PowerPolicyController's destructor depends on PowerManagerClient.
+ power_policy_controller_.reset();
- // Delete all D-Bus clients before shutting down the system bus.
- client_bundle_.reset();
+ // Delete all D-Bus clients before shutting down the system bus.
+ client_bundle_.reset();
- // Shut down the bus. During the browser shutdown, it's ok to shut down
- // the bus synchronously.
+ // Shut down the bus. During the browser shutdown, it's ok to shut down
+ // the bus synchronously.
+ if (system_bus_)
system_bus_->ShutdownOnDBusThreadAndBlock();
- // Stop the D-Bus thread.
+ // Stop the D-Bus thread.
+ if (dbus_thread_)
dbus_thread_->Stop();
- }
- void SetupDefaultEnvironment() {
- return client_bundle_->SetupDefaultEnvironment();
- }
+ dbus::statistics::Shutdown();
- virtual dbus::Bus* GetSystemBus() OVERRIDE {
- return system_bus_.get();
- }
+ if (g_dbus_thread_manager == NULL)
+ return; // Called form Shutdown() or local test instance.
- virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE {
- return client_bundle_->bluetooth_adapter_client();
+ // There should never be both a global instance and a local instance.
+ CHECK(this == g_dbus_thread_manager);
+ if (g_using_dbus_thread_manager_for_testing) {
+ g_dbus_thread_manager = NULL;
+ g_using_dbus_thread_manager_for_testing = false;
+ VLOG(1) << "DBusThreadManager destroyed";
+ } else {
+ LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()";
}
+}
- virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient()
- OVERRIDE {
- return client_bundle_->bluetooth_agent_manager_client();
- }
+dbus::Bus* DBusThreadManager::GetSystemBus() {
+ return system_bus_.get();
+}
- virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE {
- return client_bundle_->bluetooth_device_client();
- }
+BluetoothAdapterClient* DBusThreadManager::GetBluetoothAdapterClient() {
+ return client_bundle_->bluetooth_adapter_client();
+}
- virtual BluetoothGattCharacteristicClient*
- GetBluetoothGattCharacteristicClient() OVERRIDE {
- return client_bundle_->bluetooth_gatt_characteristic_client();
- }
+BluetoothAgentManagerClient*
+DBusThreadManager::GetBluetoothAgentManagerClient() {
+ return client_bundle_->bluetooth_agent_manager_client();
+}
- virtual BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient()
- OVERRIDE {
- return client_bundle_->bluetooth_gatt_descriptor_client();
- }
+BluetoothDeviceClient* DBusThreadManager::GetBluetoothDeviceClient() {
+ return client_bundle_->bluetooth_device_client();
+}
- virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() OVERRIDE {
- return client_bundle_->bluetooth_gatt_manager_client();
- }
+BluetoothGattCharacteristicClient*
+DBusThreadManager::GetBluetoothGattCharacteristicClient() {
+ return client_bundle_->bluetooth_gatt_characteristic_client();
+}
- virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() OVERRIDE {
- return client_bundle_->bluetooth_gatt_service_client();
- }
+BluetoothGattDescriptorClient*
+DBusThreadManager::GetBluetoothGattDescriptorClient() {
+ return client_bundle_->bluetooth_gatt_descriptor_client();
+}
- virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE {
- return client_bundle_->bluetooth_input_client();
- }
+BluetoothGattManagerClient*
+DBusThreadManager::GetBluetoothGattManagerClient() {
+ return client_bundle_->bluetooth_gatt_manager_client();
+}
- virtual BluetoothProfileManagerClient* GetBluetoothProfileManagerClient()
- OVERRIDE {
- return client_bundle_->bluetooth_profile_manager_client();
- }
+BluetoothGattServiceClient*
+DBusThreadManager::GetBluetoothGattServiceClient() {
+ return client_bundle_->bluetooth_gatt_service_client();
+}
- virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE {
- return client_bundle_->cras_audio_client();
- }
+BluetoothInputClient* DBusThreadManager::GetBluetoothInputClient() {
+ return client_bundle_->bluetooth_input_client();
+}
- virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE {
- return client_bundle_->cros_disks_client();
- }
+BluetoothProfileManagerClient*
+DBusThreadManager::GetBluetoothProfileManagerClient() {
+ return client_bundle_->bluetooth_profile_manager_client();
+}
- virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE {
- return client_bundle_->cryptohome_client();
- }
+CrasAudioClient* DBusThreadManager::GetCrasAudioClient() {
+ return client_bundle_->cras_audio_client();
+}
- virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE {
- return client_bundle_->debug_daemon_client();
- }
+CrosDisksClient* DBusThreadManager::GetCrosDisksClient() {
+ return client_bundle_->cros_disks_client();
+}
- virtual EasyUnlockClient* GetEasyUnlockClient() OVERRIDE {
- return client_bundle_->easy_unlock_client();
- }
- virtual LorgnetteManagerClient* GetLorgnetteManagerClient() OVERRIDE {
- return client_bundle_->lorgnette_manager_client();
- }
+CryptohomeClient* DBusThreadManager::GetCryptohomeClient() {
+ return client_bundle_->cryptohome_client();
+}
- virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE {
- return client_bundle_->shill_device_client();
- }
+DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() {
+ return client_bundle_->debug_daemon_client();
+}
- virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE {
- return client_bundle_->shill_ipconfig_client();
- }
+EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() {
+ return client_bundle_->easy_unlock_client();
+}
+LorgnetteManagerClient*
+DBusThreadManager::GetLorgnetteManagerClient() {
+ return client_bundle_->lorgnette_manager_client();
+}
- virtual ShillManagerClient* GetShillManagerClient() OVERRIDE {
- return client_bundle_->shill_manager_client();
- }
+ShillDeviceClient*
+DBusThreadManager::GetShillDeviceClient() {
+ return client_bundle_->shill_device_client();
+}
- virtual ShillServiceClient* GetShillServiceClient() OVERRIDE {
- return client_bundle_->shill_service_client();
- }
+ShillIPConfigClient*
+DBusThreadManager::GetShillIPConfigClient() {
+ return client_bundle_->shill_ipconfig_client();
+}
- virtual ShillProfileClient* GetShillProfileClient() OVERRIDE {
- return client_bundle_->shill_profile_client();
- }
+ShillManagerClient*
+DBusThreadManager::GetShillManagerClient() {
+ return client_bundle_->shill_manager_client();
+}
- virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE {
- return client_bundle_->gsm_sms_client();
- }
+ShillServiceClient*
+DBusThreadManager::GetShillServiceClient() {
+ return client_bundle_->shill_service_client();
+}
- virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE {
- return client_bundle_->image_burner_client();
- }
+ShillProfileClient*
+DBusThreadManager::GetShillProfileClient() {
+ return client_bundle_->shill_profile_client();
+}
- virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE {
- return client_bundle_->introspectable_client();
- }
+GsmSMSClient* DBusThreadManager::GetGsmSMSClient() {
+ return client_bundle_->gsm_sms_client();
+}
- virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE {
- return client_bundle_->modem_messaging_client();
- }
+ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() {
+ return client_bundle_->image_burner_client();
+}
- virtual NfcAdapterClient* GetNfcAdapterClient() OVERRIDE {
- return client_bundle_->nfc_adapter_client();
- }
+IntrospectableClient* DBusThreadManager::GetIntrospectableClient() {
+ return client_bundle_->introspectable_client();
+}
- virtual NfcDeviceClient* GetNfcDeviceClient() OVERRIDE {
- return client_bundle_->nfc_device_client();
- }
+ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() {
+ return client_bundle_->modem_messaging_client();
+}
- virtual NfcManagerClient* GetNfcManagerClient() OVERRIDE {
- return client_bundle_->nfc_manager_client();
- }
+NfcAdapterClient* DBusThreadManager::GetNfcAdapterClient() {
+ return client_bundle_->nfc_adapter_client();
+}
- virtual NfcRecordClient* GetNfcRecordClient() OVERRIDE {
- return client_bundle_->nfc_record_client();
- }
+NfcDeviceClient* DBusThreadManager::GetNfcDeviceClient() {
+ return client_bundle_->nfc_device_client();
+}
- virtual NfcTagClient* GetNfcTagClient() OVERRIDE {
- return client_bundle_->nfc_tag_client();
- }
+NfcManagerClient* DBusThreadManager::GetNfcManagerClient() {
+ return client_bundle_->nfc_manager_client();
+}
- virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE {
- return client_bundle_->permission_broker_client();
- }
+NfcRecordClient* DBusThreadManager::GetNfcRecordClient() {
+ return client_bundle_->nfc_record_client();
+}
- virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE {
- return client_bundle_->power_manager_client();
- }
+NfcTagClient* DBusThreadManager::GetNfcTagClient() {
+ return client_bundle_->nfc_tag_client();
+}
- virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE {
- return client_bundle_->session_manager_client();
- }
+PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() {
+ return client_bundle_->permission_broker_client();
+}
- virtual SMSClient* GetSMSClient() OVERRIDE {
- return client_bundle_->sms_client();
- }
+PowerManagerClient* DBusThreadManager::GetPowerManagerClient() {
+ return client_bundle_->power_manager_client();
+}
- virtual SystemClockClient* GetSystemClockClient() OVERRIDE {
- return client_bundle_->system_clock_client();
- }
+SessionManagerClient* DBusThreadManager::GetSessionManagerClient() {
+ return client_bundle_->session_manager_client();
+}
- virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE {
- return client_bundle_->update_engine_client();
- }
+SMSClient* DBusThreadManager::GetSMSClient() {
+ return client_bundle_->sms_client();
+}
- virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE {
- return power_policy_controller_.get();
- }
+SystemClockClient* DBusThreadManager::GetSystemClockClient() {
+ return client_bundle_->system_clock_client();
+}
- private:
- // Constructs all clients and stores them in the respective *_client_ member
- // variable.
- void CreateDefaultClients() {
- client_bundle_.reset(new DBusClientBundle());
- // TODO(crbug.com/345586): Move PowerPolicyController out of
- // DBusThreadManagerImpl.
- power_policy_controller_.reset(new PowerPolicyController);
- }
+UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() {
+ return client_bundle_->update_engine_client();
+}
+
+PowerPolicyController* DBusThreadManager::GetPowerPolicyController() {
+ return power_policy_controller_.get();
+}
+
+void DBusThreadManager::CreateDefaultClients() {
+ client_bundle_.reset(new DBusClientBundle());
+ // TODO(crbug.com/345586): Move PowerPolicyController out of
+ // DBusThreadManager.
+ power_policy_controller_.reset(new PowerPolicyController);
+}
+
+void DBusThreadManager::InitializeClients() {
+ GetBluetoothAdapterClient()->Init(GetSystemBus());
+ GetBluetoothAgentManagerClient()->Init(GetSystemBus());
+ GetBluetoothDeviceClient()->Init(GetSystemBus());
+ GetBluetoothGattCharacteristicClient()->Init(GetSystemBus());
+ GetBluetoothGattDescriptorClient()->Init(GetSystemBus());
+ GetBluetoothGattManagerClient()->Init(GetSystemBus());
+ GetBluetoothGattServiceClient()->Init(GetSystemBus());
+ GetBluetoothInputClient()->Init(GetSystemBus());
+ GetBluetoothProfileManagerClient()->Init(GetSystemBus());
+ GetCrasAudioClient()->Init(GetSystemBus());
+ GetCrosDisksClient()->Init(GetSystemBus());
+ GetCryptohomeClient()->Init(GetSystemBus());
+ GetDebugDaemonClient()->Init(GetSystemBus());
+ GetEasyUnlockClient()->Init(GetSystemBus());
+ GetGsmSMSClient()->Init(GetSystemBus());
+ GetImageBurnerClient()->Init(GetSystemBus());
+ GetIntrospectableClient()->Init(GetSystemBus());
+ GetLorgnetteManagerClient()->Init(GetSystemBus());
+ GetModemMessagingClient()->Init(GetSystemBus());
+ GetPermissionBrokerClient()->Init(GetSystemBus());
+ GetPowerManagerClient()->Init(GetSystemBus());
+ GetSessionManagerClient()->Init(GetSystemBus());
+ GetShillDeviceClient()->Init(GetSystemBus());
+ GetShillIPConfigClient()->Init(GetSystemBus());
+ GetShillManagerClient()->Init(GetSystemBus());
+ GetShillServiceClient()->Init(GetSystemBus());
+ GetShillProfileClient()->Init(GetSystemBus());
+ GetSMSClient()->Init(GetSystemBus());
+ GetSystemClockClient()->Init(GetSystemBus());
+ GetUpdateEngineClient()->Init(GetSystemBus());
+
+ // Initialize the NFC clients in the correct order. The order of
+ // initialization matters due to dependencies that exist between the
+ // client objects.
+ GetNfcManagerClient()->Init(GetSystemBus());
+ GetNfcAdapterClient()->Init(GetSystemBus());
+ GetNfcDeviceClient()->Init(GetSystemBus());
+ GetNfcTagClient()->Init(GetSystemBus());
+ GetNfcRecordClient()->Init(GetSystemBus());
- scoped_ptr<base::Thread> dbus_thread_;
- scoped_refptr<dbus::Bus> system_bus_;
- scoped_ptr<DBusClientBundle> client_bundle_;
- scoped_ptr<PowerPolicyController> power_policy_controller_;
+ // PowerPolicyController is dependent on PowerManagerClient, so
+ // initialize it after the main list of clients.
+ if (GetPowerPolicyController())
+ GetPowerPolicyController()->Init(this);
+
+ // This must be called after the list of clients so they've each had a
+ // chance to register with their object g_dbus_thread_managers.
+ if (GetSystemBus())
+ GetSystemBus()->GetManagedObjects();
- DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl);
-};
+ client_bundle_->SetupDefaultEnvironment();
+}
// static
bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) {
@@ -275,15 +338,10 @@ bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) {
void DBusThreadManager::Initialize() {
// If we initialize DBusThreadManager twice we may also be shutting it down
// early; do not allow that.
- CHECK(g_dbus_thread_manager == NULL);
-
- if (g_dbus_thread_manager_for_testing) {
- g_dbus_thread_manager = g_dbus_thread_manager_for_testing;
- InitializeClients();
- VLOG(1) << "DBusThreadManager initialized with test implementation";
+ if (g_using_dbus_thread_manager_for_testing)
return;
- }
+ CHECK(g_dbus_thread_manager == NULL);
bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() ||
CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kDbusStub);
@@ -295,43 +353,46 @@ void DBusThreadManager::Initialize() {
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
chromeos::switches::kDbusUnstubClients));
} else if (use_dbus_stub) {
- InitializeWithStub();
+ InitializeWithStubs();
} else {
InitializeRegular();
}
}
// static
-void DBusThreadManager::SetInstanceForTesting(
- DBusThreadManager* dbus_thread_manager) {
- CHECK(!g_dbus_thread_manager);
- CHECK(!g_dbus_thread_manager_for_testing);
- g_dbus_thread_manager_for_testing = dbus_thread_manager;
+scoped_ptr<DBusThreadManagerSetter> DBusThreadManager::GetSetterForTesting() {
+ if (!g_using_dbus_thread_manager_for_testing) {
+ g_using_dbus_thread_manager_for_testing = true;
+ InitializeWithStubs();
+ }
+
+ return make_scoped_ptr(new DBusThreadManagerSetter());
}
// static
-void DBusThreadManager::InitializeForTesting(
- DBusThreadManager* dbus_thread_manager) {
- unstub_client_mask_ = DBusClientBundle::NO_CLIENTS;
- SetInstanceForTesting(dbus_thread_manager);
- Initialize();
+void DBusThreadManager::CreateGlobalInstance() {
+ CHECK(!g_dbus_thread_manager);
+ g_dbus_thread_manager = new DBusThreadManager();
+ g_dbus_thread_manager->InitializeClients();
}
// static
void DBusThreadManager::InitializeRegular() {
unstub_client_mask_ = DBusClientBundle::ALL_CLIENTS;
- g_dbus_thread_manager = new DBusThreadManagerImpl();
- InitializeClients();
+ CreateGlobalInstance();
VLOG(1) << "DBusThreadManager initialized for Chrome OS";
}
// static
+void DBusThreadManager::InitializeWithStubs() {
+ unstub_client_mask_ = DBusClientBundle::NO_CLIENTS;
+ CreateGlobalInstance();
+ VLOG(1) << "DBusThreadManager created for testing";
+}
+
+// static
void DBusThreadManager::InitializeWithPartialStub(
const std::string& unstub_clients) {
- // If we initialize DBusThreadManager twice we may also be shutting it down
- // early; do not allow that.
- CHECK(g_dbus_thread_manager == NULL);
-
unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients);
// We should have something parsed correctly here.
if (unstub_client_mask_ == 0) {
@@ -340,25 +401,8 @@ void DBusThreadManager::InitializeWithPartialStub(
<< " cannot be parsed: "
<< unstub_clients;
}
- DBusThreadManagerImpl* dbus_thread_manager = new DBusThreadManagerImpl();
VLOG(1) << "DBusThreadManager initialized for mixed runtime environment";
- g_dbus_thread_manager = dbus_thread_manager;
- InitializeClients();
- dbus_thread_manager->SetupDefaultEnvironment();
-}
-
-// static
-void DBusThreadManager::InitializeWithStub() {
- unstub_client_mask_ = DBusClientBundle::NO_CLIENTS;
- // If we initialize DBusThreadManager twice we may also be shutting it down
- // early; do not allow that.
- CHECK(g_dbus_thread_manager == NULL);
- FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager;
- fake_dbus_thread_manager->SetFakeClients();
- g_dbus_thread_manager = fake_dbus_thread_manager;
- InitializeClients();
- fake_dbus_thread_manager->SetupDefaultEnvironment();
- VLOG(1) << "DBusThreadManager initialized with stub implementation";
+ CreateGlobalInstance();
}
// static
@@ -368,35 +412,15 @@ bool DBusThreadManager::IsInitialized() {
// static
void DBusThreadManager::Shutdown() {
- // If we called InitializeForTesting, this may get called more than once.
// Ensure that we only shutdown DBusThreadManager once.
- CHECK(g_dbus_thread_manager || g_dbus_thread_manager_for_testing);
+ CHECK(g_dbus_thread_manager);
DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager;
g_dbus_thread_manager = NULL;
- g_dbus_thread_manager_for_testing = NULL;
+ g_using_dbus_thread_manager_for_testing = false;
delete dbus_thread_manager;
VLOG(1) << "DBusThreadManager Shutdown completed";
}
-DBusThreadManager::DBusThreadManager() {
- dbus::statistics::Initialize();
-}
-
-DBusThreadManager::~DBusThreadManager() {
- dbus::statistics::Shutdown();
- if (g_dbus_thread_manager == NULL)
- return; // Called form Shutdown() or local test instance.
- // There should never be both a global instance and a local instance.
- CHECK(this == g_dbus_thread_manager);
- if (g_dbus_thread_manager_for_testing) {
- g_dbus_thread_manager = NULL;
- g_dbus_thread_manager_for_testing = NULL;
- VLOG(1) << "DBusThreadManager destroyed";
- } else {
- LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()";
- }
-}
-
// static
DBusThreadManager* DBusThreadManager::Get() {
CHECK(g_dbus_thread_manager)
@@ -404,65 +428,213 @@ DBusThreadManager* DBusThreadManager::Get() {
return g_dbus_thread_manager;
}
-// static
-void DBusThreadManager::InitializeClients() {
- InitClient(g_dbus_thread_manager->GetBluetoothAdapterClient());
- InitClient(g_dbus_thread_manager->GetBluetoothAgentManagerClient());
- InitClient(g_dbus_thread_manager->GetBluetoothDeviceClient());
- InitClient(g_dbus_thread_manager->GetBluetoothGattCharacteristicClient());
- InitClient(g_dbus_thread_manager->GetBluetoothGattDescriptorClient());
- InitClient(g_dbus_thread_manager->GetBluetoothGattManagerClient());
- InitClient(g_dbus_thread_manager->GetBluetoothGattServiceClient());
- InitClient(g_dbus_thread_manager->GetBluetoothInputClient());
- InitClient(g_dbus_thread_manager->GetBluetoothProfileManagerClient());
- InitClient(g_dbus_thread_manager->GetCrasAudioClient());
- InitClient(g_dbus_thread_manager->GetCrosDisksClient());
- InitClient(g_dbus_thread_manager->GetCryptohomeClient());
- InitClient(g_dbus_thread_manager->GetDebugDaemonClient());
- InitClient(g_dbus_thread_manager->GetEasyUnlockClient());
- InitClient(g_dbus_thread_manager->GetGsmSMSClient());
- InitClient(g_dbus_thread_manager->GetImageBurnerClient());
- InitClient(g_dbus_thread_manager->GetIntrospectableClient());
- InitClient(g_dbus_thread_manager->GetLorgnetteManagerClient());
- InitClient(g_dbus_thread_manager->GetModemMessagingClient());
- InitClient(g_dbus_thread_manager->GetPermissionBrokerClient());
- InitClient(g_dbus_thread_manager->GetPowerManagerClient());
- InitClient(g_dbus_thread_manager->GetSessionManagerClient());
- InitClient(g_dbus_thread_manager->GetShillDeviceClient());
- InitClient(g_dbus_thread_manager->GetShillIPConfigClient());
- InitClient(g_dbus_thread_manager->GetShillManagerClient());
- InitClient(g_dbus_thread_manager->GetShillServiceClient());
- InitClient(g_dbus_thread_manager->GetShillProfileClient());
- InitClient(g_dbus_thread_manager->GetSMSClient());
- InitClient(g_dbus_thread_manager->GetSystemClockClient());
- InitClient(g_dbus_thread_manager->GetUpdateEngineClient());
+DBusThreadManagerSetter::DBusThreadManagerSetter() {
+}
- // Initialize the NFC clients in the correct order. The order of
- // initialization matters due to dependencies that exist between the
- // client objects.
- InitClient(g_dbus_thread_manager->GetNfcManagerClient());
- InitClient(g_dbus_thread_manager->GetNfcAdapterClient());
- InitClient(g_dbus_thread_manager->GetNfcDeviceClient());
- InitClient(g_dbus_thread_manager->GetNfcTagClient());
- InitClient(g_dbus_thread_manager->GetNfcRecordClient());
+DBusThreadManagerSetter::~DBusThreadManagerSetter() {
+}
- // PowerPolicyController is dependent on PowerManagerClient, so
- // initialize it after the main list of clients.
- if (g_dbus_thread_manager->GetPowerPolicyController()) {
- g_dbus_thread_manager->GetPowerPolicyController()->Init(
- g_dbus_thread_manager);
- }
+void DBusThreadManagerSetter::SetBluetoothAdapterClient(
+ scoped_ptr<BluetoothAdapterClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_adapter_client_ =
+ client.Pass();
+}
- // This must be called after the list of clients so they've each had a
- // chance to register with their object g_dbus_thread_managers.
- if (g_dbus_thread_manager->GetSystemBus())
- g_dbus_thread_manager->GetSystemBus()->GetManagedObjects();
+void DBusThreadManagerSetter::SetBluetoothAgentManagerClient(
+ scoped_ptr<BluetoothAgentManagerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_agent_manager_client_ =
+ client.Pass();
}
-// static
-void DBusThreadManager::InitClient(DBusClient* client) {
- if (client)
- client->Init(g_dbus_thread_manager->GetSystemBus());
+void DBusThreadManagerSetter::SetBluetoothDeviceClient(
+ scoped_ptr<BluetoothDeviceClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_device_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetBluetoothGattCharacteristicClient(
+ scoped_ptr<BluetoothGattCharacteristicClient> client) {
+ DBusThreadManager::Get()->client_bundle_->
+ bluetooth_gatt_characteristic_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetBluetoothGattDescriptorClient(
+ scoped_ptr<BluetoothGattDescriptorClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_descriptor_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetBluetoothGattManagerClient(
+ scoped_ptr<BluetoothGattManagerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_manager_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetBluetoothGattServiceClient(
+ scoped_ptr<BluetoothGattServiceClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_service_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetBluetoothInputClient(
+ scoped_ptr<BluetoothInputClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_input_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetBluetoothProfileManagerClient(
+ scoped_ptr<BluetoothProfileManagerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->bluetooth_profile_manager_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetCrasAudioClient(
+ scoped_ptr<CrasAudioClient> client) {
+ DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetCrosDisksClient(
+ scoped_ptr<CrosDisksClient> client) {
+ DBusThreadManager::Get()->client_bundle_->cros_disks_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetCryptohomeClient(
+ scoped_ptr<CryptohomeClient> client) {
+ DBusThreadManager::Get()->client_bundle_->cryptohome_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetDebugDaemonClient(
+ scoped_ptr<DebugDaemonClient> client) {
+ DBusThreadManager::Get()->client_bundle_->debug_daemon_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetEasyUnlockClient(
+ scoped_ptr<EasyUnlockClient> client) {
+ DBusThreadManager::Get()->client_bundle_->easy_unlock_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetLorgnetteManagerClient(
+ scoped_ptr<LorgnetteManagerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->lorgnette_manager_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetShillDeviceClient(
+ scoped_ptr<ShillDeviceClient> client) {
+ DBusThreadManager::Get()->client_bundle_->shill_device_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetShillIPConfigClient(
+ scoped_ptr<ShillIPConfigClient> client) {
+ DBusThreadManager::Get()->client_bundle_->shill_ipconfig_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetShillManagerClient(
+ scoped_ptr<ShillManagerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->shill_manager_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetShillServiceClient(
+ scoped_ptr<ShillServiceClient> client) {
+ DBusThreadManager::Get()->client_bundle_->shill_service_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetShillProfileClient(
+ scoped_ptr<ShillProfileClient> client) {
+ DBusThreadManager::Get()->client_bundle_->shill_profile_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetGsmSMSClient(
+ scoped_ptr<GsmSMSClient> client) {
+ DBusThreadManager::Get()->client_bundle_->gsm_sms_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetImageBurnerClient(
+ scoped_ptr<ImageBurnerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->image_burner_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetIntrospectableClient(
+ scoped_ptr<IntrospectableClient> client) {
+ DBusThreadManager::Get()->client_bundle_->introspectable_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetModemMessagingClient(
+ scoped_ptr<ModemMessagingClient> client) {
+ DBusThreadManager::Get()->client_bundle_->modem_messaging_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetNfcAdapterClient(
+ scoped_ptr<NfcAdapterClient> client) {
+ DBusThreadManager::Get()->client_bundle_->nfc_adapter_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetNfcDeviceClient(
+ scoped_ptr<NfcDeviceClient> client) {
+ DBusThreadManager::Get()->client_bundle_->nfc_device_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetNfcManagerClient(
+ scoped_ptr<NfcManagerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->nfc_manager_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetNfcRecordClient(
+ scoped_ptr<NfcRecordClient> client) {
+ DBusThreadManager::Get()->client_bundle_->nfc_record_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetNfcTagClient(
+ scoped_ptr<NfcTagClient> client) {
+ DBusThreadManager::Get()->client_bundle_->nfc_tag_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetPermissionBrokerClient(
+ scoped_ptr<PermissionBrokerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->permission_broker_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetPowerManagerClient(
+ scoped_ptr<PowerManagerClient> client) {
+ DBusThreadManager::Get()->power_policy_controller_.reset();
+ DBusThreadManager::Get()->client_bundle_->power_manager_client_ =
+ client.Pass();
+ DBusThreadManager::Get()->power_policy_controller_.reset(
+ new PowerPolicyController);
+ DBusThreadManager::Get()->power_policy_controller_->Init(
+ DBusThreadManager::Get());
+}
+
+void DBusThreadManagerSetter::SetSessionManagerClient(
+ scoped_ptr<SessionManagerClient> client) {
+ DBusThreadManager::Get()->client_bundle_->session_manager_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetSMSClient(scoped_ptr<SMSClient> client) {
+ DBusThreadManager::Get()->client_bundle_->sms_client_ = client.Pass();
+}
+
+void DBusThreadManagerSetter::SetSystemClockClient(
+ scoped_ptr<SystemClockClient> client) {
+ DBusThreadManager::Get()->client_bundle_->system_clock_client_ =
+ client.Pass();
+}
+
+void DBusThreadManagerSetter::SetUpdateEngineClient(
+ scoped_ptr<UpdateEngineClient> client) {
+ DBusThreadManager::Get()->client_bundle_->update_engine_client_ =
+ client.Pass();
}
} // namespace chromeos
diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h
index 053763c..f190f66 100644
--- a/chromeos/dbus/dbus_thread_manager.h
+++ b/chromeos/dbus/dbus_thread_manager.h
@@ -36,6 +36,8 @@ class CrasAudioClient;
class CrosDisksClient;
class CryptohomeClient;
class DBusClient;
+class DBusThreadManager;
+class DBusThreadManagerSetter;
class DebugDaemonClient;
class EasyUnlockClient;
class GsmSMSClient;
@@ -86,24 +88,9 @@ class CHROMEOS_EXPORT DBusThreadManager {
// making it a Singleton, to ensure clean startup and shutdown.
static void Initialize();
- // Sets an alternative DBusThreadManager such as MockDBusThreadManager
- // to be used in |Initialize()| for testing. Tests that call
- // DBusThreadManager::Initialize() (such as browser_tests and
- // interactive_ui_tests) should use this instead of calling
- // |InitiailzeForTesting|. The injected object will be owned by the
- // internal pointer and deleted by Shutdown().
- static void SetInstanceForTesting(DBusThreadManager* dbus_thread_manager);
-
- // Similar to Initialize(), but injects an alternative
- // DBusThreadManager using SetInstanceForTest first. The injected
- // object will be owned by the internal pointer and deleted by
- // Shutdown(). Does not create any Fake client implementations.
- static void InitializeForTesting(DBusThreadManager* dbus_thread_manager);
-
- // Initialize with stub implementations for tests, creating a complete set
- // of fake/stub client implementations. Also initializes a default set of
- // fake Shill devices and services, customizable with switches::kShillStub.
- static void InitializeWithStub();
+ // Returns DBusThreadManagerSetter instance that allows tests to
+ // replace individual dbus clients with their own implementations.
+ static scoped_ptr<DBusThreadManagerSetter> GetSetterForTesting();
// Returns true if DBusThreadManager has been initialized. Call this to
// avoid initializing + shutting down DBusThreadManager more than once.
@@ -119,76 +106,142 @@ class CHROMEOS_EXPORT DBusThreadManager {
static bool IsUsingStub(DBusClientBundle::DBusClientType client);
// Returns various D-Bus bus instances, owned by DBusThreadManager.
- virtual dbus::Bus* GetSystemBus() = 0;
+ dbus::Bus* GetSystemBus();
// All returned objects are owned by DBusThreadManager. Do not cache these
// pointers and use them after DBusThreadManager has been shut down.
- virtual BluetoothAdapterClient* GetBluetoothAdapterClient() = 0;
- virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() = 0;
- virtual BluetoothDeviceClient* GetBluetoothDeviceClient() = 0;
- virtual BluetoothGattCharacteristicClient*
- GetBluetoothGattCharacteristicClient() = 0;
- virtual BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient() = 0;
- virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() = 0;
- virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() = 0;
- virtual BluetoothInputClient* GetBluetoothInputClient() = 0;
- virtual BluetoothProfileManagerClient* GetBluetoothProfileManagerClient() = 0;
- virtual CrasAudioClient* GetCrasAudioClient() = 0;
- virtual CrosDisksClient* GetCrosDisksClient() = 0;
- virtual CryptohomeClient* GetCryptohomeClient() = 0;
- virtual DebugDaemonClient* GetDebugDaemonClient() = 0;
- virtual EasyUnlockClient* GetEasyUnlockClient() = 0;
- virtual GsmSMSClient* GetGsmSMSClient() = 0;
- virtual ImageBurnerClient* GetImageBurnerClient() = 0;
- virtual IntrospectableClient* GetIntrospectableClient() = 0;
- virtual LorgnetteManagerClient* GetLorgnetteManagerClient() = 0;
- virtual ModemMessagingClient* GetModemMessagingClient() = 0;
- virtual NfcAdapterClient* GetNfcAdapterClient() = 0;
- virtual NfcDeviceClient* GetNfcDeviceClient() = 0;
- virtual NfcManagerClient* GetNfcManagerClient() = 0;
- virtual NfcRecordClient* GetNfcRecordClient() = 0;
- virtual NfcTagClient* GetNfcTagClient() = 0;
- virtual PermissionBrokerClient* GetPermissionBrokerClient() = 0;
- virtual PowerManagerClient* GetPowerManagerClient() = 0;
- virtual PowerPolicyController* GetPowerPolicyController() = 0;
- virtual SessionManagerClient* GetSessionManagerClient() = 0;
- virtual ShillDeviceClient* GetShillDeviceClient() = 0;
- virtual ShillIPConfigClient* GetShillIPConfigClient() = 0;
- virtual ShillManagerClient* GetShillManagerClient() = 0;
- virtual ShillServiceClient* GetShillServiceClient() = 0;
- virtual ShillProfileClient* GetShillProfileClient() = 0;
- virtual SMSClient* GetSMSClient() = 0;
- virtual SystemClockClient* GetSystemClockClient() = 0;
- virtual UpdateEngineClient* GetUpdateEngineClient() = 0;
-
- virtual ~DBusThreadManager();
-
- protected:
- DBusThreadManager();
+ BluetoothAdapterClient* GetBluetoothAdapterClient();
+ BluetoothAgentManagerClient* GetBluetoothAgentManagerClient();
+ BluetoothDeviceClient* GetBluetoothDeviceClient();
+ BluetoothGattCharacteristicClient* GetBluetoothGattCharacteristicClient();
+ BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient();
+ BluetoothGattManagerClient* GetBluetoothGattManagerClient();
+ BluetoothGattServiceClient* GetBluetoothGattServiceClient();
+ BluetoothInputClient* GetBluetoothInputClient();
+ BluetoothProfileManagerClient* GetBluetoothProfileManagerClient();
+ CrasAudioClient* GetCrasAudioClient();
+ CrosDisksClient* GetCrosDisksClient();
+ CryptohomeClient* GetCryptohomeClient();
+ DebugDaemonClient* GetDebugDaemonClient();
+ EasyUnlockClient* GetEasyUnlockClient();
+ GsmSMSClient* GetGsmSMSClient();
+ ImageBurnerClient* GetImageBurnerClient();
+ IntrospectableClient* GetIntrospectableClient();
+ LorgnetteManagerClient* GetLorgnetteManagerClient();
+ ModemMessagingClient* GetModemMessagingClient();
+ NfcAdapterClient* GetNfcAdapterClient();
+ NfcDeviceClient* GetNfcDeviceClient();
+ NfcManagerClient* GetNfcManagerClient();
+ NfcRecordClient* GetNfcRecordClient();
+ NfcTagClient* GetNfcTagClient();
+ PermissionBrokerClient* GetPermissionBrokerClient();
+ PowerManagerClient* GetPowerManagerClient();
+ PowerPolicyController* GetPowerPolicyController();
+ SessionManagerClient* GetSessionManagerClient();
+ ShillDeviceClient* GetShillDeviceClient();
+ ShillIPConfigClient* GetShillIPConfigClient();
+ ShillManagerClient* GetShillManagerClient();
+ ShillServiceClient* GetShillServiceClient();
+ ShillProfileClient* GetShillProfileClient();
+ SMSClient* GetSMSClient();
+ SystemClockClient* GetSystemClockClient();
+ UpdateEngineClient* GetUpdateEngineClient();
private:
+ friend class DBusThreadManagerSetter;
+
+ DBusThreadManager();
+ ~DBusThreadManager();
+
+ // Creates a global instance of DBusThreadManager. Can not be called more
+ // than once.
+ static void CreateGlobalInstance();
+
// Initialize global thread manager instance.
static void InitializeRegular();
+ // Initialize global thread manager instance with stubbed-out dbus clients
+ // implementation.
+ static void InitializeWithStubs();
+
// Initialize with stub implementations for only certain clients that are
// not included in comma-separated |unstub_clients| list.
static void InitializeWithPartialStub(const std::string& unstub_clients);
- // InitializeClients is called after g_dbus_thread_manager is set.
- // NOTE: Clients that access other clients in their Init() must be
- // initialized in the correct order.
- static void InitializeClients();
+ // Constructs all clients and stores them in the respective *_client_ member
+ // variable.
+ void CreateDefaultClients();
- // Initializes |client| with the |system_bus_|.
- static void InitClient(DBusClient* client);
+ // Constructs all clients and stores them in the respective *_client_ member
+ // variable.
+ void InitializeClients();
// Bitmask that defines which dbus clients are not stubbed out. Bitmap flags
// are defined within DBusClientBundle::DBusClientType enum.
static DBusClientBundle::DBusClientTypeMask unstub_client_mask_;
+ scoped_ptr<base::Thread> dbus_thread_;
+ scoped_refptr<dbus::Bus> system_bus_;
+ scoped_ptr<DBusClientBundle> client_bundle_;
+ scoped_ptr<PowerPolicyController> power_policy_controller_;
+
DISALLOW_COPY_AND_ASSIGN(DBusThreadManager);
};
+class CHROMEOS_EXPORT DBusThreadManagerSetter {
+ public:
+ ~DBusThreadManagerSetter();
+
+ void SetBluetoothAdapterClient(scoped_ptr<BluetoothAdapterClient> client);
+ void SetBluetoothAgentManagerClient(
+ scoped_ptr<BluetoothAgentManagerClient> client);
+ void SetBluetoothDeviceClient(scoped_ptr<BluetoothDeviceClient> client);
+ void SetBluetoothGattCharacteristicClient(
+ scoped_ptr<BluetoothGattCharacteristicClient> client);
+ void SetBluetoothGattDescriptorClient(
+ scoped_ptr<BluetoothGattDescriptorClient> client);
+ void SetBluetoothGattManagerClient(
+ scoped_ptr<BluetoothGattManagerClient> client);
+ void SetBluetoothGattServiceClient(
+ scoped_ptr<BluetoothGattServiceClient> client);
+ void SetBluetoothInputClient(scoped_ptr<BluetoothInputClient> client);
+ void SetBluetoothProfileManagerClient(
+ scoped_ptr<BluetoothProfileManagerClient> client);
+ void SetCrasAudioClient(scoped_ptr<CrasAudioClient> client);
+ void SetCrosDisksClient(scoped_ptr<CrosDisksClient> client);
+ void SetCryptohomeClient(scoped_ptr<CryptohomeClient> client);
+ void SetDebugDaemonClient(scoped_ptr<DebugDaemonClient> client);
+ void SetEasyUnlockClient(scoped_ptr<EasyUnlockClient> client);
+ void SetLorgnetteManagerClient(scoped_ptr<LorgnetteManagerClient> client);
+ void SetShillDeviceClient(scoped_ptr<ShillDeviceClient> client);
+ void SetShillIPConfigClient(scoped_ptr<ShillIPConfigClient> client);
+ void SetShillManagerClient(scoped_ptr<ShillManagerClient> client);
+ void SetShillServiceClient(scoped_ptr<ShillServiceClient> client);
+ void SetShillProfileClient(scoped_ptr<ShillProfileClient> client);
+ void SetGsmSMSClient(scoped_ptr<GsmSMSClient> client);
+ void SetImageBurnerClient(scoped_ptr<ImageBurnerClient> client);
+ void SetIntrospectableClient(scoped_ptr<IntrospectableClient> client);
+ void SetModemMessagingClient(scoped_ptr<ModemMessagingClient> client);
+ void SetNfcAdapterClient(scoped_ptr<NfcAdapterClient> client);
+ void SetNfcDeviceClient(scoped_ptr<NfcDeviceClient> client);
+ void SetNfcManagerClient(scoped_ptr<NfcManagerClient> client);
+ void SetNfcRecordClient(scoped_ptr<NfcRecordClient> client);
+ void SetNfcTagClient(scoped_ptr<NfcTagClient> client);
+ void SetPermissionBrokerClient(scoped_ptr<PermissionBrokerClient> client);
+ void SetPowerManagerClient(scoped_ptr<PowerManagerClient> client);
+ void SetSessionManagerClient(scoped_ptr<SessionManagerClient> client);
+ void SetSMSClient(scoped_ptr<SMSClient> client);
+ void SetSystemClockClient(scoped_ptr<SystemClockClient> client);
+ void SetUpdateEngineClient(scoped_ptr<UpdateEngineClient> client);
+
+ private:
+ friend class DBusThreadManager;
+
+ DBusThreadManagerSetter();
+
+ DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerSetter);
+};
+
} // namespace chromeos
#endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_
diff --git a/chromeos/dbus/fake_dbus_thread_manager.cc b/chromeos/dbus/fake_dbus_thread_manager.cc
deleted file mode 100644
index abf26e9..0000000
--- a/chromeos/dbus/fake_dbus_thread_manager.cc
+++ /dev/null
@@ -1,472 +0,0 @@
-// 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/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_gatt_characteristic_client.h"
-#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h"
-#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h"
-#include "chromeos/dbus/fake_bluetooth_gatt_service_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_easy_unlock_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_lorgnette_manager_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() {
-}
-
-void FakeDBusThreadManager::SetFakeClients() {
- const DBusClientImplementationType client_type =
- STUB_DBUS_CLIENT_IMPLEMENTATION;
- SetBluetoothAdapterClient(
- scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient));
- SetBluetoothAgentManagerClient(scoped_ptr<BluetoothAgentManagerClient>(
- new FakeBluetoothAgentManagerClient));
- SetBluetoothDeviceClient(
- scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient));
- SetBluetoothGattCharacteristicClient(
- scoped_ptr<BluetoothGattCharacteristicClient>(
- new FakeBluetoothGattCharacteristicClient));
- SetBluetoothGattDescriptorClient(scoped_ptr<BluetoothGattDescriptorClient>(
- new FakeBluetoothGattDescriptorClient));
- SetBluetoothGattManagerClient(scoped_ptr<BluetoothGattManagerClient>(
- new FakeBluetoothGattManagerClient));
- SetBluetoothGattServiceClient(scoped_ptr<BluetoothGattServiceClient>(
- new FakeBluetoothGattServiceClient));
- SetBluetoothInputClient(
- scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient));
- SetBluetoothProfileManagerClient(scoped_ptr<BluetoothProfileManagerClient>(
- new FakeBluetoothProfileManagerClient));
- SetCrosDisksClient(
- scoped_ptr<CrosDisksClient>(CrosDisksClient::Create(client_type)));
- SetCrasAudioClient(scoped_ptr<CrasAudioClient>(new CrasAudioClientStubImpl));
- SetCryptohomeClient(scoped_ptr<CryptohomeClient>(new FakeCryptohomeClient));
- SetDebugDaemonClient(
- scoped_ptr<DebugDaemonClient>(new FakeDebugDaemonClient));
- SetEasyUnlockClient(scoped_ptr<EasyUnlockClient>(new FakeEasyUnlockClient));
- SetLorgnetteManagerClient(
- scoped_ptr<LorgnetteManagerClient>(new FakeLorgnetteManagerClient));
-
- SetFakeShillClients();
-
- FakeGsmSMSClient* gsm_sms_client = new FakeGsmSMSClient();
- gsm_sms_client->set_sms_test_message_switch_present(
- CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kSmsTestMessages));
- SetGsmSMSClient(scoped_ptr<GsmSMSClient>(gsm_sms_client));
-
- SetImageBurnerClient(
- scoped_ptr<ImageBurnerClient>(new FakeImageBurnerClient));
- SetIntrospectableClient(
- scoped_ptr<IntrospectableClient>(new FakeIntrospectableClient));
- SetModemMessagingClient(
- scoped_ptr<ModemMessagingClient>(new FakeModemMessagingClient));
- SetNfcAdapterClient(scoped_ptr<NfcAdapterClient>(new FakeNfcAdapterClient));
- SetNfcDeviceClient(scoped_ptr<NfcDeviceClient>(new FakeNfcDeviceClient));
- SetNfcManagerClient(scoped_ptr<NfcManagerClient>(new FakeNfcManagerClient));
- SetNfcRecordClient(scoped_ptr<NfcRecordClient>(new FakeNfcRecordClient));
- SetNfcTagClient(scoped_ptr<NfcTagClient>(new FakeNfcTagClient));
- SetPermissionBrokerClient(
- scoped_ptr<PermissionBrokerClient>(new FakePermissionBrokerClient));
- SetPowerManagerClient(
- scoped_ptr<PowerManagerClient>(PowerManagerClient::Create(client_type)));
- SetSessionManagerClient(scoped_ptr<SessionManagerClient>(
- SessionManagerClient::Create(client_type)));
- SetSMSClient(scoped_ptr<SMSClient>(new FakeSMSClient));
- SetSystemClockClient(
- scoped_ptr<SystemClockClient>(new FakeSystemClockClient));
- SetUpdateEngineClient(
- scoped_ptr<UpdateEngineClient>(UpdateEngineClient::Create(client_type)));
-
- SetPowerPolicyController(make_scoped_ptr(new PowerPolicyController));
-}
-
-void FakeDBusThreadManager::SetFakeShillClients() {
- SetShillManagerClient(
- scoped_ptr<ShillManagerClient>(new FakeShillManagerClient));
- SetShillDeviceClient(
- scoped_ptr<ShillDeviceClient>(new FakeShillDeviceClient));
- SetShillIPConfigClient(
- scoped_ptr<ShillIPConfigClient>(new FakeShillIPConfigClient));
- SetShillServiceClient(
- scoped_ptr<ShillServiceClient>(new FakeShillServiceClient));
- SetShillProfileClient(
- scoped_ptr<ShillProfileClient>(new FakeShillProfileClient));
-}
-
-void FakeDBusThreadManager::SetupDefaultEnvironment() {
- ShillManagerClient::TestInterface* manager =
- shill_manager_client_->GetTestInterface();
- if (manager)
- manager->SetupDefaultEnvironment();
-}
-
-void FakeDBusThreadManager::SetBluetoothAdapterClient(
- scoped_ptr<BluetoothAdapterClient> client) {
- bluetooth_adapter_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothAgentManagerClient(
- scoped_ptr<BluetoothAgentManagerClient> client) {
- bluetooth_agent_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothDeviceClient(
- scoped_ptr<BluetoothDeviceClient> client) {
- bluetooth_device_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothGattCharacteristicClient(
- scoped_ptr<BluetoothGattCharacteristicClient> client) {
- bluetooth_gatt_characteristic_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothGattDescriptorClient(
- scoped_ptr<BluetoothGattDescriptorClient> client) {
- bluetooth_gatt_descriptor_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothGattManagerClient(
- scoped_ptr<BluetoothGattManagerClient> client) {
- bluetooth_gatt_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothGattServiceClient(
- scoped_ptr<BluetoothGattServiceClient> client) {
- bluetooth_gatt_service_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothInputClient(
- scoped_ptr<BluetoothInputClient> client) {
- bluetooth_input_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetBluetoothProfileManagerClient(
- scoped_ptr<BluetoothProfileManagerClient> client) {
- bluetooth_profile_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetCrasAudioClient(
- scoped_ptr<CrasAudioClient> client) {
- cras_audio_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetCrosDisksClient(
- scoped_ptr<CrosDisksClient> client) {
- cros_disks_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetCryptohomeClient(
- scoped_ptr<CryptohomeClient> client) {
- cryptohome_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetDebugDaemonClient(
- scoped_ptr<DebugDaemonClient> client) {
- debug_daemon_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetEasyUnlockClient(
- scoped_ptr<EasyUnlockClient> client) {
- easy_unlock_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetLorgnetteManagerClient(
- scoped_ptr<LorgnetteManagerClient> client) {
- lorgnette_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetShillDeviceClient(
- scoped_ptr<ShillDeviceClient> client) {
- shill_device_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetShillIPConfigClient(
- scoped_ptr<ShillIPConfigClient> client) {
- shill_ipconfig_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetShillManagerClient(
- scoped_ptr<ShillManagerClient> client) {
- shill_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetShillServiceClient(
- scoped_ptr<ShillServiceClient> client) {
- shill_service_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetShillProfileClient(
- scoped_ptr<ShillProfileClient> client) {
- shill_profile_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetGsmSMSClient(scoped_ptr<GsmSMSClient> client) {
- gsm_sms_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetImageBurnerClient(
- scoped_ptr<ImageBurnerClient> client) {
- image_burner_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetIntrospectableClient(
- scoped_ptr<IntrospectableClient> client) {
- introspectable_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetModemMessagingClient(
- scoped_ptr<ModemMessagingClient> client) {
- modem_messaging_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetNfcAdapterClient(
- scoped_ptr<NfcAdapterClient> client) {
- nfc_adapter_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetNfcDeviceClient(
- scoped_ptr<NfcDeviceClient> client) {
- nfc_device_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetNfcManagerClient(
- scoped_ptr<NfcManagerClient> client) {
- nfc_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetNfcRecordClient(
- scoped_ptr<NfcRecordClient> client) {
- nfc_record_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetNfcTagClient(scoped_ptr<NfcTagClient> client) {
- nfc_tag_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetPermissionBrokerClient(
- scoped_ptr<PermissionBrokerClient> client) {
- permission_broker_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetPowerManagerClient(
- scoped_ptr<PowerManagerClient> client) {
- power_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetPowerPolicyController(
- scoped_ptr<PowerPolicyController> client) {
- power_policy_controller_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetSessionManagerClient(
- scoped_ptr<SessionManagerClient> client) {
- session_manager_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetSMSClient(scoped_ptr<SMSClient> client) {
- sms_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetSystemClockClient(
- scoped_ptr<SystemClockClient> client) {
- system_clock_client_ = client.Pass();
-}
-
-void FakeDBusThreadManager::SetUpdateEngineClient(
- scoped_ptr<UpdateEngineClient> client) {
- update_engine_client_ = client.Pass();
-}
-
-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();
-}
-
-BluetoothGattCharacteristicClient*
-FakeDBusThreadManager::GetBluetoothGattCharacteristicClient() {
- return bluetooth_gatt_characteristic_client_.get();
-}
-
-BluetoothGattDescriptorClient*
-FakeDBusThreadManager::GetBluetoothGattDescriptorClient() {
- return bluetooth_gatt_descriptor_client_.get();
-}
-
-BluetoothGattManagerClient*
-FakeDBusThreadManager::GetBluetoothGattManagerClient() {
- return bluetooth_gatt_manager_client_.get();
-}
-
-BluetoothGattServiceClient*
-FakeDBusThreadManager::GetBluetoothGattServiceClient() {
- return bluetooth_gatt_service_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();
-}
-
-EasyUnlockClient* FakeDBusThreadManager::GetEasyUnlockClient() {
- return easy_unlock_client_.get();
-}
-LorgnetteManagerClient* FakeDBusThreadManager::GetLorgnetteManagerClient() {
- return lorgnette_manager_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
diff --git a/chromeos/dbus/fake_dbus_thread_manager.h b/chromeos/dbus/fake_dbus_thread_manager.h
deleted file mode 100644
index d70f599..0000000
--- a/chromeos/dbus/fake_dbus_thread_manager.h
+++ /dev/null
@@ -1,167 +0,0 @@
-// 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.
-
-#ifndef CHROMEOS_DBUS_FAKE_DBUS_THREAD_MANAGER_H_
-#define CHROMEOS_DBUS_FAKE_DBUS_THREAD_MANAGER_H_
-
-#include "base/logging.h"
-#include "chromeos/chromeos_export.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-
-namespace dbus {
-class Bus;
-class ObjectPath;
-} // namespace dbus
-
-namespace chromeos {
-
-// This class provides a fake implementation of DBusThreadManager, which
-// hosts fake D-Bus clients.
-class CHROMEOS_EXPORT FakeDBusThreadManager : public DBusThreadManager {
- public:
- FakeDBusThreadManager();
- virtual ~FakeDBusThreadManager();
-
- // Creates and sets all fake DBusClients and the PowerPolicyController.
- void SetFakeClients();
-
- // Creates and sets all fake Shill DBusClients.
- void SetFakeShillClients();
-
- // Sets up any default environment for fake clients, e.g. for UI testing.
- void SetupDefaultEnvironment();
-
- void SetBluetoothAdapterClient(scoped_ptr<BluetoothAdapterClient> client);
- void SetBluetoothAgentManagerClient(
- scoped_ptr<BluetoothAgentManagerClient> client);
- void SetBluetoothDeviceClient(scoped_ptr<BluetoothDeviceClient> client);
- void SetBluetoothGattCharacteristicClient(
- scoped_ptr<BluetoothGattCharacteristicClient> client);
- void SetBluetoothGattDescriptorClient(
- scoped_ptr<BluetoothGattDescriptorClient> client);
- void SetBluetoothGattManagerClient(
- scoped_ptr<BluetoothGattManagerClient> client);
- void SetBluetoothGattServiceClient(
- scoped_ptr<BluetoothGattServiceClient> client);
- void SetBluetoothInputClient(scoped_ptr<BluetoothInputClient> client);
- void SetBluetoothProfileManagerClient(
- scoped_ptr<BluetoothProfileManagerClient> client);
- void SetCrasAudioClient(scoped_ptr<CrasAudioClient> client);
- void SetCrosDisksClient(scoped_ptr<CrosDisksClient> client);
- void SetCryptohomeClient(scoped_ptr<CryptohomeClient> client);
- void SetDebugDaemonClient(scoped_ptr<DebugDaemonClient> client);
- void SetEasyUnlockClient(scoped_ptr<EasyUnlockClient> client);
- void SetLorgnetteManagerClient(scoped_ptr<LorgnetteManagerClient> client);
- void SetShillDeviceClient(scoped_ptr<ShillDeviceClient> client);
- void SetShillIPConfigClient(scoped_ptr<ShillIPConfigClient> client);
- void SetShillManagerClient(scoped_ptr<ShillManagerClient> client);
- void SetShillServiceClient(scoped_ptr<ShillServiceClient> client);
- void SetShillProfileClient(scoped_ptr<ShillProfileClient> client);
- void SetGsmSMSClient(scoped_ptr<GsmSMSClient> client);
- void SetImageBurnerClient(scoped_ptr<ImageBurnerClient> client);
- void SetIntrospectableClient(scoped_ptr<IntrospectableClient> client);
- void SetModemMessagingClient(scoped_ptr<ModemMessagingClient> client);
- void SetNfcAdapterClient(scoped_ptr<NfcAdapterClient> client);
- void SetNfcDeviceClient(scoped_ptr<NfcDeviceClient> client);
- void SetNfcManagerClient(scoped_ptr<NfcManagerClient> client);
- void SetNfcRecordClient(scoped_ptr<NfcRecordClient> client);
- void SetNfcTagClient(scoped_ptr<NfcTagClient> client);
- void SetPermissionBrokerClient(scoped_ptr<PermissionBrokerClient> client);
- void SetPowerManagerClient(scoped_ptr<PowerManagerClient> client);
- void SetPowerPolicyController(scoped_ptr<PowerPolicyController> client);
- void SetSessionManagerClient(scoped_ptr<SessionManagerClient> client);
- void SetSMSClient(scoped_ptr<SMSClient> client);
- void SetSystemClockClient(scoped_ptr<SystemClockClient> client);
- void SetUpdateEngineClient(scoped_ptr<UpdateEngineClient> client);
-
- virtual dbus::Bus* GetSystemBus() OVERRIDE;
-
- virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE;
- virtual BluetoothAgentManagerClient*
- GetBluetoothAgentManagerClient() OVERRIDE;
- virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE;
- virtual BluetoothGattCharacteristicClient*
- GetBluetoothGattCharacteristicClient() OVERRIDE;
- virtual BluetoothGattDescriptorClient*
- GetBluetoothGattDescriptorClient() OVERRIDE;
- virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() OVERRIDE;
- virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() OVERRIDE;
- virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE;
- virtual BluetoothProfileManagerClient*
- GetBluetoothProfileManagerClient() OVERRIDE;
- virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE;
- virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE;
- virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE;
- virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE;
- virtual EasyUnlockClient* GetEasyUnlockClient() OVERRIDE;
- virtual LorgnetteManagerClient* GetLorgnetteManagerClient() OVERRIDE;
- virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE;
- virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE;
- virtual ShillManagerClient* GetShillManagerClient() OVERRIDE;
- virtual ShillProfileClient* GetShillProfileClient() OVERRIDE;
- virtual ShillServiceClient* GetShillServiceClient() OVERRIDE;
- virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE;
- virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE;
- virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE;
- virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE;
- virtual NfcAdapterClient* GetNfcAdapterClient() OVERRIDE;
- virtual NfcDeviceClient* GetNfcDeviceClient() OVERRIDE;
- virtual NfcManagerClient* GetNfcManagerClient() OVERRIDE;
- virtual NfcRecordClient* GetNfcRecordClient() OVERRIDE;
- virtual NfcTagClient* GetNfcTagClient() OVERRIDE;
- virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE;
- virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE;
- virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE;
- virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE;
- virtual SMSClient* GetSMSClient() OVERRIDE;
- virtual SystemClockClient* GetSystemClockClient() OVERRIDE;
- virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE;
-
- private:
- scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_;
- scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_;
- scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_;
- scoped_ptr<BluetoothGattCharacteristicClient>
- bluetooth_gatt_characteristic_client_;
- scoped_ptr<BluetoothGattDescriptorClient>
- bluetooth_gatt_descriptor_client_;
- scoped_ptr<BluetoothGattManagerClient> bluetooth_gatt_manager_client_;
- scoped_ptr<BluetoothGattServiceClient> bluetooth_gatt_service_client_;
- scoped_ptr<BluetoothInputClient> bluetooth_input_client_;
- scoped_ptr<BluetoothProfileManagerClient> bluetooth_profile_manager_client_;
- scoped_ptr<CrasAudioClient> cras_audio_client_;
- scoped_ptr<CrosDisksClient> cros_disks_client_;
- scoped_ptr<CryptohomeClient> cryptohome_client_;
- scoped_ptr<DebugDaemonClient> debug_daemon_client_;
- scoped_ptr<EasyUnlockClient> easy_unlock_client_;
- scoped_ptr<LorgnetteManagerClient> lorgnette_manager_client_;
- scoped_ptr<ShillDeviceClient> shill_device_client_;
- scoped_ptr<ShillIPConfigClient> shill_ipconfig_client_;
- scoped_ptr<ShillManagerClient> shill_manager_client_;
- scoped_ptr<ShillServiceClient> shill_service_client_;
- scoped_ptr<ShillProfileClient> shill_profile_client_;
- scoped_ptr<GsmSMSClient> gsm_sms_client_;
- scoped_ptr<ImageBurnerClient> image_burner_client_;
- scoped_ptr<IntrospectableClient> introspectable_client_;
- scoped_ptr<ModemMessagingClient> modem_messaging_client_;
- scoped_ptr<NfcAdapterClient> nfc_adapter_client_;
- scoped_ptr<NfcDeviceClient> nfc_device_client_;
- scoped_ptr<NfcManagerClient> nfc_manager_client_;
- scoped_ptr<NfcRecordClient> nfc_record_client_;
- scoped_ptr<NfcTagClient> nfc_tag_client_;
- scoped_ptr<PermissionBrokerClient> permission_broker_client_;
- scoped_ptr<SystemClockClient> system_clock_client_;
- scoped_ptr<PowerManagerClient> power_manager_client_;
- scoped_ptr<SessionManagerClient> session_manager_client_;
- scoped_ptr<SMSClient> sms_client_;
- scoped_ptr<UpdateEngineClient> update_engine_client_;
-
- scoped_ptr<PowerPolicyController> power_policy_controller_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeDBusThreadManager);
-};
-
-} // namespace chromeos
-
-#endif // CHROMEOS_DBUS_FAKE_DBUS_THREAD_MANAGER_H_
diff --git a/chromeos/dbus/fake_shill_manager_client.cc b/chromeos/dbus/fake_shill_manager_client.cc
index f524c1f..7b4eb61 100644
--- a/chromeos/dbus/fake_shill_manager_client.cc
+++ b/chromeos/dbus/fake_shill_manager_client.cc
@@ -565,6 +565,11 @@ void FakeShillManagerClient::SetBestServiceToConnect(
}
void FakeShillManagerClient::SetupDefaultEnvironment() {
+ // Bail out from setup if there is no message loop. This will be the common
+ // case for tests that are not testing Shill.
+ if (!base::MessageLoop::current())
+ return;
+
DBusThreadManager* dbus_manager = DBusThreadManager::Get();
ShillServiceClient::TestInterface* services =
dbus_manager->GetShillServiceClient()->GetTestInterface();
diff --git a/chromeos/dbus/power_policy_controller_unittest.cc b/chromeos/dbus/power_policy_controller_unittest.cc
index b4e7bf4..755cc53 100644
--- a/chromeos/dbus/power_policy_controller_unittest.cc
+++ b/chromeos/dbus/power_policy_controller_unittest.cc
@@ -5,8 +5,8 @@
#include "chromeos/dbus/power_policy_controller.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
#include "chromeos/dbus/fake_power_manager_client.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,14 +22,14 @@ class PowerPolicyControllerTest : public testing::Test {
virtual ~PowerPolicyControllerTest() {}
virtual void SetUp() OVERRIDE {
- dbus_manager_ = new FakeDBusThreadManager;
+ scoped_ptr<DBusThreadManagerSetter> dbus_setter =
+ chromeos::DBusThreadManager::GetSetterForTesting();
fake_power_client_ = new FakePowerManagerClient;
- dbus_manager_->SetPowerManagerClient(
+ dbus_setter->SetPowerManagerClient(
scoped_ptr<PowerManagerClient>(fake_power_client_));
- DBusThreadManager::InitializeForTesting(dbus_manager_); // Takes ownership.
policy_controller_.reset(new PowerPolicyController);
- policy_controller_->Init(dbus_manager_);
+ policy_controller_->Init(DBusThreadManager::Get());
}
virtual void TearDown() OVERRIDE {
@@ -38,9 +38,9 @@ class PowerPolicyControllerTest : public testing::Test {
}
protected:
- FakeDBusThreadManager* dbus_manager_; // Not owned.
FakePowerManagerClient* fake_power_client_;
scoped_ptr<PowerPolicyController> policy_controller_;
+ base::MessageLoop message_loop_;
};
TEST_F(PowerPolicyControllerTest, Prefs) {
diff --git a/chromeos/disks/disk_mount_manager_unittest.cc b/chromeos/disks/disk_mount_manager_unittest.cc
index b7a8e49..674ee7a 100644
--- a/chromeos/disks/disk_mount_manager_unittest.cc
+++ b/chromeos/disks/disk_mount_manager_unittest.cc
@@ -4,8 +4,8 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_cros_disks_client.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,7 +14,6 @@ using chromeos::disks::DiskMountManager;
using chromeos::CrosDisksClient;
using chromeos::DBusThreadManager;
using chromeos::FakeCrosDisksClient;
-using chromeos::FakeDBusThreadManager;
using testing::_;
using testing::Field;
using testing::InSequence;
@@ -123,13 +122,10 @@ class DiskMountManagerTest : public testing::Test {
// Initializes disk mount manager disks and mount points.
// Adds a test observer to the disk mount manager.
virtual void SetUp() {
- FakeDBusThreadManager* fake_thread_manager = new FakeDBusThreadManager();
fake_cros_disks_client_ = new FakeCrosDisksClient;
- fake_thread_manager->SetCrosDisksClient(
+ DBusThreadManager::GetSetterForTesting()->SetCrosDisksClient(
scoped_ptr<CrosDisksClient>(fake_cros_disks_client_));
- DBusThreadManager::InitializeForTesting(fake_thread_manager);
-
DiskMountManager::Initialize();
InitDisksAndMountPoints();
diff --git a/chromeos/network/client_cert_resolver_unittest.cc b/chromeos/network/client_cert_resolver_unittest.cc
index f2dc452..89df842 100644
--- a/chromeos/network/client_cert_resolver_unittest.cc
+++ b/chromeos/network/client_cert_resolver_unittest.cc
@@ -69,7 +69,7 @@ class ClientCertResolverTest : public testing::Test {
base::Callback<void(crypto::ScopedPK11Slot)>())));
test_nssdb_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy());
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
service_test_ =
DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
profile_test_ =
diff --git a/chromeos/network/geolocation_handler_unittest.cc b/chromeos/network/geolocation_handler_unittest.cc
index be0985d..af5dc19 100644
--- a/chromeos/network/geolocation_handler_unittest.cc
+++ b/chromeos/network/geolocation_handler_unittest.cc
@@ -24,7 +24,7 @@ class GeolocationHandlerTest : public testing::Test {
virtual void SetUp() OVERRIDE {
// Initialize DBusThreadManager with a stub implementation.
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
// Get the test interface for manager / device.
manager_test_ =
DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface();
diff --git a/chromeos/network/host_resolver_impl_chromeos_unittest.cc b/chromeos/network/host_resolver_impl_chromeos_unittest.cc
index e27175ed..9567b8b 100644
--- a/chromeos/network/host_resolver_impl_chromeos_unittest.cc
+++ b/chromeos/network/host_resolver_impl_chromeos_unittest.cc
@@ -41,7 +41,7 @@ class HostResolverImplChromeOSTest : public testing::Test {
virtual ~HostResolverImplChromeOSTest() {}
virtual void SetUp() OVERRIDE {
- chromeos::DBusThreadManager::InitializeWithStub();
+ chromeos::DBusThreadManager::Initialize();
network_state_handler_.reset(
chromeos::NetworkStateHandler::InitializeForTest());
diff --git a/chromeos/network/managed_network_configuration_handler_unittest.cc b/chromeos/network/managed_network_configuration_handler_unittest.cc
index c3cc5c4..b4ec1cc 100644
--- a/chromeos/network/managed_network_configuration_handler_unittest.cc
+++ b/chromeos/network/managed_network_configuration_handler_unittest.cc
@@ -12,7 +12,6 @@
#include "base/stl_util.h"
#include "base/values.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
#include "chromeos/dbus/mock_shill_manager_client.h"
#include "chromeos/dbus/mock_shill_profile_client.h"
#include "chromeos/dbus/shill_client_helper.h"
@@ -159,16 +158,15 @@ class ManagedNetworkConfigurationHandlerTest : public testing::Test {
}
virtual void SetUp() OVERRIDE {
- FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager;
+ scoped_ptr<DBusThreadManagerSetter> dbus_setter =
+ DBusThreadManager::GetSetterForTesting();
mock_manager_client_ = new StrictMock<MockShillManagerClient>();
mock_profile_client_ = new StrictMock<MockShillProfileClient>();
- dbus_thread_manager->SetShillManagerClient(
+ dbus_setter->SetShillManagerClient(
scoped_ptr<ShillManagerClient>(mock_manager_client_).Pass());
- dbus_thread_manager->SetShillProfileClient(
+ dbus_setter->SetShillProfileClient(
scoped_ptr<ShillProfileClient>(mock_profile_client_).Pass());
- DBusThreadManager::InitializeForTesting(dbus_thread_manager);
-
SetNetworkConfigurationHandlerExpectations();
ON_CALL(*mock_profile_client_, GetProperties(_,_,_))
diff --git a/chromeos/network/network_cert_migrator_unittest.cc b/chromeos/network/network_cert_migrator_unittest.cc
index 32798c8..a749cd9 100644
--- a/chromeos/network/network_cert_migrator_unittest.cc
+++ b/chromeos/network/network_cert_migrator_unittest.cc
@@ -58,7 +58,7 @@ class NetworkCertMigratorTest : public testing::Test {
base::Callback<void(crypto::ScopedPK11Slot)>())));
test_nssdb_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy());
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
service_test_ =
DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
DBusThreadManager::Get()
diff --git a/chromeos/network/network_configuration_handler_unittest.cc b/chromeos/network/network_configuration_handler_unittest.cc
index dcc47f0..3609b11 100644
--- a/chromeos/network/network_configuration_handler_unittest.cc
+++ b/chromeos/network/network_configuration_handler_unittest.cc
@@ -8,7 +8,6 @@
#include "base/strings/string_piece.h"
#include "base/values.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
#include "chromeos/dbus/mock_shill_manager_client.h"
#include "chromeos/dbus/mock_shill_profile_client.h"
#include "chromeos/dbus/mock_shill_service_client.h"
@@ -99,15 +98,16 @@ class NetworkConfigurationHandlerTest : public testing::Test {
virtual ~NetworkConfigurationHandlerTest() {}
virtual void SetUp() OVERRIDE {
- FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager;
+ scoped_ptr<DBusThreadManagerSetter> dbus_setter =
+ DBusThreadManager::GetSetterForTesting();
mock_manager_client_ = new MockShillManagerClient();
mock_profile_client_ = new MockShillProfileClient();
mock_service_client_ = new MockShillServiceClient();
- dbus_thread_manager->SetShillManagerClient(
+ dbus_setter->SetShillManagerClient(
scoped_ptr<ShillManagerClient>(mock_manager_client_).Pass());
- dbus_thread_manager->SetShillProfileClient(
+ dbus_setter->SetShillProfileClient(
scoped_ptr<ShillProfileClient>(mock_profile_client_).Pass());
- dbus_thread_manager->SetShillServiceClient(
+ dbus_setter->SetShillServiceClient(
scoped_ptr<ShillServiceClient>(mock_service_client_).Pass());
EXPECT_CALL(*mock_service_client_, GetProperties(_, _))
@@ -119,8 +119,6 @@ class NetworkConfigurationHandlerTest : public testing::Test {
EXPECT_CALL(*mock_manager_client_, RemovePropertyChangedObserver(_))
.Times(AnyNumber());
- DBusThreadManager::InitializeForTesting(dbus_thread_manager);
-
network_state_handler_.reset(NetworkStateHandler::InitializeForTest());
network_configuration_handler_.reset(new NetworkConfigurationHandler());
network_configuration_handler_->Init(network_state_handler_.get());
@@ -436,7 +434,7 @@ class NetworkConfigurationHandlerStubTest : public testing::Test {
}
virtual void SetUp() OVERRIDE {
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
network_state_handler_.reset(NetworkStateHandler::InitializeForTest());
test_observer_.reset(new TestObserver());
diff --git a/chromeos/network/network_connection_handler_unittest.cc b/chromeos/network/network_connection_handler_unittest.cc
index b22c07d..ed737ac 100644
--- a/chromeos/network/network_connection_handler_unittest.cc
+++ b/chromeos/network/network_connection_handler_unittest.cc
@@ -13,7 +13,7 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "chromeos/cert_loader.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
#include "chromeos/dbus/shill_manager_client.h"
#include "chromeos/dbus/shill_profile_client.h"
@@ -77,9 +77,8 @@ class NetworkConnectionHandlerTest : public testing::Test {
CertLoader* cert_loader = CertLoader::Get();
cert_loader->force_hardware_backed_for_test();
- FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager;
- dbus_manager->SetFakeClients();
- DBusThreadManager::InitializeForTesting(dbus_manager);
+ DBusThreadManager::Initialize();
+ DBusThreadManager* dbus_manager = DBusThreadManager::Get();
test_manager_client_ =
dbus_manager->GetShillManagerClient()->GetTestInterface();
test_service_client_ =
diff --git a/chromeos/network/network_device_handler_unittest.cc b/chromeos/network/network_device_handler_unittest.cc
index af4b93f..644ac57 100644
--- a/chromeos/network/network_device_handler_unittest.cc
+++ b/chromeos/network/network_device_handler_unittest.cc
@@ -6,7 +6,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/values.h"
-#include "chromeos/dbus/fake_dbus_thread_manager.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_shill_device_client.h"
#include "chromeos/dbus/fake_shill_manager_client.h"
#include "chromeos/network/network_device_handler_impl.h"
@@ -32,13 +32,9 @@ class NetworkDeviceHandlerTest : public testing::Test {
virtual ~NetworkDeviceHandlerTest() {}
virtual void SetUp() OVERRIDE {
- FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager;
- dbus_manager->SetFakeShillClients();
-
fake_device_client_ = new FakeShillDeviceClient;
- dbus_manager->SetShillDeviceClient(
+ DBusThreadManager::GetSetterForTesting()->SetShillDeviceClient(
scoped_ptr<ShillDeviceClient>(fake_device_client_));
- DBusThreadManager::InitializeForTesting(dbus_manager);
success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback,
base::Unretained(this));
diff --git a/chromeos/network/network_sms_handler_unittest.cc b/chromeos/network/network_sms_handler_unittest.cc
index b1c06e1..a050d2b 100644
--- a/chromeos/network/network_sms_handler_unittest.cc
+++ b/chromeos/network/network_sms_handler_unittest.cc
@@ -60,7 +60,7 @@ class NetworkSmsHandlerTest : public testing::Test {
command_line->AppendSwitch(chromeos::switches::kSmsTestMessages);
// Initialize DBusThreadManager with a stub implementation.
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
ShillDeviceClient::TestInterface* device_test =
DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
ASSERT_TRUE(device_test);
diff --git a/chromeos/network/network_state_handler_unittest.cc b/chromeos/network/network_state_handler_unittest.cc
index 74c9b6d..6b41251 100644
--- a/chromeos/network/network_state_handler_unittest.cc
+++ b/chromeos/network/network_state_handler_unittest.cc
@@ -179,7 +179,7 @@ class NetworkStateHandlerTest : public testing::Test {
virtual void SetUp() OVERRIDE {
// Initialize DBusThreadManager with a stub implementation.
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
SetupDefaultShillState();
network_state_handler_.reset(new NetworkStateHandler);
test_observer_.reset(new TestObserver(network_state_handler_.get()));
diff --git a/chromeos/network/shill_property_handler_unittest.cc b/chromeos/network/shill_property_handler_unittest.cc
index cb82890..6c311ea 100644
--- a/chromeos/network/shill_property_handler_unittest.cc
+++ b/chromeos/network/shill_property_handler_unittest.cc
@@ -177,7 +177,7 @@ class ShillPropertyHandlerTest : public testing::Test {
virtual void SetUp() OVERRIDE {
// Initialize DBusThreadManager with a stub implementation.
- DBusThreadManager::InitializeWithStub();
+ DBusThreadManager::Initialize();
// Get the test interface for manager / device / service and clear the
// default stub properties.
manager_test_ =