OLD | NEW |
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" |
11 #include "device/bluetooth/test/bluetooth_test.h" | 11 #include "device/bluetooth/test/bluetooth_test.h" |
12 | 12 |
| 13 #if __OBJC__ |
| 14 @class MockCBPeripheral; |
| 15 #else // __OBJC__ |
| 16 class MockCBPeripheral; |
| 17 #endif // __OBJC__ |
| 18 |
13 namespace device { | 19 namespace device { |
14 | 20 |
15 class BluetoothAdapterMac; | 21 class BluetoothAdapterMac; |
16 | 22 |
17 // Mac implementation of BluetoothTestBase. | 23 // Mac implementation of BluetoothTestBase. |
18 class BluetoothTestMac : public BluetoothTestBase { | 24 class BluetoothTestMac : public BluetoothTestBase { |
19 public: | 25 public: |
20 static const std::string kTestPeripheralUUID1; | 26 static const std::string kTestPeripheralUUID1; |
21 static const std::string kTestPeripheralUUID2; | 27 static const std::string kTestPeripheralUUID2; |
22 | 28 |
(...skipping 11 matching lines...) Expand all Loading... |
34 BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal) override; | 40 BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal) override; |
35 void SimulateGattConnection(BluetoothDevice* device) override; | 41 void SimulateGattConnection(BluetoothDevice* device) override; |
36 void SimulateGattConnectionError( | 42 void SimulateGattConnectionError( |
37 BluetoothDevice* device, | 43 BluetoothDevice* device, |
38 BluetoothDevice::ConnectErrorCode errorCode) override; | 44 BluetoothDevice::ConnectErrorCode errorCode) override; |
39 void SimulateGattDisconnection(BluetoothDevice* device) override; | 45 void SimulateGattDisconnection(BluetoothDevice* device) override; |
40 void SimulateGattServicesDiscovered( | 46 void SimulateGattServicesDiscovered( |
41 BluetoothDevice* device, | 47 BluetoothDevice* device, |
42 const std::vector<std::string>& uuids) override; | 48 const std::vector<std::string>& uuids) override; |
43 void SimulateGattServiceRemoved(BluetoothRemoteGattService* service) override; | 49 void SimulateGattServiceRemoved(BluetoothRemoteGattService* service) override; |
| 50 void SimulateGattCharacteristic(BluetoothRemoteGattService* service, |
| 51 const std::string& uuid, |
| 52 int properties) override; |
| 53 void SimulateGattCharacteristicRemoved( |
| 54 BluetoothRemoteGattService* service, |
| 55 BluetoothRemoteGattCharacteristic* characteristic) override; |
44 | 56 |
45 // Callback for the bluetooth central manager mock. | 57 // Callback for the bluetooth central manager mock. |
46 void OnFakeBluetoothDeviceConnectGattCalled(); | 58 void OnFakeBluetoothDeviceConnectGattCalled(); |
47 void OnFakeBluetoothGattDisconnect(); | 59 void OnFakeBluetoothGattDisconnect(); |
48 | 60 |
49 // Callback for the bluetooth peripheral mock. | 61 // Callback for the bluetooth peripheral mock. |
50 void OnFakeBluetoothServiceDiscovery(); | 62 void OnFakeBluetoothServiceDiscovery(); |
51 | 63 |
52 protected: | 64 protected: |
53 class ScopedMockCentralManager; | 65 class ScopedMockCentralManager; |
54 | 66 |
| 67 // Returns MockCBPeripheral from BluetoothRemoteGattService. |
| 68 MockCBPeripheral* GetMockCBPeripheral( |
| 69 BluetoothRemoteGattService* service) const; |
| 70 |
55 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. | 71 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. |
56 std::string FindCBUUIDForHashTarget(); | 72 std::string FindCBUUIDForHashTarget(); |
57 | 73 |
58 BluetoothAdapterMac* adapter_mac_ = NULL; | 74 BluetoothAdapterMac* adapter_mac_ = NULL; |
59 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; | 75 std::unique_ptr<ScopedMockCentralManager> mock_central_manager_; |
60 }; | 76 }; |
61 | 77 |
62 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). | 78 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). |
63 typedef BluetoothTestMac BluetoothTest; | 79 typedef BluetoothTestMac BluetoothTest; |
64 | 80 |
65 } // namespace device | 81 } // namespace device |
66 | 82 |
67 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ | 83 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ |
OLD | NEW |