Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2606)

Unified Diff: device/bluetooth/bluetooth_chromeos_unittest.cc

Issue 848613003: bluetooth: Shutdown BluetoothAdapter before DBus on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: --set-upstream-to=origin/master Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_adapter_factory.cc ('k') | device/bluetooth/test/mock_bluetooth_adapter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_chromeos_unittest.cc
diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc
index 0c25a402f9dadcd5ac3170d8cd770c6ab57ecf1f..370b3b789dfc3a9443aa371979efb23556796b03 100644
--- a/device/bluetooth/bluetooth_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_chromeos_unittest.cc
@@ -3312,4 +3312,74 @@ TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) {
EXPECT_EQ(4, conn_info.max_transmit_power);
}
+// Verifies Shutdown shuts down the adapter as expected.
+TEST_F(BluetoothChromeOSTest, Shutdown) {
+ // Set up and adapter, power, discoverable, start discovery.
+ GetAdapter();
+ adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ adapter_->StartDiscoverySession(
+ base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ base::MessageLoop::current()->Run();
+ ASSERT_EQ(3, callback_count_);
+ ASSERT_EQ(0, error_callback_count_);
+ callback_count_ = 0;
+
+ // Validate running adapter state.
+ EXPECT_NE("", adapter_->GetAddress());
+ EXPECT_NE("", adapter_->GetName());
+ EXPECT_TRUE(adapter_->IsInitialized());
+ EXPECT_TRUE(adapter_->IsPresent());
+ EXPECT_TRUE(adapter_->IsPowered());
+ EXPECT_TRUE(adapter_->IsDiscoverable());
+ EXPECT_TRUE(adapter_->IsDiscovering());
+ EXPECT_EQ(1U, adapter_->GetDevices().size());
+ EXPECT_NE(nullptr, adapter_->GetDevice(
+ FakeBluetoothDeviceClient::kPairedDeviceAddress));
+ EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>(
+ adapter_.get())->object_path());
+
+ // Shutdown
+ static_cast<BluetoothAdapterChromeOS*>(adapter_.get())->Shutdown();
+
+ // Validate post shutdown state.
+ EXPECT_EQ("", adapter_->GetAddress());
+ EXPECT_EQ("", adapter_->GetName());
+ EXPECT_TRUE(adapter_->IsInitialized());
+ EXPECT_FALSE(adapter_->IsPresent());
+ EXPECT_FALSE(adapter_->IsPowered());
+ EXPECT_FALSE(adapter_->IsDiscoverable());
+ EXPECT_FALSE(adapter_->IsDiscovering());
+ EXPECT_EQ(0U, adapter_->GetDevices().size());
+ EXPECT_EQ(nullptr, adapter_->GetDevice(
+ FakeBluetoothDeviceClient::kPairedDeviceAddress));
+ EXPECT_EQ(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>(
+ adapter_.get())->object_path());
+
+ adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ adapter_->SetDiscoverable(true, base::Bind(&BluetoothChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ adapter_->StartDiscoverySession(
+ base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ ASSERT_EQ(0, callback_count_);
+ ASSERT_EQ(3, error_callback_count_);
+}
+
} // namespace chromeos
« no previous file with comments | « device/bluetooth/bluetooth_adapter_factory.cc ('k') | device/bluetooth/test/mock_bluetooth_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698