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

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

Issue 2634873002: Bluetooth: macOS: Implement BluetoothRemoteGattCharacteristicMac::UnsubscribeFromNotifications (Closed)
Patch Set: Adding last_notify_value for macOS Created 3 years, 10 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 void SimulateGattCharacteristicWriteError( 66 void SimulateGattCharacteristicWriteError(
67 BluetoothRemoteGattCharacteristic* characteristic, 67 BluetoothRemoteGattCharacteristic* characteristic,
68 BluetoothRemoteGattService::GattErrorCode error_code) override; 68 BluetoothRemoteGattService::GattErrorCode error_code) override;
69 void SimulateGattDescriptor(BluetoothRemoteGattCharacteristic* characteristic, 69 void SimulateGattDescriptor(BluetoothRemoteGattCharacteristic* characteristic,
70 const std::string& uuid) override; 70 const std::string& uuid) override;
71 void SimulateGattNotifySessionStarted( 71 void SimulateGattNotifySessionStarted(
72 BluetoothRemoteGattCharacteristic* characteristic) override; 72 BluetoothRemoteGattCharacteristic* characteristic) override;
73 void SimulateGattNotifySessionStartError( 73 void SimulateGattNotifySessionStartError(
74 BluetoothRemoteGattCharacteristic* characteristic, 74 BluetoothRemoteGattCharacteristic* characteristic,
75 BluetoothRemoteGattService::GattErrorCode error_code) override; 75 BluetoothRemoteGattService::GattErrorCode error_code) override;
76 void SimulateGattNotifySessionStopped(
77 BluetoothRemoteGattCharacteristic* characteristic) override;
78 void SimulateGattNotifySessionStopError(
79 BluetoothRemoteGattCharacteristic* characteristic,
80 BluetoothRemoteGattService::GattErrorCode error_code) override;
76 void SimulateGattCharacteristicChanged( 81 void SimulateGattCharacteristicChanged(
77 BluetoothRemoteGattCharacteristic* characteristic, 82 BluetoothRemoteGattCharacteristic* characteristic,
78 const std::vector<uint8_t>& value) override; 83 const std::vector<uint8_t>& value) override;
79 void SimulateGattCharacteristicRemoved( 84 void SimulateGattCharacteristicRemoved(
80 BluetoothRemoteGattService* service, 85 BluetoothRemoteGattService* service,
81 BluetoothRemoteGattCharacteristic* characteristic) override; 86 BluetoothRemoteGattCharacteristic* characteristic) override;
82 87
83 // Callback for the bluetooth central manager mock. 88 // Callback for the bluetooth central manager mock.
84 void OnFakeBluetoothDeviceConnectGattCalled(); 89 void OnFakeBluetoothDeviceConnectGattCalled();
85 void OnFakeBluetoothGattDisconnect(); 90 void OnFakeBluetoothGattDisconnect();
86 91
87 // Callback for the bluetooth peripheral mock. 92 // Callback for the bluetooth peripheral mock.
88 void OnFakeBluetoothServiceDiscovery(); 93 void OnFakeBluetoothServiceDiscovery();
89 void OnFakeBluetoothCharacteristicReadValue(); 94 void OnFakeBluetoothCharacteristicReadValue();
90 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value); 95 void OnFakeBluetoothCharacteristicWriteValue(std::vector<uint8_t> value);
91 void OnFakeBluetoothGattSetCharacteristicNotification(); 96 void OnFakeBluetoothGattSetCharacteristicNotification(bool notify_value);
92 97
93 // Returns the service UUIDs used to retrieve connected peripherals. 98 // Returns the service UUIDs used to retrieve connected peripherals.
94 BluetoothDevice::UUIDSet RetrieveConnectedPeripheralServiceUUIDs(); 99 BluetoothDevice::UUIDSet RetrieveConnectedPeripheralServiceUUIDs();
95 // Reset RetrieveConnectedPeripheralServiceUUIDs set. 100 // Reset RetrieveConnectedPeripheralServiceUUIDs set.
96 void ResetRetrieveConnectedPeripheralServiceUUIDs(); 101 void ResetRetrieveConnectedPeripheralServiceUUIDs();
97 102
98 protected: 103 protected:
99 class ScopedMockCentralManager; 104 class ScopedMockCentralManager;
100 105
101 // Returns MockCBPeripheral from BluetoothRemoteGattService. 106 // Returns MockCBPeripheral from BluetoothRemoteGattService.
102 MockCBPeripheral* GetMockCBPeripheral( 107 MockCBPeripheral* GetMockCBPeripheral(
103 BluetoothRemoteGattService* service) const; 108 BluetoothRemoteGattService* service) const;
104 // Returns MockCBPeripheral from BluetoothRemoteGattCharacteristic. 109 // Returns MockCBPeripheral from BluetoothRemoteGattCharacteristic.
105 MockCBPeripheral* GetMockCBPeripheral( 110 MockCBPeripheral* GetMockCBPeripheral(
106 BluetoothRemoteGattCharacteristic* characteristic) const; 111 BluetoothRemoteGattCharacteristic* characteristic) const;
107 // Returns MockCBCharacteristic from BluetoothRemoteGattCharacteristic. 112 // Returns MockCBCharacteristic from BluetoothRemoteGattCharacteristic.
108 MockCBCharacteristic* GetCBMockCharacteristic( 113 MockCBCharacteristic* GetCBMockCharacteristic(
109 BluetoothRemoteGattCharacteristic* characteristic) const; 114 BluetoothRemoteGattCharacteristic* characteristic) const;
110 115
111 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. 116 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes.
112 std::string FindCBUUIDForHashTarget(); 117 std::string FindCBUUIDForHashTarget();
113 118
114 BluetoothAdapterMac* adapter_mac_ = nullptr; 119 BluetoothAdapterMac* adapter_mac_ = nullptr;
115 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; 120 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_;
121
122 // Value set by -[CBPeripheral setNotifyValue:forCharacteristic:] call.
123 bool last_notify_value = false;
116 }; 124 };
117 125
118 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). 126 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName).
119 typedef BluetoothTestMac BluetoothTest; 127 typedef BluetoothTestMac BluetoothTest;
120 128
121 } // namespace device 129 } // namespace device
122 130
123 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ 131 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc ('k') | device/bluetooth/test/bluetooth_test_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698