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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 ASSERT_NE(adapter_.get(), nullptr); | 91 ASSERT_NE(adapter_.get(), nullptr); |
92 ASSERT_TRUE(adapter_->IsInitialized()); | 92 ASSERT_TRUE(adapter_->IsInitialized()); |
93 if (base::MessageLoop::current() && | 93 if (base::MessageLoop::current() && |
94 base::MessageLoop::current()->is_running()) { | 94 base::MessageLoop::current()->is_running()) { |
95 base::MessageLoop::current()->QuitWhenIdle(); | 95 base::MessageLoop::current()->QuitWhenIdle(); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 std::unique_ptr<BluetoothAdvertisement::Data> CreateAdvertisementData() { | 99 std::unique_ptr<BluetoothAdvertisement::Data> CreateAdvertisementData() { |
100 std::unique_ptr<BluetoothAdvertisement::Data> data = | 100 std::unique_ptr<BluetoothAdvertisement::Data> data = |
101 base::WrapUnique(new BluetoothAdvertisement::Data( | 101 base::MakeUnique<BluetoothAdvertisement::Data>( |
102 BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST)); | 102 BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); |
103 data->set_service_uuids( | 103 data->set_service_uuids( |
104 base::WrapUnique(new BluetoothAdvertisement::UUIDList())); | 104 base::MakeUnique<BluetoothAdvertisement::UUIDList>()); |
105 data->set_manufacturer_data( | 105 data->set_manufacturer_data( |
106 base::WrapUnique(new BluetoothAdvertisement::ManufacturerData())); | 106 base::MakeUnique<BluetoothAdvertisement::ManufacturerData>()); |
107 data->set_solicit_uuids( | 107 data->set_solicit_uuids( |
108 base::WrapUnique(new BluetoothAdvertisement::UUIDList())); | 108 base::MakeUnique<BluetoothAdvertisement::UUIDList>()); |
109 data->set_service_data( | 109 data->set_service_data( |
110 base::WrapUnique(new BluetoothAdvertisement::ServiceData())); | 110 base::MakeUnique<BluetoothAdvertisement::ServiceData>()); |
111 return data; | 111 return data; |
112 } | 112 } |
113 | 113 |
114 // Creates and registers an advertisement with the adapter. | 114 // Creates and registers an advertisement with the adapter. |
115 scoped_refptr<BluetoothAdvertisement> CreateAdvertisement() { | 115 scoped_refptr<BluetoothAdvertisement> CreateAdvertisement() { |
116 // Clear the last advertisement we created. | 116 // Clear the last advertisement we created. |
117 advertisement_ = nullptr; | 117 advertisement_ = nullptr; |
118 | 118 |
119 adapter_->RegisterAdvertisement( | 119 adapter_->RegisterAdvertisement( |
120 CreateAdvertisementData(), | 120 CreateAdvertisementData(), |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 TriggerReleased(advertisement); | 240 TriggerReleased(advertisement); |
241 EXPECT_TRUE(observer_->released()); | 241 EXPECT_TRUE(observer_->released()); |
242 | 242 |
243 // Unregistering an advertisement that has been released should give us an | 243 // Unregistering an advertisement that has been released should give us an |
244 // error. | 244 // error. |
245 UnregisterAdvertisement(advertisement); | 245 UnregisterAdvertisement(advertisement); |
246 ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); | 246 ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); |
247 } | 247 } |
248 | 248 |
249 } // namespace bluez | 249 } // namespace bluez |
OLD | NEW |