| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/bluetooth/bluez/bluetooth_advertisement_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_advertisement_bluez.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 ExpectSuccess(); | 272 ExpectSuccess(); |
| 273 EXPECT_TRUE(advertisement); | 273 EXPECT_TRUE(advertisement); |
| 274 | 274 |
| 275 // Shutdown the default adapter. | 275 // Shutdown the default adapter. |
| 276 BluetoothAdapterFactory::Shutdown(); | 276 BluetoothAdapterFactory::Shutdown(); |
| 277 | 277 |
| 278 UnregisterAdvertisement(advertisement); | 278 UnregisterAdvertisement(advertisement); |
| 279 ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); | 279 ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); |
| 280 } | 280 } |
| 281 | 281 |
| 282 TEST_F(BluetoothAdvertisementBlueZTest, ResetAdvertising) { |
| 283 bluez::FakeBluetoothLEAdvertisingManagerClient* adv_client = |
| 284 static_cast<bluez::FakeBluetoothLEAdvertisingManagerClient*>( |
| 285 bluez::BluezDBusManager::Get() |
| 286 ->GetBluetoothLEAdvertisingManagerClient()); |
| 287 |
| 288 // Creates and registers multiple advertisements. |
| 289 scoped_refptr<BluetoothAdvertisement> advertisement1 = CreateAdvertisement(); |
| 290 ExpectSuccess(); |
| 291 EXPECT_TRUE(advertisement1); |
| 292 scoped_refptr<BluetoothAdvertisement> advertisement2 = CreateAdvertisement(); |
| 293 ExpectSuccess(); |
| 294 EXPECT_TRUE(advertisement2); |
| 295 // There should be 2 currently registered advertisements. |
| 296 EXPECT_EQ(2, adv_client->currently_registered()); |
| 297 |
| 298 adapter_->ResetAdvertising( |
| 299 base::Bind(&BluetoothAdvertisementBlueZTest::Callback, |
| 300 base::Unretained(this)), |
| 301 base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback, |
| 302 base::Unretained(this))); |
| 303 ExpectSuccess(); |
| 304 |
| 305 // Checks that the advertisements have been cleared after ResetAdvertising. |
| 306 EXPECT_EQ(0, adv_client->currently_registered()); |
| 307 } |
| 308 |
| 282 } // namespace bluez | 309 } // namespace bluez |
| OLD | NEW |