Chromium Code Reviews| Index: device/bluetooth/test/bluetooth_test_win.cc |
| diff --git a/device/bluetooth/test/bluetooth_test_win.cc b/device/bluetooth/test/bluetooth_test_win.cc |
| index 4e6536f616b6539855ba77ee2ea7112f493a5afe..4c00260e3afb6c921711308a6e1ff12780e615e5 100644 |
| --- a/device/bluetooth/test/bluetooth_test_win.cc |
| +++ b/device/bluetooth/test/bluetooth_test_win.cc |
| @@ -73,4 +73,63 @@ void BluetoothTestWin::InitWithFakeAdapter() { |
| bool BluetoothTestWin::DenyPermission() { |
| return false; |
| } |
| + |
| +void BluetoothTestWin::StartLowEnergyDiscoverySession() { |
| + adapter_->StartDiscoverySessionWithFilter( |
|
scheib
2016/02/07 02:24:08
Is it possible to avoid duplicate code, and not be
gogerald1
2016/02/08 19:23:51
Done.
|
| + make_scoped_ptr(new BluetoothDiscoveryFilter( |
| + BluetoothDiscoveryFilter::Transport::TRANSPORT_LE)), |
| + GetDiscoverySessionCallback(Call::EXPECTED), |
| + GetErrorCallback(Call::NOT_EXPECTED)); |
| + bluetooth_task_runner_->RunPendingTasks(); |
| + ui_task_runner_->RunPendingTasks(); |
| +} |
| + |
| +BluetoothDevice* BluetoothTestWin::DiscoverLowEnergyDevice(int device_ordinal) { |
| + if (device_ordinal > 4 || device_ordinal < 1) |
| + return nullptr; |
| + |
| + std::string device_name = kTestDeviceName; |
| + std::string device_address = kTestDeviceAddress1; |
| + std::string service_uuid_1; |
| + std::string service_uuid_2; |
| + |
| + switch (device_ordinal) { |
| + case 1: { |
| + service_uuid_1 = kTestUUIDGenericAccess; |
| + service_uuid_2 = kTestUUIDGenericAttribute; |
| + } break; |
| + case 2: { |
| + service_uuid_1 = kTestUUIDImmediateAlert; |
| + service_uuid_2 = kTestUUIDLinkLoss; |
| + } break; |
| + case 3: { |
| + device_name = kTestDeviceNameEmpty; |
| + } break; |
| + case 4: { |
| + device_name = kTestDeviceNameEmpty; |
| + device_address = kTestDeviceAddress2; |
| + } break; |
| + } |
| + |
| + win::BLEDevice* simulated_device = fake_bt_le_wrapper_->SimulateBLEDevice( |
| + device_name, CanonicalStringToBLUETOOTH_ADDRESS(device_address)); |
| + if (simulated_device != nullptr) { |
| + if (!service_uuid_1.empty()) |
| + fake_bt_le_wrapper_->SimulateBLEGattService(simulated_device, |
| + service_uuid_1); |
| + if (!service_uuid_2.empty()) |
| + fake_bt_le_wrapper_->SimulateBLEGattService(simulated_device, |
| + service_uuid_2); |
| + } |
| + bluetooth_task_runner_->RunPendingTasks(); |
| + ui_task_runner_->RunPendingTasks(); |
| + |
| + std::vector<BluetoothDevice*> devices = adapter_win_->GetDevices(); |
| + for (auto device : devices) { |
| + if (device->GetAddress() == device_address) |
| + return device; |
| + } |
| + |
| + return nullptr; |
| +} |
| } |