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

Side by Side Diff: device/bluetooth/bluez/bluetooth_bluez_unittest.cc

Issue 2792203003: Revert of Bluetooth: Add service data unit tests for chromeos (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 4464 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 } 4475 }
4476 adapter_->Shutdown(); 4476 adapter_->Shutdown();
4477 adapter_bluez->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); 4477 adapter_bluez->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", "");
4478 4478
4479 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, 4479 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError,
4480 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. 4480 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession.
4481 EXPECT_EQ(0, callback_count_); 4481 EXPECT_EQ(0, callback_count_);
4482 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); 4482 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_);
4483 } 4483 }
4484 4484
4485 TEST_F(BluetoothBlueZTest, ServiceDataChanged) {
4486 // Simulate a change of service data of a device.
4487 GetAdapter();
4488
4489 BluetoothDevice* device = adapter_->GetDevice(
4490 bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress);
4491
4492 // Install an observer; expect the DeviceChanged method to be called
4493 // when we change the service data.
4494 TestBluetoothAdapterObserver observer(adapter_);
4495
4496 bluez::FakeBluetoothDeviceClient::Properties* properties =
4497 fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(
4498 bluez::FakeBluetoothDeviceClient::kPairedDevicePath));
4499
4500 properties->service_data.set_valid(true);
4501
4502 // Check that ServiceDataChanged is correctly invoke.
4503 properties->service_data.ReplaceValue({{kGapUuid, {1, 2, 3}}});
4504 EXPECT_EQ(1, observer.device_changed_count());
4505 EXPECT_EQ(device, observer.last_device());
4506 EXPECT_EQ(
4507 BluetoothDevice::ServiceDataMap({{BluetoothUUID(kGapUuid), {1, 2, 3}}}),
4508 device->GetServiceData());
4509 EXPECT_EQ(BluetoothDevice::UUIDSet({BluetoothUUID(kGapUuid)}),
4510 device->GetServiceDataUUIDs());
4511 EXPECT_EQ(std::vector<uint8_t>({1, 2, 3}),
4512 *(device->GetServiceDataForUUID(BluetoothUUID(kGapUuid))));
4513
4514 // Check that we can update service data with same uuid / add more uuid.
4515 properties->service_data.ReplaceValue(
4516 {{kGapUuid, {3, 2, 1}}, {kGattUuid, {1}}});
4517 EXPECT_EQ(2, observer.device_changed_count());
4518 EXPECT_EQ(device, observer.last_device());
4519
4520 EXPECT_EQ(
4521 BluetoothDevice::ServiceDataMap({{BluetoothUUID(kGapUuid), {3, 2, 1}},
4522 {BluetoothUUID(kGattUuid), {1}}}),
4523 device->GetServiceData());
4524 EXPECT_EQ(BluetoothDevice::UUIDSet(
4525 {BluetoothUUID(kGapUuid), BluetoothUUID(kGattUuid)}),
4526 device->GetServiceDataUUIDs());
4527 EXPECT_EQ(std::vector<uint8_t>({3, 2, 1}),
4528 *(device->GetServiceDataForUUID(BluetoothUUID(kGapUuid))));
4529 EXPECT_EQ(std::vector<uint8_t>({1}),
4530 *(device->GetServiceDataForUUID(BluetoothUUID(kGattUuid))));
4531
4532 // Check that we can remove uuid / change uuid with same data.
4533 properties->service_data.ReplaceValue({{kPnpUuid, {3, 2, 1}}});
4534 EXPECT_EQ(3, observer.device_changed_count());
4535 EXPECT_EQ(device, observer.last_device());
4536
4537 EXPECT_EQ(
4538 BluetoothDevice::ServiceDataMap({{BluetoothUUID(kPnpUuid), {3, 2, 1}}}),
4539 device->GetServiceData());
4540 EXPECT_EQ(BluetoothDevice::UUIDSet({BluetoothUUID(kPnpUuid)}),
4541 device->GetServiceDataUUIDs());
4542 EXPECT_EQ(std::vector<uint8_t>({3, 2, 1}),
4543 *(device->GetServiceDataForUUID(BluetoothUUID(kPnpUuid))));
4544 EXPECT_EQ(nullptr, device->GetServiceDataForUUID(BluetoothUUID(kGapUuid)));
4545 EXPECT_EQ(nullptr, device->GetServiceDataForUUID(BluetoothUUID(kGattUuid)));
4546 }
4547
4485 TEST_F(BluetoothBlueZTest, ManufacturerDataChanged) { 4548 TEST_F(BluetoothBlueZTest, ManufacturerDataChanged) {
4486 const BluetoothDevice::ManufacturerId kManufacturerId1 = 0x1234; 4549 const BluetoothDevice::ManufacturerId kManufacturerId1 = 0x1234;
4487 const BluetoothDevice::ManufacturerId kManufacturerId2 = 0x2345; 4550 const BluetoothDevice::ManufacturerId kManufacturerId2 = 0x2345;
4488 const BluetoothDevice::ManufacturerId kManufacturerId3 = 0x3456; 4551 const BluetoothDevice::ManufacturerId kManufacturerId3 = 0x3456;
4489 4552
4490 // Simulate a change of manufacturer data of a device. 4553 // Simulate a change of manufacturer data of a device.
4491 GetAdapter(); 4554 GetAdapter();
4492 4555
4493 BluetoothDevice* device = adapter_->GetDevice( 4556 BluetoothDevice* device = adapter_->GetDevice(
4494 bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); 4557 bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
4574 4637
4575 // Check that we can update advertising data flags. 4638 // Check that we can update advertising data flags.
4576 properties->advertising_data_flags.ReplaceValue(std::vector<uint8_t>({0x23})); 4639 properties->advertising_data_flags.ReplaceValue(std::vector<uint8_t>({0x23}));
4577 EXPECT_EQ(2, observer.device_changed_count()); 4640 EXPECT_EQ(2, observer.device_changed_count());
4578 EXPECT_EQ(device, observer.last_device()); 4641 EXPECT_EQ(device, observer.last_device());
4579 EXPECT_TRUE(device->GetAdvertisingDataFlags().has_value()); 4642 EXPECT_TRUE(device->GetAdvertisingDataFlags().has_value());
4580 EXPECT_EQ(0x23u, device->GetAdvertisingDataFlags().value()); 4643 EXPECT_EQ(0x23u, device->GetAdvertisingDataFlags().value());
4581 } 4644 }
4582 4645
4583 } // namespace bluez 4646 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_unittest.cc ('k') | device/bluetooth/dbus/fake_bluetooth_device_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698