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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc

Issue 2511253002: arc: bluetooth: enable use_new_wrapper_types for bluetooth.mojom (Closed)
Patch Set: Rebase again Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/arc/bluetooth/arc_bluetooth_bridge.h" 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 base::RunLoop get_adapter_run_loop_; 174 base::RunLoop get_adapter_run_loop_;
175 }; 175 };
176 176
177 // When we add device to bluez::FakeBluetoothDeviceClient, ArcBluetoothBridge 177 // When we add device to bluez::FakeBluetoothDeviceClient, ArcBluetoothBridge
178 // should send new device data to Android. This test will then check 178 // should send new device data to Android. This test will then check
179 // the correctness of the device properties sent via arc bridge. 179 // the correctness of the device properties sent via arc bridge.
180 TEST_F(ArcBluetoothBridgeTest, DeviceFound) { 180 TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
181 EXPECT_EQ(0u, fake_bluetooth_instance_->device_found_data().size()); 181 EXPECT_EQ(0u, fake_bluetooth_instance_->device_found_data().size());
182 AddTestDevice(); 182 AddTestDevice();
183 EXPECT_EQ(2u, fake_bluetooth_instance_->device_found_data().size()); 183 EXPECT_EQ(2u, fake_bluetooth_instance_->device_found_data().size());
184 const mojo::Array<mojom::BluetoothPropertyPtr>& prop = 184 const std::vector<mojom::BluetoothPropertyPtr>& prop =
185 fake_bluetooth_instance_->device_found_data().back(); 185 fake_bluetooth_instance_->device_found_data().back();
186 186
187 EXPECT_EQ(7u, prop.size()); 187 EXPECT_EQ(7u, prop.size());
188 EXPECT_TRUE(prop[0]->is_bdname()); 188 EXPECT_TRUE(prop[0]->is_bdname());
189 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName), 189 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName),
190 prop[0]->get_bdname()); 190 prop[0]->get_bdname());
191 EXPECT_TRUE(prop[1]->is_bdaddr()); 191 EXPECT_TRUE(prop[1]->is_bdaddr());
192 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress), 192 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress),
193 prop[1]->get_bdaddr()->To<std::string>()); 193 prop[1]->get_bdaddr()->To<std::string>());
194 EXPECT_TRUE(prop[2]->is_uuids()); 194 EXPECT_TRUE(prop[2]->is_uuids());
195 EXPECT_EQ(1u, prop[2]->get_uuids().size()); 195 EXPECT_EQ(1u, prop[2]->get_uuids().size());
196 EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID, 196 EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID,
197 prop[2]->get_uuids()[0].value()); 197 prop[2]->get_uuids()[0].value());
198 EXPECT_TRUE(prop[3]->is_device_class()); 198 EXPECT_TRUE(prop[3]->is_device_class());
199 EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyClass, 199 EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyClass,
200 prop[3]->get_device_class()); 200 prop[3]->get_device_class());
201 EXPECT_TRUE(prop[4]->is_device_type()); 201 EXPECT_TRUE(prop[4]->is_device_type());
202 // bluez::FakeBluetoothDeviceClient does not return proper device type. 202 // bluez::FakeBluetoothDeviceClient does not return proper device type.
203 EXPECT_TRUE(prop[5]->is_remote_friendly_name()); 203 EXPECT_TRUE(prop[5]->is_remote_friendly_name());
204 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName), 204 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName),
205 prop[5]->get_remote_friendly_name()); 205 prop[5]->get_remote_friendly_name());
206 EXPECT_TRUE(prop[6]->is_remote_rssi()); 206 EXPECT_TRUE(prop[6]->is_remote_rssi());
207 EXPECT_EQ(kTestRssi, prop[6]->get_remote_rssi()); 207 EXPECT_EQ(kTestRssi, prop[6]->get_remote_rssi());
208 208
209 ChangeTestDeviceRssi(kTestRssi2); 209 ChangeTestDeviceRssi(kTestRssi2);
210 EXPECT_EQ(3u, fake_bluetooth_instance_->device_found_data().size()); 210 EXPECT_EQ(3u, fake_bluetooth_instance_->device_found_data().size());
211 const mojo::Array<mojom::BluetoothPropertyPtr>& prop2 = 211 const std::vector<mojom::BluetoothPropertyPtr>& prop2 =
212 fake_bluetooth_instance_->device_found_data().back(); 212 fake_bluetooth_instance_->device_found_data().back();
213 EXPECT_EQ(7u, prop2.size()); 213 EXPECT_EQ(7u, prop2.size());
214 EXPECT_TRUE(prop2[6]->is_remote_rssi()); 214 EXPECT_TRUE(prop2[6]->is_remote_rssi());
215 EXPECT_EQ(kTestRssi2, prop2[6]->get_remote_rssi()); 215 EXPECT_EQ(kTestRssi2, prop2[6]->get_remote_rssi());
216 } 216 }
217 217
218 // Invoke OnDiscoveryStarted to send cached device to BT instance, 218 // Invoke OnDiscoveryStarted to send cached device to BT instance,
219 // and check correctness of the Advertising data sent via arc bridge. 219 // and check correctness of the Advertising data sent via arc bridge.
220 TEST_F(ArcBluetoothBridgeTest, LEDeviceFound) { 220 TEST_F(ArcBluetoothBridgeTest, LEDeviceFound) {
221 EXPECT_EQ(0u, fake_bluetooth_instance_->le_device_found_data().size()); 221 EXPECT_EQ(0u, fake_bluetooth_instance_->le_device_found_data().size());
222 AddTestDevice(); 222 AddTestDevice();
223 EXPECT_EQ(1u, fake_bluetooth_instance_->le_device_found_data().size()); 223 EXPECT_EQ(1u, fake_bluetooth_instance_->le_device_found_data().size());
224 224
225 const auto& le_device_found_data = 225 const auto& le_device_found_data =
226 fake_bluetooth_instance_->le_device_found_data().back(); 226 fake_bluetooth_instance_->le_device_found_data().back();
227 const mojom::BluetoothAddressPtr& addr = le_device_found_data->addr(); 227 const mojom::BluetoothAddressPtr& addr = le_device_found_data->addr();
228 const mojo::Array<mojom::BluetoothAdvertisingDataPtr>& adv_data = 228 const std::vector<mojom::BluetoothAdvertisingDataPtr>& adv_data =
229 le_device_found_data->adv_data(); 229 le_device_found_data->adv_data();
230 230
231 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress), 231 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress),
232 addr->To<std::string>()); 232 addr->To<std::string>());
233 EXPECT_EQ(2u, adv_data.size()); 233 EXPECT_EQ(2u, adv_data.size());
234 234
235 EXPECT_TRUE(adv_data[0]->is_local_name()); 235 EXPECT_TRUE(adv_data[0]->is_local_name());
236 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName), 236 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName),
237 adv_data[0]->get_local_name().To<std::string>()); 237 adv_data[0]->get_local_name());
238 238
239 EXPECT_TRUE(adv_data[1]->is_service_uuids()); 239 EXPECT_TRUE(adv_data[1]->is_service_uuids());
240 EXPECT_EQ(1u, adv_data[1]->get_service_uuids().size()); 240 EXPECT_EQ(1u, adv_data[1]->get_service_uuids().size());
241 EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID, 241 EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID,
242 adv_data[1]->get_service_uuids()[0].canonical_value()); 242 adv_data[1]->get_service_uuids()[0].canonical_value());
243 243
244 EXPECT_EQ(kTestRssi, le_device_found_data->rssi()); 244 EXPECT_EQ(kTestRssi, le_device_found_data->rssi());
245 245
246 ChangeTestDeviceRssi(kTestRssi2); 246 ChangeTestDeviceRssi(kTestRssi2);
247 EXPECT_EQ(2u, fake_bluetooth_instance_->le_device_found_data().size()); 247 EXPECT_EQ(2u, fake_bluetooth_instance_->le_device_found_data().size());
(...skipping 13 matching lines...) Expand all
261 fake_bluetooth_instance_->gatt_db_result().back()->remote_addr(); 261 fake_bluetooth_instance_->gatt_db_result().back()->remote_addr();
262 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress), 262 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress),
263 addr->To<std::string>()); 263 addr->To<std::string>());
264 264
265 // HeartRateService in bluez::FakeBluetoothDeviceClient consists of 265 // HeartRateService in bluez::FakeBluetoothDeviceClient consists of
266 // Service: HeartRateService 266 // Service: HeartRateService
267 // Characteristic: HeartRateMeasurement 267 // Characteristic: HeartRateMeasurement
268 // Descriptor: ClientCharacteristicConfiguration 268 // Descriptor: ClientCharacteristicConfiguration
269 // Characteristic: BodySensorLocation 269 // Characteristic: BodySensorLocation
270 // Characteristic: HeartRateControlPoint 270 // Characteristic: HeartRateControlPoint
271 const mojo::Array<mojom::BluetoothGattDBElementPtr>& db = 271 const std::vector<mojom::BluetoothGattDBElementPtr>& db =
272 fake_bluetooth_instance_->gatt_db_result().back()->db(); 272 fake_bluetooth_instance_->gatt_db_result().back()->db();
273 EXPECT_EQ(5u, db.size()); 273 EXPECT_EQ(5u, db.size());
274 274
275 EXPECT_EQ(device::BluetoothUUID( 275 EXPECT_EQ(device::BluetoothUUID(
276 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), 276 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
277 db[0]->uuid); 277 db[0]->uuid);
278 EXPECT_EQ(mojom::BluetoothGattDBAttributeType::BTGATT_DB_PRIMARY_SERVICE, 278 EXPECT_EQ(mojom::BluetoothGattDBAttributeType::BTGATT_DB_PRIMARY_SERVICE,
279 db[0]->type); 279 db[0]->type);
280 280
281 EXPECT_EQ(device::BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: 281 EXPECT_EQ(device::BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient::
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 BroadcastAdvertisement(handle, std::move(adv_data)); 322 BroadcastAdvertisement(handle, std::move(adv_data));
323 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status); 323 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
324 EXPECT_EQ(1, NumActiveAdvertisements()); 324 EXPECT_EQ(1, NumActiveAdvertisements());
325 325
326 status = ReleaseAdvertisementHandle(handle); 326 status = ReleaseAdvertisementHandle(handle);
327 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status); 327 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
328 EXPECT_EQ(0, NumActiveAdvertisements()); 328 EXPECT_EQ(0, NumActiveAdvertisements());
329 } 329 }
330 330
331 } // namespace arc 331 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.cc ('k') | components/arc/bluetooth/bluetooth_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698