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/test/bluetooth_test_bluez.h" | 5 #include "device/bluetooth/test/bluetooth_test_bluez.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 adapter_ = new bluez::BluetoothAdapterBlueZ( | 87 adapter_ = new bluez::BluetoothAdapterBlueZ( |
88 base::Bind(&AdapterCallback, run_loop.QuitClosure())); | 88 base::Bind(&AdapterCallback, run_loop.QuitClosure())); |
89 run_loop.Run(); | 89 run_loop.Run(); |
90 } | 90 } |
91 | 91 |
92 BluetoothDevice* BluetoothTestBlueZ::SimulateLowEnergyDevice( | 92 BluetoothDevice* BluetoothTestBlueZ::SimulateLowEnergyDevice( |
93 int device_ordinal) { | 93 int device_ordinal) { |
94 if (device_ordinal > 6 || device_ordinal < 1) | 94 if (device_ordinal > 6 || device_ordinal < 1) |
95 return nullptr; | 95 return nullptr; |
96 | 96 |
97 base::Optional<std::string> device_name = kTestDeviceName; | 97 base::Optional<std::string> device_name = kTestDeviceGapName; |
98 std::string device_address = kTestDeviceAddress1; | 98 std::string device_address = kTestDeviceAddress1; |
99 std::vector<std::string> service_uuids; | 99 std::vector<std::string> service_uuids; |
100 BluetoothTransport device_type = BLUETOOTH_TRANSPORT_LE; | 100 BluetoothTransport device_type = BLUETOOTH_TRANSPORT_LE; |
101 | 101 |
102 switch (device_ordinal) { | 102 switch (device_ordinal) { |
103 case 1: | 103 case 1: |
104 service_uuids.push_back(kTestUUIDGenericAccess); | 104 service_uuids.push_back(kTestUUIDGenericAccess); |
105 service_uuids.push_back(kTestUUIDGenericAttribute); | 105 service_uuids.push_back(kTestUUIDGenericAttribute); |
106 break; | 106 break; |
107 case 2: | 107 case 2: |
(...skipping 21 matching lines...) Expand all Loading... |
129 /* name */ device_name, | 129 /* name */ device_name, |
130 /* alias */ device_name.value_or("") + "(alias)", device_address, | 130 /* alias */ device_name.value_or("") + "(alias)", device_address, |
131 service_uuids, device_type); | 131 service_uuids, device_type); |
132 } | 132 } |
133 BluetoothDevice* device = adapter_->GetDevice(device_address); | 133 BluetoothDevice* device = adapter_->GetDevice(device_address); |
134 | 134 |
135 return device; | 135 return device; |
136 } | 136 } |
137 | 137 |
138 BluetoothDevice* BluetoothTestBlueZ::SimulateClassicDevice() { | 138 BluetoothDevice* BluetoothTestBlueZ::SimulateClassicDevice() { |
139 std::string device_name = kTestDeviceName; | 139 std::string device_name = kTestDeviceGapName; |
140 std::string device_address = kTestDeviceAddress3; | 140 std::string device_address = kTestDeviceAddress3; |
141 std::vector<std::string> service_uuids; | 141 std::vector<std::string> service_uuids; |
142 | 142 |
143 if (!adapter_->GetDevice(device_address)) { | 143 if (!adapter_->GetDevice(device_address)) { |
144 fake_bluetooth_device_client_->CreateTestDevice( | 144 fake_bluetooth_device_client_->CreateTestDevice( |
145 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), | 145 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), |
146 device_name /* name */, device_name /* alias */, device_address, | 146 device_name /* name */, device_name /* alias */, device_address, |
147 service_uuids, BLUETOOTH_TRANSPORT_CLASSIC); | 147 service_uuids, BLUETOOTH_TRANSPORT_CLASSIC); |
148 } | 148 } |
149 return adapter_->GetDevice(device_address); | 149 return adapter_->GetDevice(device_address); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 std::vector<BluetoothLocalGattService*> services; | 317 std::vector<BluetoothLocalGattService*> services; |
318 bluez::BluetoothAdapterBlueZ* adapter_bluez = | 318 bluez::BluetoothAdapterBlueZ* adapter_bluez = |
319 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); | 319 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); |
320 | 320 |
321 for (const auto& iter : adapter_bluez->registered_gatt_services_) | 321 for (const auto& iter : adapter_bluez->registered_gatt_services_) |
322 services.push_back(iter.second); | 322 services.push_back(iter.second); |
323 return services; | 323 return services; |
324 } | 324 } |
325 | 325 |
326 } // namespace device | 326 } // namespace device |
OLD | NEW |