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

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: 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
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;
+}
}
« device/bluetooth/bluetooth_task_manager_win.cc ('K') | « 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