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

Unified Diff: device/bluetooth/test/bluetooth_test_mac.mm

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Implementing RetrieveGattConnectedDevicesWithDiscoveryFilter() with tests Created 4 years, 2 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_mac.mm
diff --git a/device/bluetooth/test/bluetooth_test_mac.mm b/device/bluetooth/test/bluetooth_test_mac.mm
index d7e6f4b63ad6020d8ebfeed19d13e4afb3bd52ee..0edb5f28c6df9d8187fe7d9b9a1b406e7839c0ee 100644
--- a/device/bluetooth/test/bluetooth_test_mac.mm
+++ b/device/bluetooth/test/bluetooth_test_mac.mm
@@ -8,6 +8,7 @@
#include "base/mac/foundation_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/sys_string_conversions.h"
#include "build/build_config.h"
#include "device/bluetooth/bluetooth_adapter_mac.h"
#include "device/bluetooth/bluetooth_device_mac.h"
@@ -144,6 +145,39 @@ void BluetoothTestMac::InitWithFakeAdapter() {
}
}
+void BluetoothTestMac::SimulateConnectedLowEnergyDevice(
+ int device_ordinal,
+ const BluetoothDevice::UUIDSet& service_uuids) {
+ const char* identifier = NULL;
+ NSString* name;
+ switch (device_ordinal) {
+ case 1:
+ identifier = kTestPeripheralUUID1.c_str();
+ break;
+ case 2:
+ identifier = kTestPeripheralUUID2.c_str();
+ break;
+ default:
+ NOTREACHED() << "SimulateLowEnergyDevice not implemented for "
+ << device_ordinal;
+ }
+ name = @(kTestDeviceName.c_str());
+ scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
+ initWithUTF8StringIdentifier:identifier
+ name:name]);
+ mock_peripheral.get().bluetoothTestMac = this;
+ scoped_nsobject<NSMutableSet> cbUUIDs([[NSMutableSet alloc] init]);
+ for (auto iterator = service_uuids.begin(); iterator != service_uuids.end();
+ ++iterator) {
+ NSString* uuidString =
+ base::SysUTF8ToNSString(iterator->canonical_value().c_str());
+ [cbUUIDs.get() addObject:[CBUUID UUIDWithString:uuidString]];
+ }
+ [mock_central_manager_->get()
+ setConnectedMockPeripheral:mock_peripheral.get().peripheral
+ withServiceUUIDs:cbUUIDs.get()];
+}
+
BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
TestBluetoothAdapterObserver observer(adapter_);
CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_;

Powered by Google App Engine
This is Rietveld 408576698