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

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

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Nit for the tests Created 4 years, 1 month 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..5732531dd66ee342f07dd9c4ecc2247eee59da66 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"
@@ -247,6 +248,38 @@ void BluetoothTestMac::SimulateGattConnection(BluetoothDevice* device) {
didConnectPeripheral:peripheral];
}
+void BluetoothTestMac::SimulateConnectedLowEnergyDevice(
+ ConnectedDeviceType device_ordinal) {
+ const char* identifier = nullptr;
+ NSString* name = nil;
+ scoped_nsobject<NSMutableSet> cbUUIDs([[NSMutableSet alloc] init]);
+ switch (device_ordinal) {
+ case ConnectedDeviceType::GENERIC_DEVICE:
+ name = @(kTestDeviceName.c_str());
+ identifier = kTestPeripheralUUID1.c_str();
+ [cbUUIDs
+ addObject:[CBUUID UUIDWithString:@(kTestUUIDGenericAccess.c_str())]];
+ break;
+ case ConnectedDeviceType::HEART_RATE_DEVICE:
+ name = @(kTestDeviceName.c_str());
+ identifier = kTestPeripheralUUID2.c_str();
+ [cbUUIDs
+ addObject:[CBUUID UUIDWithString:@(kTestUUIDGenericAccess.c_str())]];
+ [cbUUIDs addObject:[CBUUID UUIDWithString:@(kTestUUIDHeartRate.c_str())]];
+ break;
+ }
+ DCHECK(name);
+ DCHECK(identifier);
+ DCHECK([cbUUIDs.get() count] > 0);
+ scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
+ initWithUTF8StringIdentifier:identifier
+ name:name]);
+ mock_peripheral.get().bluetoothTestMac = this;
+ [mock_central_manager_->get()
+ setConnectedMockPeripheral:mock_peripheral.get().peripheral
+ withServiceUUIDs:cbUUIDs.get()];
+}
+
void BluetoothTestMac::SimulateGattConnectionError(
BluetoothDevice* device,
BluetoothDevice::ConnectErrorCode errorCode) {
@@ -440,6 +473,20 @@ void BluetoothTest::OnFakeBluetoothGattSetCharacteristicNotification() {
gatt_notify_characteristic_attempts_++;
}
+BluetoothDevice::UUIDSet
+BluetoothTestMac::RetrieveConnectedPeripheralServiceUUIDs() {
+ BluetoothDevice::UUIDSet service_uuids;
+ for (CBUUID* uuid in
+ [mock_central_manager_->get() retrieveConnectedPeripheralServiceUUIDs]) {
+ service_uuids.insert(BluetoothAdapterMac::BluetoothUUIDWithCBUUID(uuid));
+ }
+ return service_uuids;
+}
+
+void BluetoothTestMac::ResetRetrieveConnectedPeripheralServiceUUIDs() {
+ [mock_central_manager_->get() resetRetrieveConnectedPeripheralServiceUUIDs];
+}
+
MockCBPeripheral* BluetoothTestMac::GetMockCBPeripheral(
BluetoothRemoteGattService* service) const {
BluetoothDevice* device = service->GetDevice();
« no previous file with comments | « device/bluetooth/test/bluetooth_test_mac.h ('k') | device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698