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

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: MockBluetoothAdapter::OnDBusThreadManagerShutdown (and a rebase) 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
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..c4744216038f14aa246b97a28bd109382c2b84ab 100644
--- a/device/bluetooth/bluetooth_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_chromeos_unittest.cc
@@ -3312,4 +3312,49 @@ TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) {
EXPECT_EQ(4, conn_info.max_transmit_power);
}
+// Verifies OnDBusThreadManagerShutdown shuts down the adapter as expected.
+TEST_F(BluetoothChromeOSTest, OnDBusThreadManagerShutdown) {
+ // 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)));
+
+ // 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_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>(
+ adapter_.get())->object_path());
+
+ // OnDBusThreadManagerShutdown
+ static_cast<BluetoothAdapterChromeOS*>(adapter_.get())
+ ->OnDBusThreadManagerShutdown();
+
+ // 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(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>(
+ 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.
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698