OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chromeos/dbus/dbus_thread_manager.h" |
8 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
9 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
10 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 11 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
11 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" | 12 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" |
12 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 13 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
13 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
14 #include "dbus/object_path.h" | 14 #include "dbus/object_path.h" |
15 #include "device/bluetooth/bluetooth_adapter.h" | 15 #include "device/bluetooth/bluetooth_adapter.h" |
16 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 16 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
17 #include "device/bluetooth/bluetooth_adapter_factory.h" | 17 #include "device/bluetooth/bluetooth_adapter_factory.h" |
18 #include "device/bluetooth/bluetooth_device.h" | 18 #include "device/bluetooth/bluetooth_device.h" |
19 #include "device/bluetooth/bluetooth_device_chromeos.h" | 19 #include "device/bluetooth/bluetooth_device_chromeos.h" |
20 #include "device/bluetooth/bluetooth_discovery_session.h" | 20 #include "device/bluetooth/bluetooth_discovery_session.h" |
21 #include "device/bluetooth/bluetooth_pairing_chromeos.h" | 21 #include "device/bluetooth/bluetooth_pairing_chromeos.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void QuitMessageLoop() { | 227 void QuitMessageLoop() { |
228 if (base::MessageLoop::current() && | 228 if (base::MessageLoop::current() && |
229 base::MessageLoop::current()->is_running()) | 229 base::MessageLoop::current()->is_running()) |
230 base::MessageLoop::current()->Quit(); | 230 base::MessageLoop::current()->Quit(); |
231 } | 231 } |
232 }; | 232 }; |
233 | 233 |
234 class BluetoothChromeOSTest : public testing::Test { | 234 class BluetoothChromeOSTest : public testing::Test { |
235 public: | 235 public: |
236 virtual void SetUp() { | 236 virtual void SetUp() { |
237 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; | 237 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
| 238 chromeos::DBusThreadManager::GetSetterForTesting(); |
238 // We need to initialize DBusThreadManager early to prevent | 239 // We need to initialize DBusThreadManager early to prevent |
239 // Bluetooth*::Create() methods from picking the real instead of fake | 240 // Bluetooth*::Create() methods from picking the real instead of fake |
240 // implementations. | 241 // implementations. |
241 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); | |
242 fake_bluetooth_adapter_client_ = new FakeBluetoothAdapterClient; | 242 fake_bluetooth_adapter_client_ = new FakeBluetoothAdapterClient; |
243 fake_dbus_thread_manager->SetBluetoothAdapterClient( | 243 dbus_setter->SetBluetoothAdapterClient( |
244 scoped_ptr<BluetoothAdapterClient>(fake_bluetooth_adapter_client_)); | 244 scoped_ptr<BluetoothAdapterClient>(fake_bluetooth_adapter_client_)); |
245 fake_bluetooth_device_client_ = new FakeBluetoothDeviceClient; | 245 fake_bluetooth_device_client_ = new FakeBluetoothDeviceClient; |
246 fake_dbus_thread_manager->SetBluetoothDeviceClient( | 246 dbus_setter->SetBluetoothDeviceClient( |
247 scoped_ptr<BluetoothDeviceClient>(fake_bluetooth_device_client_)); | 247 scoped_ptr<BluetoothDeviceClient>(fake_bluetooth_device_client_)); |
248 fake_dbus_thread_manager->SetBluetoothInputClient( | 248 dbus_setter->SetBluetoothInputClient( |
249 scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); | 249 scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); |
250 fake_dbus_thread_manager->SetBluetoothAgentManagerClient( | 250 dbus_setter->SetBluetoothAgentManagerClient( |
251 scoped_ptr<BluetoothAgentManagerClient>( | 251 scoped_ptr<BluetoothAgentManagerClient>( |
252 new FakeBluetoothAgentManagerClient)); | 252 new FakeBluetoothAgentManagerClient)); |
253 fake_dbus_thread_manager->SetBluetoothGattServiceClient( | 253 dbus_setter->SetBluetoothGattServiceClient( |
254 scoped_ptr<BluetoothGattServiceClient>( | 254 scoped_ptr<BluetoothGattServiceClient>( |
255 new FakeBluetoothGattServiceClient)); | 255 new FakeBluetoothGattServiceClient)); |
256 | 256 |
257 fake_bluetooth_adapter_client_->SetSimulationIntervalMs(10); | 257 fake_bluetooth_adapter_client_->SetSimulationIntervalMs(10); |
258 | 258 |
259 callback_count_ = 0; | 259 callback_count_ = 0; |
260 error_callback_count_ = 0; | 260 error_callback_count_ = 0; |
261 last_connect_error_ = BluetoothDevice::ERROR_UNKNOWN; | 261 last_connect_error_ = BluetoothDevice::ERROR_UNKNOWN; |
262 last_client_error_ = ""; | 262 last_client_error_ = ""; |
263 } | 263 } |
(...skipping 2912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3176 // Unknown vendor specification identifier. | 3176 // Unknown vendor specification identifier. |
3177 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); | 3177 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); |
3178 | 3178 |
3179 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); | 3179 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); |
3180 EXPECT_EQ(0, device->GetVendorID()); | 3180 EXPECT_EQ(0, device->GetVendorID()); |
3181 EXPECT_EQ(0, device->GetProductID()); | 3181 EXPECT_EQ(0, device->GetProductID()); |
3182 EXPECT_EQ(0, device->GetDeviceID()); | 3182 EXPECT_EQ(0, device->GetDeviceID()); |
3183 } | 3183 } |
3184 | 3184 |
3185 } // namespace chromeos | 3185 } // namespace chromeos |
OLD | NEW |