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

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

Issue 1538173003: Implementing GATT connection/disconnect on OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing chromium.gyp_env Created 4 years, 11 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 110e9f992832b5c145b29f2809c64e64f3f5b622..f089adbb23d90f59416f7dc4bd28f88a0793d76b 100644
--- a/device/bluetooth/test/bluetooth_test_mac.mm
+++ b/device/bluetooth/test/bluetooth_test_mac.mm
@@ -9,6 +9,7 @@
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "device/bluetooth/bluetooth_adapter_mac.h"
+#include "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h"
#include "device/bluetooth/test/mock_bluetooth_central_manager_mac.h"
#include "device/bluetooth/test/test_bluetooth_adapter_observer.h"
#include "third_party/ocmock/OCMock/OCMock.h"
@@ -151,8 +152,11 @@ BluetoothDevice* BluetoothTestMac::DiscoverLowEnergyDevice(int device_ordinal) {
break;
}
case 3: {
- CBPeripheral* peripheral = CreateMockPeripheral(
- [NSString stringWithUTF8String:kTestPeripheralUUID1.c_str()]);
+ NSString* uuid_string =
+ [NSString stringWithUTF8String:kTestPeripheralUUID1.c_str()];
+ NSUUID* identifier = [[NSUUID alloc] initWithUUIDString:uuid_string];
+ CBPeripheral* peripheral = (CBPeripheral*)[[MockCBPeripheral alloc]
+ initWithIdentifier:identifier];
NSString* name =
[NSString stringWithUTF8String:kTestDeviceNameEmpty.c_str()];
NSArray* uuids = nil;
@@ -161,6 +165,7 @@ BluetoothDevice* BluetoothTestMac::DiscoverLowEnergyDevice(int device_ordinal) {
didDiscoverPeripheral:peripheral
advertisementData:advertisement_data
RSSI:[NSNumber numberWithInt:0]];
+ [peripheral release];
break;
}
case 4: {
@@ -180,6 +185,18 @@ BluetoothDevice* BluetoothTestMac::DiscoverLowEnergyDevice(int device_ordinal) {
return observer.last_device();
}
+void BluetoothTestMac::SimulateGattConnection(BluetoothDevice* device) {
+ BluetoothLowEnergyDeviceMac* lowEnergyDeviceMac =
+ (BluetoothLowEnergyDeviceMac*)device;
+ BluetoothAdapterMac* adapter = lowEnergyDeviceMac->GetBluetoothAdapterMac();
+ CBPeripheral* peripheral = lowEnergyDeviceMac->GetPeripheral();
+ MockCBPeripheral* mockPeripheral = (MockCBPeripheral*)peripheral;
+ [mockPeripheral setStateForTesting:CBPeripheralStateConnected];
+ CBCentralManager* centralManager = adapter->GetCentralManagerForTesting();
+ [centralManager.delegate centralManager:centralManager
+ didConnectPeripheral:peripheral];
+}
+
// Utility function for generating new (CBUUID, address) pairs where CBUUID
// hashes to address. For use when adding a new device address to the testing
// suite because CoreBluetooth peripherals have CBUUIDs in place of addresses,

Powered by Google App Engine
This is Rietveld 408576698