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

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

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Adding BluetoothAdapter::RetrievedConnectedPeripherals() and the implementation in BluetoothAdapter… 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 [mock_central_manager_->get() addConnectedMockPeripheral:mock_peripheral];
157 }
158
147 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) { 159 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
148 TestBluetoothAdapterObserver observer(adapter_); 160 TestBluetoothAdapterObserver observer(adapter_);
149 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_; 161 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_;
150 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate = 162 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate =
151 adapter_mac_->low_energy_central_manager_delegate_; 163 adapter_mac_->low_energy_central_manager_delegate_;
152 164
153 const char* identifier; 165 const char* identifier;
154 NSString* name; 166 NSString* name;
155 NSArray* uuids; 167 NSArray* uuids;
156 NSNumber* rssi; 168 NSNumber* rssi;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); 500 // crypto::SHA256HashString(input_str, raw, sizeof(raw));
489 // if (base::HexEncode(raw, sizeof(raw)) == target) { 501 // if (base::HexEncode(raw, sizeof(raw)) == target) {
490 // return input_str; 502 // return input_str;
491 // } 503 // }
492 // ++input[0]; 504 // ++input[0];
493 // } 505 // }
494 // return ""; 506 // return "";
495 // } 507 // }
496 508
497 } // namespace device 509 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698