OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 6 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
7 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 7 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
8 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 8 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
9 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
10 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" |
11 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" | 11 #include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" |
12 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 12 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
13 #include "device/bluetooth/bluetooth_adapter.h" | 13 #include "device/bluetooth/bluetooth_adapter.h" |
14 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 14 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
15 #include "device/bluetooth/bluetooth_adapter_factory.h" | 15 #include "device/bluetooth/bluetooth_adapter_factory.h" |
16 #include "device/bluetooth/bluetooth_device.h" | 16 #include "device/bluetooth/bluetooth_device.h" |
17 #include "device/bluetooth/bluetooth_device_chromeos.h" | 17 #include "device/bluetooth/bluetooth_device_chromeos.h" |
18 #include "device/bluetooth/bluetooth_profile.h" | 18 #include "device/bluetooth/bluetooth_profile.h" |
19 #include "device/bluetooth/bluetooth_profile_chromeos.h" | 19 #include "device/bluetooth/bluetooth_profile_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_uuid.h" | |
23 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
25 | 24 |
26 using device::BluetoothAdapter; | 25 using device::BluetoothAdapter; |
27 using device::BluetoothDevice; | 26 using device::BluetoothDevice; |
28 using device::BluetoothProfile; | 27 using device::BluetoothProfile; |
29 using device::BluetoothSocket; | 28 using device::BluetoothSocket; |
30 using device::BluetoothUUID; | |
31 | 29 |
32 namespace chromeos { | 30 namespace chromeos { |
33 | 31 |
34 class BluetoothProfileChromeOSTest : public testing::Test { | 32 class BluetoothProfileChromeOSTest : public testing::Test { |
35 public: | 33 public: |
36 BluetoothProfileChromeOSTest() | 34 BluetoothProfileChromeOSTest() |
37 : callback_count_(0), | 35 : callback_count_(0), |
38 error_callback_count_(0), | 36 error_callback_count_(0), |
39 profile_callback_count_(0), | 37 profile_callback_count_(0), |
40 connection_callback_count_(0), | 38 connection_callback_count_(0), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 BluetoothProfile* last_profile_; | 117 BluetoothProfile* last_profile_; |
120 const BluetoothDevice* last_device_; | 118 const BluetoothDevice* last_device_; |
121 scoped_refptr<BluetoothSocket> last_socket_; | 119 scoped_refptr<BluetoothSocket> last_socket_; |
122 }; | 120 }; |
123 | 121 |
124 TEST_F(BluetoothProfileChromeOSTest, L2capEndToEnd) { | 122 TEST_F(BluetoothProfileChromeOSTest, L2capEndToEnd) { |
125 // Register the profile and expect the profile object to be passed to the | 123 // Register the profile and expect the profile object to be passed to the |
126 // callback. | 124 // callback. |
127 BluetoothProfile::Options options; | 125 BluetoothProfile::Options options; |
128 BluetoothProfile::Register( | 126 BluetoothProfile::Register( |
129 BluetoothUUID(FakeBluetoothProfileManagerClient::kL2capUuid), | 127 FakeBluetoothProfileManagerClient::kL2capUuid, |
130 options, | 128 options, |
131 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback, | 129 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback, |
132 base::Unretained(this))); | 130 base::Unretained(this))); |
133 | 131 |
134 EXPECT_EQ(1U, profile_callback_count_); | 132 EXPECT_EQ(1U, profile_callback_count_); |
135 EXPECT_TRUE(last_profile_ != NULL); | 133 EXPECT_TRUE(last_profile_ != NULL); |
136 BluetoothProfile* profile = last_profile_; | 134 BluetoothProfile* profile = last_profile_; |
137 | 135 |
138 // Make sure we have a profile service provider for it. | 136 // Make sure we have a profile service provider for it. |
139 FakeBluetoothProfileServiceProvider* profile_service_provider = | 137 FakeBluetoothProfileServiceProvider* profile_service_provider = |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( | 243 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( |
246 FakeBluetoothProfileManagerClient::kL2capUuid); | 244 FakeBluetoothProfileManagerClient::kL2capUuid); |
247 EXPECT_TRUE(profile_service_provider == NULL); | 245 EXPECT_TRUE(profile_service_provider == NULL); |
248 } | 246 } |
249 | 247 |
250 TEST_F(BluetoothProfileChromeOSTest, RfcommEndToEnd) { | 248 TEST_F(BluetoothProfileChromeOSTest, RfcommEndToEnd) { |
251 // Register the profile and expect the profile object to be passed to the | 249 // Register the profile and expect the profile object to be passed to the |
252 // callback. | 250 // callback. |
253 BluetoothProfile::Options options; | 251 BluetoothProfile::Options options; |
254 BluetoothProfile::Register( | 252 BluetoothProfile::Register( |
255 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), | 253 FakeBluetoothProfileManagerClient::kRfcommUuid, |
256 options, | 254 options, |
257 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback, | 255 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback, |
258 base::Unretained(this))); | 256 base::Unretained(this))); |
259 | 257 |
260 EXPECT_EQ(1U, profile_callback_count_); | 258 EXPECT_EQ(1U, profile_callback_count_); |
261 EXPECT_TRUE(last_profile_ != NULL); | 259 EXPECT_TRUE(last_profile_ != NULL); |
262 BluetoothProfile* profile = last_profile_; | 260 BluetoothProfile* profile = last_profile_; |
263 | 261 |
264 // Make sure we have a profile service provider for it. | 262 // Make sure we have a profile service provider for it. |
265 FakeBluetoothProfileServiceProvider* profile_service_provider = | 263 FakeBluetoothProfileServiceProvider* profile_service_provider = |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // Unregister the profile, make sure it's no longer registered. | 363 // Unregister the profile, make sure it's no longer registered. |
366 last_profile_->Unregister(); | 364 last_profile_->Unregister(); |
367 | 365 |
368 profile_service_provider = | 366 profile_service_provider = |
369 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( | 367 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( |
370 FakeBluetoothProfileManagerClient::kRfcommUuid); | 368 FakeBluetoothProfileManagerClient::kRfcommUuid); |
371 EXPECT_TRUE(profile_service_provider == NULL); | 369 EXPECT_TRUE(profile_service_provider == NULL); |
372 } | 370 } |
373 | 371 |
374 } // namespace chromeos | 372 } // namespace chromeos |
OLD | NEW |