Index: device/bluetooth/bluetooth_chromeos_unittest.cc |
diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc |
index 379d1dfd25fc6994e462d11726f63e0f80651331..87b454f17a2c6f8e7c8f2d000f86e42860fb03f7 100644 |
--- a/device/bluetooth/bluetooth_chromeos_unittest.cc |
+++ b/device/bluetooth/bluetooth_chromeos_unittest.cc |
@@ -235,6 +235,10 @@ class BluetoothChromeOSTest : public testing::Test { |
public: |
virtual void SetUp() { |
FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; |
+ // We need to initialize DBusThreadManager early to prevent |
+ // Bluetooth*::Create() methods from picking the real instead of fake |
+ // implementations. |
+ DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); |
fake_bluetooth_adapter_client_ = new FakeBluetoothAdapterClient; |
fake_dbus_thread_manager->SetBluetoothAdapterClient( |
scoped_ptr<BluetoothAdapterClient>(fake_bluetooth_adapter_client_)); |
@@ -249,7 +253,6 @@ class BluetoothChromeOSTest : public testing::Test { |
fake_dbus_thread_manager->SetBluetoothGattServiceClient( |
scoped_ptr<BluetoothGattServiceClient>( |
new FakeBluetoothGattServiceClient)); |
- DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); |
fake_bluetooth_adapter_client_->SetSimulationIntervalMs(10); |