| OLD | NEW |
| 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 |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/stringprintf.h" |
| 13 #include "components/arc/bluetooth/bluetooth_type_converters.h" | 14 #include "components/arc/bluetooth/bluetooth_type_converters.h" |
| 14 #include "components/arc/common/bluetooth.mojom.h" | 15 #include "components/arc/common/bluetooth.mojom.h" |
| 15 #include "components/arc/test/fake_arc_bridge_service.h" | 16 #include "components/arc/test/fake_arc_bridge_service.h" |
| 16 #include "components/arc/test/fake_bluetooth_instance.h" | 17 #include "components/arc/test/fake_bluetooth_instance.h" |
| 17 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 18 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 18 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" | 19 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" |
| 19 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h" | 20 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h" |
| 20 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" | 21 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" |
| 21 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" | 22 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" |
| 22 #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" | 23 #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 fake_bluetooth_instance_->le_device_found_data().back()->adv_data(); | 135 fake_bluetooth_instance_->le_device_found_data().back()->adv_data(); |
| 135 | 136 |
| 136 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress), | 137 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress), |
| 137 addr->To<std::string>()); | 138 addr->To<std::string>()); |
| 138 EXPECT_EQ(2u, adv_data.size()); | 139 EXPECT_EQ(2u, adv_data.size()); |
| 139 | 140 |
| 140 EXPECT_TRUE(adv_data[0]->is_local_name()); | 141 EXPECT_TRUE(adv_data[0]->is_local_name()); |
| 141 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName), | 142 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName), |
| 142 adv_data[0]->get_local_name().To<std::string>()); | 143 adv_data[0]->get_local_name().To<std::string>()); |
| 143 | 144 |
| 144 EXPECT_TRUE(adv_data[1]->is_service_uuids()); | 145 EXPECT_TRUE(adv_data[1]->is_service_uuids_16()); |
| 145 EXPECT_EQ(1u, adv_data[1]->get_service_uuids().size()); | 146 EXPECT_EQ(1u, adv_data[1]->get_service_uuids_16().size()); |
| 146 EXPECT_EQ(device::BluetoothUUID( | 147 |
| 147 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), | 148 std::string uuid16_str = |
| 148 adv_data[1]->get_service_uuids()[0].To<device::BluetoothUUID>()); | 149 base::StringPrintf("%04x", adv_data[1]->get_service_uuids_16()[0]); |
| 150 EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID, |
| 151 device::BluetoothUUID(uuid16_str).canonical_value()); |
| 149 } | 152 } |
| 150 | 153 |
| 151 // Invoke GetGattDB and check correctness of the GattDB sent via arc bridge. | 154 // Invoke GetGattDB and check correctness of the GattDB sent via arc bridge. |
| 152 TEST_F(ArcBluetoothBridgeTest, GetGattDB) { | 155 TEST_F(ArcBluetoothBridgeTest, GetGattDB) { |
| 153 AddTestDevice(); | 156 AddTestDevice(); |
| 154 | 157 |
| 155 arc_bluetooth_bridge_->GetGattDB(mojom::BluetoothAddress::From( | 158 arc_bluetooth_bridge_->GetGattDB(mojom::BluetoothAddress::From( |
| 156 std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress))); | 159 std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress))); |
| 157 EXPECT_EQ(1u, fake_bluetooth_instance_->gatt_db_result().size()); | 160 EXPECT_EQ(1u, fake_bluetooth_instance_->gatt_db_result().size()); |
| 158 | 161 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 EXPECT_EQ(device::BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: | 205 EXPECT_EQ(device::BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: |
| 203 kHeartRateControlPointUUID), | 206 kHeartRateControlPointUUID), |
| 204 db[4]->uuid.To<device::BluetoothUUID>()); | 207 db[4]->uuid.To<device::BluetoothUUID>()); |
| 205 EXPECT_EQ(mojom::BluetoothGattDBAttributeType::BTGATT_DB_CHARACTERISTIC, | 208 EXPECT_EQ(mojom::BluetoothGattDBAttributeType::BTGATT_DB_CHARACTERISTIC, |
| 206 db[4]->type); | 209 db[4]->type); |
| 207 EXPECT_EQ(device::BluetoothGattCharacteristic::PROPERTY_WRITE, | 210 EXPECT_EQ(device::BluetoothGattCharacteristic::PROPERTY_WRITE, |
| 208 db[4]->properties); | 211 db[4]->properties); |
| 209 } | 212 } |
| 210 | 213 |
| 211 } // namespace arc | 214 } // namespace arc |
| OLD | NEW |