Chromium Code Reviews| 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 3294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3305 // Calling GetConnectionInfo for a connected device should return valid | 3305 // Calling GetConnectionInfo for a connected device should return valid |
| 3306 // results. | 3306 // results. |
| 3307 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); | 3307 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); |
| 3308 BluetoothDevice::ConnectionInfo conn_info; | 3308 BluetoothDevice::ConnectionInfo conn_info; |
| 3309 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | 3309 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); |
| 3310 EXPECT_EQ(-10, conn_info.rssi); | 3310 EXPECT_EQ(-10, conn_info.rssi); |
| 3311 EXPECT_EQ(3, conn_info.transmit_power); | 3311 EXPECT_EQ(3, conn_info.transmit_power); |
| 3312 EXPECT_EQ(4, conn_info.max_transmit_power); | 3312 EXPECT_EQ(4, conn_info.max_transmit_power); |
| 3313 } | 3313 } |
| 3314 | 3314 |
| 3315 // Verifies OnDBusThreadManagerShutdown shuts down the adapter as expected. | |
| 3316 TEST_F(BluetoothChromeOSTest, OnDBusThreadManagerShutdown) { | |
| 3317 // Set up and adapter, power, discoverable, start discovery. | |
| 3318 GetAdapter(); | |
| 3319 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, | |
| 3320 base::Unretained(this)), | |
| 3321 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | |
| 3322 base::Unretained(this))); | |
| 3323 adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback, | |
| 3324 base::Unretained(this)), | |
| 3325 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | |
| 3326 base::Unretained(this))); | |
| 3327 adapter_->StartDiscoverySession( | |
| 3328 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, | |
| 3329 base::Unretained(this)), | |
| 3330 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | |
| 3331 base::Unretained(this))); | |
| 3332 | |
| 3333 // Validate running adapter state. | |
| 3334 EXPECT_NE("", adapter_->GetAddress()); | |
| 3335 EXPECT_NE("", adapter_->GetName()); | |
| 3336 EXPECT_TRUE(adapter_->IsInitialized()); | |
| 3337 EXPECT_TRUE(adapter_->IsPresent()); | |
| 3338 EXPECT_TRUE(adapter_->IsPowered()); | |
| 3339 EXPECT_TRUE(adapter_->IsDiscoverable()); | |
| 3340 EXPECT_TRUE(adapter_->IsDiscovering()); | |
| 3341 EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( | |
| 3342 adapter_.get())->object_path()); | |
| 3343 | |
| 3344 // OnDBusThreadManagerShutdown | |
| 3345 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()) | |
| 3346 ->OnDBusThreadManagerShutdown(); | |
| 3347 | |
| 3348 // Validate post shutdown state. | |
| 3349 EXPECT_EQ("", adapter_->GetAddress()); | |
| 3350 EXPECT_EQ("", adapter_->GetName()); | |
| 3351 EXPECT_TRUE(adapter_->IsInitialized()); | |
| 3352 EXPECT_FALSE(adapter_->IsPresent()); | |
| 3353 EXPECT_FALSE(adapter_->IsPowered()); | |
| 3354 EXPECT_FALSE(adapter_->IsDiscoverable()); | |
| 3355 EXPECT_FALSE(adapter_->IsDiscovering()); | |
| 3356 EXPECT_EQ(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( | |
| 3357 adapter_.get())->object_path()); | |
|
armansito
2015/01/16 21:57:18
Probably also make a calls to the asynchronous met
scheib
2015/01/16 22:28:27
Done.
| |
| 3358 } | |
| 3359 | |
| 3315 } // namespace chromeos | 3360 } // namespace chromeos |
| OLD | NEW |