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

Side by Side Diff: device/bluetooth/test/bluetooth_test_mac.mm

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Cleanup 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/test/bluetooth_test_mac.h" 5 #include "device/bluetooth/test/bluetooth_test_mac.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 if (BluetoothAdapterMac::IsLowEnergyAvailable()) { 138 if (BluetoothAdapterMac::IsLowEnergyAvailable()) {
139 mock_central_manager_.reset( 139 mock_central_manager_.reset(
140 new ScopedMockCentralManager([[MockCentralManager alloc] init])); 140 new ScopedMockCentralManager([[MockCentralManager alloc] init]));
141 mock_central_manager_->get().bluetoothTestMac = this; 141 mock_central_manager_->get().bluetoothTestMac = this;
142 [mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn]; 142 [mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn];
143 adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get()); 143 adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get());
144 } 144 }
145 } 145 }
146 146
147 void BluetoothTestMac::SimulateConnectedLowEnergyDevice() {
148 const char* identifier;
149 NSString* name;
150 identifier = kTestPeripheralUUID1.c_str();
151 name = @(kTestDeviceName.c_str());
152 scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
153 initWithUTF8StringIdentifier:identifier
154 name:name]);
155 mock_peripheral.get().bluetoothTestMac = this;
156 base::scoped_nsobject<NSMutableArray> peripherals(
157 [[NSMutableArray alloc] init]);
158 [peripherals.get() addObject:mock_peripheral.get()];
159 [mock_central_manager_->get() setConnectedMockPeripherals:peripherals.get()];
160 }
161
147 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) { 162 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
148 TestBluetoothAdapterObserver observer(adapter_); 163 TestBluetoothAdapterObserver observer(adapter_);
149 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_; 164 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_;
150 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate = 165 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate =
151 adapter_mac_->low_energy_central_manager_delegate_; 166 adapter_mac_->low_energy_central_manager_delegate_;
152 167
153 const char* identifier; 168 const char* identifier;
154 NSString* name; 169 NSString* name;
155 NSArray* uuids; 170 NSArray* uuids;
156 NSNumber* rssi; 171 NSNumber* rssi;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); 503 // crypto::SHA256HashString(input_str, raw, sizeof(raw));
489 // if (base::HexEncode(raw, sizeof(raw)) == target) { 504 // if (base::HexEncode(raw, sizeof(raw)) == target) {
490 // return input_str; 505 // return input_str;
491 // } 506 // }
492 // ++input[0]; 507 // ++input[0];
493 // } 508 // }
494 // return ""; 509 // return "";
495 // } 510 // }
496 511
497 } // namespace device 512 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698