OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.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_bluetooth_profile_manager_client.h" | 14 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" |
14 #include "chromeos/dbus/fake_dbus_thread_manager.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_socket.h" | 20 #include "device/bluetooth/bluetooth_socket.h" |
21 #include "device/bluetooth/bluetooth_socket_chromeos.h" | 21 #include "device/bluetooth/bluetooth_socket_chromeos.h" |
22 #include "device/bluetooth/bluetooth_socket_thread.h" | 22 #include "device/bluetooth/bluetooth_socket_thread.h" |
23 #include "device/bluetooth/bluetooth_uuid.h" | 23 #include "device/bluetooth/bluetooth_uuid.h" |
24 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
(...skipping 18 matching lines...) Expand all Loading... |
43 class BluetoothSocketChromeOSTest : public testing::Test { | 43 class BluetoothSocketChromeOSTest : public testing::Test { |
44 public: | 44 public: |
45 BluetoothSocketChromeOSTest() | 45 BluetoothSocketChromeOSTest() |
46 : success_callback_count_(0), | 46 : success_callback_count_(0), |
47 error_callback_count_(0), | 47 error_callback_count_(0), |
48 last_bytes_sent_(0), | 48 last_bytes_sent_(0), |
49 last_bytes_received_(0), | 49 last_bytes_received_(0), |
50 last_reason_(BluetoothSocket::kSystemError) {} | 50 last_reason_(BluetoothSocket::kSystemError) {} |
51 | 51 |
52 virtual void SetUp() OVERRIDE { | 52 virtual void SetUp() OVERRIDE { |
53 scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager( | 53 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
54 new FakeDBusThreadManager); | 54 DBusThreadManager::GetSetterForTesting(); |
55 | 55 |
56 fake_dbus_thread_manager->SetBluetoothAdapterClient( | 56 dbus_setter->SetBluetoothAdapterClient( |
57 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); | 57 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); |
58 fake_dbus_thread_manager->SetBluetoothAgentManagerClient( | 58 dbus_setter->SetBluetoothAgentManagerClient( |
59 scoped_ptr<BluetoothAgentManagerClient>( | 59 scoped_ptr<BluetoothAgentManagerClient>( |
60 new FakeBluetoothAgentManagerClient)); | 60 new FakeBluetoothAgentManagerClient)); |
61 fake_dbus_thread_manager->SetBluetoothDeviceClient( | 61 dbus_setter->SetBluetoothDeviceClient( |
62 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); | 62 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); |
63 fake_dbus_thread_manager->SetBluetoothGattServiceClient( | 63 dbus_setter->SetBluetoothGattServiceClient( |
64 scoped_ptr<BluetoothGattServiceClient>( | 64 scoped_ptr<BluetoothGattServiceClient>( |
65 new FakeBluetoothGattServiceClient)); | 65 new FakeBluetoothGattServiceClient)); |
66 fake_dbus_thread_manager->SetBluetoothInputClient( | 66 dbus_setter->SetBluetoothInputClient( |
67 scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); | 67 scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); |
68 fake_dbus_thread_manager->SetBluetoothProfileManagerClient( | 68 dbus_setter->SetBluetoothProfileManagerClient( |
69 scoped_ptr<BluetoothProfileManagerClient>( | 69 scoped_ptr<BluetoothProfileManagerClient>( |
70 new FakeBluetoothProfileManagerClient)); | 70 new FakeBluetoothProfileManagerClient)); |
71 | 71 |
72 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager.release()); | |
73 BluetoothSocketThread::Get(); | 72 BluetoothSocketThread::Get(); |
74 | 73 |
75 // Grab a pointer to the adapter. | 74 // Grab a pointer to the adapter. |
76 device::BluetoothAdapterFactory::GetAdapter( | 75 device::BluetoothAdapterFactory::GetAdapter( |
77 base::Bind(&BluetoothSocketChromeOSTest::AdapterCallback, | 76 base::Bind(&BluetoothSocketChromeOSTest::AdapterCallback, |
78 base::Unretained(this))); | 77 base::Unretained(this))); |
79 ASSERT_TRUE(adapter_.get() != NULL); | 78 ASSERT_TRUE(adapter_.get() != NULL); |
80 ASSERT_TRUE(adapter_->IsInitialized()); | 79 ASSERT_TRUE(adapter_->IsInitialized()); |
81 ASSERT_TRUE(adapter_->IsPresent()); | 80 ASSERT_TRUE(adapter_->IsPresent()); |
82 | 81 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 503 |
505 // Cleanup the socket. | 504 // Cleanup the socket. |
506 socket->Disconnect( | 505 socket->Disconnect( |
507 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, | 506 base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, |
508 base::Unretained(this))); | 507 base::Unretained(this))); |
509 | 508 |
510 EXPECT_EQ(1U, success_callback_count_); | 509 EXPECT_EQ(1U, success_callback_count_); |
511 } | 510 } |
512 | 511 |
513 } // namespace chromeos | 512 } // namespace chromeos |
OLD | NEW |