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/dbus_thread_manager.h" |
9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
(...skipping 3300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3311 // Calling GetConnectionInfo for a connected device should return valid | 3311 // Calling GetConnectionInfo for a connected device should return valid |
3312 // results. | 3312 // results. |
3313 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); | 3313 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); |
3314 BluetoothDevice::ConnectionInfo conn_info; | 3314 BluetoothDevice::ConnectionInfo conn_info; |
3315 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | 3315 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); |
3316 EXPECT_EQ(-10, conn_info.rssi); | 3316 EXPECT_EQ(-10, conn_info.rssi); |
3317 EXPECT_EQ(3, conn_info.transmit_power); | 3317 EXPECT_EQ(3, conn_info.transmit_power); |
3318 EXPECT_EQ(4, conn_info.max_transmit_power); | 3318 EXPECT_EQ(4, conn_info.max_transmit_power); |
3319 } | 3319 } |
3320 | 3320 |
| 3321 // Verifies OnDBusThreadManagerShutdown shuts down the adapter as expected. |
| 3322 TEST_F(BluetoothChromeOSTest, OnDBusThreadManagerShutdown) { |
| 3323 // Set up and adapter, power, discoverable, start discovery. |
| 3324 GetAdapter(); |
| 3325 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, |
| 3326 base::Unretained(this)), |
| 3327 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 3328 base::Unretained(this))); |
| 3329 adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback, |
| 3330 base::Unretained(this)), |
| 3331 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 3332 base::Unretained(this))); |
| 3333 adapter_->StartDiscoverySession( |
| 3334 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, |
| 3335 base::Unretained(this)), |
| 3336 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 3337 base::Unretained(this))); |
| 3338 |
| 3339 // Validate running adapter state. |
| 3340 EXPECT_NE("", adapter_->GetAddress()); |
| 3341 EXPECT_NE("", adapter_->GetName()); |
| 3342 EXPECT_TRUE(adapter_->IsInitialized()); |
| 3343 EXPECT_TRUE(adapter_->IsPresent()); |
| 3344 EXPECT_TRUE(adapter_->IsPowered()); |
| 3345 EXPECT_TRUE(adapter_->IsDiscoverable()); |
| 3346 EXPECT_TRUE(adapter_->IsDiscovering()); |
| 3347 EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( |
| 3348 adapter_.get())->object_path()); |
| 3349 |
| 3350 // OnDBusThreadManagerShutdown |
| 3351 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()) |
| 3352 ->OnDBusThreadManagerShutdown(); |
| 3353 |
| 3354 // Validate post shutdown state. |
| 3355 EXPECT_EQ("", adapter_->GetAddress()); |
| 3356 EXPECT_EQ("", adapter_->GetName()); |
| 3357 EXPECT_TRUE(adapter_->IsInitialized()); |
| 3358 EXPECT_FALSE(adapter_->IsPresent()); |
| 3359 EXPECT_FALSE(adapter_->IsPowered()); |
| 3360 EXPECT_FALSE(adapter_->IsDiscoverable()); |
| 3361 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 3362 EXPECT_EQ(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( |
| 3363 adapter_.get())->object_path()); |
| 3364 } |
| 3365 |
3321 } // namespace chromeos | 3366 } // namespace chromeos |
OLD | NEW |