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

Unified Diff: device/bluetooth/test/bluetooth_test_win.cc

Issue 1676073002: Implement BluetoothLowEnergyWrapperFake for Bluetooth test fixture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase && address comments Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/test/bluetooth_test_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2bbaeee60017f7daa5633286e47d530ca5a6123d 100644
--- a/device/bluetooth/test/bluetooth_test_win.cc
+++ b/device/bluetooth/test/bluetooth_test_win.cc
@@ -73,4 +73,59 @@ void BluetoothTestWin::InitWithFakeAdapter() {
bool BluetoothTestWin::DenyPermission() {
return false;
}
+
+void BluetoothTestWin::StartLowEnergyDiscoverySession() {
+ __super ::StartLowEnergyDiscoverySession();
+ 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;
+}
}
« no previous file with comments | « device/bluetooth/test/bluetooth_test_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698