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

Unified Diff: device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc

Issue 2861533004: Implement chrome.bluetoothLowEnergy.resetAdvertising(). (Closed)
Patch Set: Implement chrome.bluetoothLowEnergy.resetAllAdvertisements(). Created 3 years, 6 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/bluez/bluetooth_advertisement_bluez_unittest.cc
diff --git a/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc b/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc
index 3c7addf719a9a2030df75396cdb5a80e1cd9e66d..170c80636797b6799f26b8e6249e23be82aecbc3 100644
--- a/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc
+++ b/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc
@@ -279,4 +279,31 @@ TEST_F(BluetoothAdvertisementBlueZTest, UnregisterAfterAdapterShutdown) {
ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST);
}
+TEST_F(BluetoothAdvertisementBlueZTest, ResetAdvertising) {
+ bluez::FakeBluetoothLEAdvertisingManagerClient* adv_client =
+ static_cast<bluez::FakeBluetoothLEAdvertisingManagerClient*>(
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothLEAdvertisingManagerClient());
+
+ // Creates and registers multiple advertisements.
+ scoped_refptr<BluetoothAdvertisement> advertisement1 = CreateAdvertisement();
+ ExpectSuccess();
+ EXPECT_TRUE(advertisement1);
+ scoped_refptr<BluetoothAdvertisement> advertisement2 = CreateAdvertisement();
+ ExpectSuccess();
+ EXPECT_TRUE(advertisement2);
+ // There should be 2 currently registered advertisements.
+ EXPECT_EQ(2, adv_client->currently_registered());
+
+ adapter_->ResetAdvertising(
+ base::Bind(&BluetoothAdvertisementBlueZTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback,
+ base::Unretained(this)));
+ ExpectSuccess();
+
+ // Checks that the advertisements have been cleared after ResetAdvertising.
+ EXPECT_EQ(0, adv_client->currently_registered());
+}
+
} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698