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