| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Clear the last advertisement we created. | 117 // Clear the last advertisement we created. |
| 118 advertisement_ = nullptr; | 118 advertisement_ = nullptr; |
| 119 | 119 |
| 120 adapter_->RegisterAdvertisement( | 120 adapter_->RegisterAdvertisement( |
| 121 CreateAdvertisementData(), | 121 CreateAdvertisementData(), |
| 122 base::Bind(&BluetoothAdvertisementBlueZTest::RegisterCallback, | 122 base::Bind(&BluetoothAdvertisementBlueZTest::RegisterCallback, |
| 123 base::Unretained(this)), | 123 base::Unretained(this)), |
| 124 base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback, | 124 base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback, |
| 125 base::Unretained(this))); | 125 base::Unretained(this))); |
| 126 | 126 |
| 127 message_loop_.RunUntilIdle(); | 127 base::RunLoop().RunUntilIdle(); |
| 128 return advertisement_; | 128 return advertisement_; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void UnregisterAdvertisement( | 131 void UnregisterAdvertisement( |
| 132 scoped_refptr<BluetoothAdvertisement> advertisement) { | 132 scoped_refptr<BluetoothAdvertisement> advertisement) { |
| 133 advertisement->Unregister( | 133 advertisement->Unregister( |
| 134 base::Bind(&BluetoothAdvertisementBlueZTest::Callback, | 134 base::Bind(&BluetoothAdvertisementBlueZTest::Callback, |
| 135 base::Unretained(this)), | 135 base::Unretained(this)), |
| 136 base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback, | 136 base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback, |
| 137 base::Unretained(this))); | 137 base::Unretained(this))); |
| 138 | 138 |
| 139 message_loop_.RunUntilIdle(); | 139 base::RunLoop().RunUntilIdle(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void TriggerReleased(scoped_refptr<BluetoothAdvertisement> advertisement) { | 142 void TriggerReleased(scoped_refptr<BluetoothAdvertisement> advertisement) { |
| 143 BluetoothAdvertisementBlueZ* adv = | 143 BluetoothAdvertisementBlueZ* adv = |
| 144 static_cast<BluetoothAdvertisementBlueZ*>(advertisement.get()); | 144 static_cast<BluetoothAdvertisementBlueZ*>(advertisement.get()); |
| 145 bluez::FakeBluetoothLEAdvertisementServiceProvider* provider = | 145 bluez::FakeBluetoothLEAdvertisementServiceProvider* provider = |
| 146 static_cast<bluez::FakeBluetoothLEAdvertisementServiceProvider*>( | 146 static_cast<bluez::FakeBluetoothLEAdvertisementServiceProvider*>( |
| 147 adv->provider()); | 147 adv->provider()); |
| 148 provider->Release(); | 148 provider->Release(); |
| 149 } | 149 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 TriggerReleased(advertisement); | 241 TriggerReleased(advertisement); |
| 242 EXPECT_TRUE(observer_->released()); | 242 EXPECT_TRUE(observer_->released()); |
| 243 | 243 |
| 244 // Unregistering an advertisement that has been released should give us an | 244 // Unregistering an advertisement that has been released should give us an |
| 245 // error. | 245 // error. |
| 246 UnregisterAdvertisement(advertisement); | 246 UnregisterAdvertisement(advertisement); |
| 247 ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); | 247 ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); |
| 248 } | 248 } |
| 249 | 249 |
| 250 } // namespace bluez | 250 } // namespace bluez |
| OLD | NEW |