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

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

Issue 2638653002: Bluetooth: macOS: DidModifyServices can happens while scanning (Closed)
Patch Set: Adding comments and Mac suffix Created 3 years, 7 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 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_
6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 BluetoothRemoteGattDescriptor* descriptor) override; 96 BluetoothRemoteGattDescriptor* descriptor) override;
97 void SimulateGattDescriptorWriteError( 97 void SimulateGattDescriptorWriteError(
98 BluetoothRemoteGattDescriptor* descriptor, 98 BluetoothRemoteGattDescriptor* descriptor,
99 BluetoothRemoteGattService::GattErrorCode error_code) override; 99 BluetoothRemoteGattService::GattErrorCode error_code) override;
100 void ExpectedChangeNotifyValueAttempts(int attempts) override; 100 void ExpectedChangeNotifyValueAttempts(int attempts) override;
101 void ExpectedNotifyValue(NotifyValueState expected_value_state) override; 101 void ExpectedNotifyValue(NotifyValueState expected_value_state) override;
102 102
103 // macOS is the only platform for which we need to discover each set of 103 // macOS is the only platform for which we need to discover each set of
104 // attributes individually so we need a method to simulate discovering each 104 // attributes individually so we need a method to simulate discovering each
105 // set of attributes. 105 // set of attributes.
106 void SimulateDidDiscoverServices(BluetoothDevice* device, 106 // Simulates service discovery for a device.
107 const std::vector<std::string>& uuids); 107 void SimulateDidDiscoverServicesMac(BluetoothDevice* device);
108 // Simulates characteristic discovery for a service.
109 void SimulateDidDiscoverCharacteristicsMac(
110 BluetoothRemoteGattService* service);
111 // Simulates descriptor discovery for a characteristic.
112 void SimulateDidDiscoverDescriptorsMac(
113 BluetoothRemoteGattCharacteristic* characteristic);
108 // CoreBluetooth can return NSData when reading remote gatt descriptors. 114 // CoreBluetooth can return NSData when reading remote gatt descriptors.
109 // This methods simulate receiving NSData from CoreBluetooth. 115 // This methods simulate receiving NSData from CoreBluetooth.
110 void SimulateGattDescriptorReadNSData( 116 void SimulateGattDescriptorReadNSDataMac(
111 BluetoothRemoteGattDescriptor* descriptor, 117 BluetoothRemoteGattDescriptor* descriptor,
112 const std::vector<uint8_t>& value); 118 const std::vector<uint8_t>& value);
113 // CoreBluetooth can return NSString when reading remote gatt descriptors. 119 // CoreBluetooth can return NSString when reading remote gatt descriptors.
114 // This methods simulate receiving NSString from CoreBluetooth. 120 // This methods simulate receiving NSString from CoreBluetooth.
115 void SimulateGattDescriptorReadNSString( 121 void SimulateGattDescriptorReadNSStringMac(
116 BluetoothRemoteGattDescriptor* descriptor, 122 BluetoothRemoteGattDescriptor* descriptor,
117 const std::string& value); 123 const std::string& value);
118 // CoreBluetooth can return NSString when reading remote gatt descriptors. 124 // CoreBluetooth can return NSString when reading remote gatt descriptors.
119 // This methods simulate receiving NSString from CoreBluetooth. 125 // This methods simulate receiving NSString from CoreBluetooth.
120 void SimulateGattDescriptorReadNSNumber( 126 void SimulateGattDescriptorReadNSNumberMac(
121 BluetoothRemoteGattDescriptor* descriptor, 127 BluetoothRemoteGattDescriptor* descriptor,
122 short value); 128 short value);
123 129
130 // Adds services in MockCBPeripheral.
131 void AddServicesToDevice(BluetoothDevice* device,
scheib 2017/05/01 17:20:33 Please add the Mac suffix to these as well.
jlebel 2017/05/01 21:27:14 Ok, I was thinking that those methods could be use
scheib 2017/05/01 21:44:22 Ok, but let's rename them if/when they are moved t
132 const std::vector<std::string>& uuids);
133 // Adds a characteristic in MockCBService.
134 void AddCharacteristicToService(BluetoothRemoteGattService* service,
135 const std::string& characteristic_uuid,
136 int properties);
137 // Adds a descriptor in MockCBCharacteristic.
138 void AddDescriptorToCharacteristic(
139 BluetoothRemoteGattCharacteristic* characteristic,
140 const std::string& uuid);
141
124 // Callback for the bluetooth central manager mock. 142 // Callback for the bluetooth central manager mock.
125 void OnFakeBluetoothDeviceConnectGattCalled(); 143 void OnFakeBluetoothDeviceConnectGattCalled();
126 void OnFakeBluetoothGattDisconnect(); 144 void OnFakeBluetoothGattDisconnect();
127 145
128 // Callback for the bluetooth peripheral mock. 146 // Callback for the bluetooth peripheral mock.
129 void OnFakeBluetoothServiceDiscovery(); 147 void OnFakeBluetoothServiceDiscovery();
130 void OnFakeBluetoothCharacteristicDiscovery(); 148 void OnFakeBluetoothCharacteristicDiscovery();
131 void OnFakeBluetoothCharacteristicReadValue(); 149 void OnFakeBluetoothCharacteristicReadValue();
132 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); 150 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value);
133 void OnFakeBluetoothGattSetCharacteristicNotification(bool notify_value); 151 void OnFakeBluetoothGattSetCharacteristicNotification(bool notify_value);
(...skipping 18 matching lines...) Expand all
152 BluetoothRemoteGattCharacteristic* characteristic) const; 170 BluetoothRemoteGattCharacteristic* characteristic) const;
153 // Returns MockCBPeripheral from BluetoothRemoteGattDescriptor. 171 // Returns MockCBPeripheral from BluetoothRemoteGattDescriptor.
154 MockCBPeripheral* GetMockCBPeripheral( 172 MockCBPeripheral* GetMockCBPeripheral(
155 BluetoothRemoteGattDescriptor* descriptor) const; 173 BluetoothRemoteGattDescriptor* descriptor) const;
156 // Returns MockCBCharacteristic from BluetoothRemoteGattCharacteristic. 174 // Returns MockCBCharacteristic from BluetoothRemoteGattCharacteristic.
157 MockCBCharacteristic* GetCBMockCharacteristic( 175 MockCBCharacteristic* GetCBMockCharacteristic(
158 BluetoothRemoteGattCharacteristic* characteristic) const; 176 BluetoothRemoteGattCharacteristic* characteristic) const;
159 // Returns MockCBDescriptor from BluetoothRemoteGattDescriptor. 177 // Returns MockCBDescriptor from BluetoothRemoteGattDescriptor.
160 MockCBDescriptor* GetCBMockDescriptor( 178 MockCBDescriptor* GetCBMockDescriptor(
161 BluetoothRemoteGattDescriptor* descriptor) const; 179 BluetoothRemoteGattDescriptor* descriptor) const;
162 // Adds services in MockCBPeripheral.
163 void AddServicesToDevice(BluetoothDevice* device,
164 const std::vector<std::string>& uuids);
165 180
166 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. 181 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes.
167 std::string FindCBUUIDForHashTarget(); 182 std::string FindCBUUIDForHashTarget();
168 183
169 BluetoothAdapterMac* adapter_mac_ = nullptr; 184 BluetoothAdapterMac* adapter_mac_ = nullptr;
170 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; 185 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_;
171 186
172 // Value set by -[CBPeripheral setNotifyValue:forCharacteristic:] call. 187 // Value set by -[CBPeripheral setNotifyValue:forCharacteristic:] call.
173 bool last_notify_value_ = false; 188 bool last_notify_value_ = false;
174 int gatt_characteristic_discovery_attempts_ = 0; 189 int gatt_characteristic_discovery_attempts_ = 0;
175 }; 190 };
176 191
177 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). 192 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName).
178 typedef BluetoothTestMac BluetoothTest; 193 typedef BluetoothTestMac BluetoothTest;
179 194
180 } // namespace device 195 } // namespace device
181 196
182 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ 197 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698