| OLD | NEW | 
|---|
| 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 4558 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4569   EXPECT_EQ(0x12u, device->GetAdvertisingDataFlags().value()); | 4569   EXPECT_EQ(0x12u, device->GetAdvertisingDataFlags().value()); | 
| 4570 | 4570 | 
| 4571   // Check that we can update advertising data flags. | 4571   // Check that we can update advertising data flags. | 
| 4572   properties->advertising_data_flags.ReplaceValue(std::vector<uint8_t>({0x23})); | 4572   properties->advertising_data_flags.ReplaceValue(std::vector<uint8_t>({0x23})); | 
| 4573   EXPECT_EQ(2, observer.device_changed_count()); | 4573   EXPECT_EQ(2, observer.device_changed_count()); | 
| 4574   EXPECT_EQ(device, observer.last_device()); | 4574   EXPECT_EQ(device, observer.last_device()); | 
| 4575   EXPECT_TRUE(device->GetAdvertisingDataFlags().has_value()); | 4575   EXPECT_TRUE(device->GetAdvertisingDataFlags().has_value()); | 
| 4576   EXPECT_EQ(0x23u, device->GetAdvertisingDataFlags().value()); | 4576   EXPECT_EQ(0x23u, device->GetAdvertisingDataFlags().value()); | 
| 4577 } | 4577 } | 
| 4578 | 4578 | 
|  | 4579 TEST_F(BluetoothBlueZTest, SetConnectionLatency) { | 
|  | 4580   GetAdapter(); | 
|  | 4581   DiscoverDevices(); | 
|  | 4582 | 
|  | 4583   // SetConnectionLatency is supported on LE devices. | 
|  | 4584   bluez::FakeBluetoothDeviceClient::Properties* properties = | 
|  | 4585       fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( | 
|  | 4586           bluez::FakeBluetoothDeviceClient::kConnectUnpairablePath)); | 
|  | 4587   properties->type.ReplaceValue(BluetoothDeviceClient::kTypeLe); | 
|  | 4588   BluetoothDevice* device = adapter_->GetDevice( | 
|  | 4589       bluez::FakeBluetoothDeviceClient::kConnectUnpairableAddress); | 
|  | 4590   ASSERT_TRUE(device); | 
|  | 4591 | 
|  | 4592   device->SetConnectionLatency( | 
|  | 4593       BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_LOW, GetCallback(), | 
|  | 4594       GetErrorCallback()); | 
|  | 4595   EXPECT_EQ(1, callback_count_); | 
|  | 4596   EXPECT_EQ(0, error_callback_count_); | 
|  | 4597 | 
|  | 4598   device->SetConnectionLatency( | 
|  | 4599       BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_HIGH, | 
|  | 4600       GetCallback(), GetErrorCallback()); | 
|  | 4601   EXPECT_EQ(2, callback_count_); | 
|  | 4602   EXPECT_EQ(0, error_callback_count_); | 
|  | 4603 | 
|  | 4604   // Dual mode devices should be supported as well. | 
|  | 4605   properties->type.ReplaceValue(BluetoothDeviceClient::kTypeDual); | 
|  | 4606   device->SetConnectionLatency( | 
|  | 4607       BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_MEDIUM, | 
|  | 4608       GetCallback(), GetErrorCallback()); | 
|  | 4609   EXPECT_EQ(3, callback_count_); | 
|  | 4610   EXPECT_EQ(0, error_callback_count_); | 
|  | 4611 | 
|  | 4612   // This API is not supported for BR/EDR devices. | 
|  | 4613   properties->type.ReplaceValue(BluetoothDeviceClient::kTypeBredr); | 
|  | 4614   device->SetConnectionLatency( | 
|  | 4615       BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_MEDIUM, | 
|  | 4616       GetCallback(), GetErrorCallback()); | 
|  | 4617   EXPECT_EQ(3, callback_count_); | 
|  | 4618   EXPECT_EQ(1, error_callback_count_); | 
|  | 4619 | 
|  | 4620   // Return an error if the type is not valid. | 
|  | 4621   properties->type.set_valid(false); | 
|  | 4622   device->SetConnectionLatency( | 
|  | 4623       BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_MEDIUM, | 
|  | 4624       GetCallback(), GetErrorCallback()); | 
|  | 4625   EXPECT_EQ(3, callback_count_); | 
|  | 4626   EXPECT_EQ(2, error_callback_count_); | 
|  | 4627 } | 
|  | 4628 | 
| 4579 }  // namespace bluez | 4629 }  // namespace bluez | 
| OLD | NEW | 
|---|