| 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 "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
| 9 #include "device/bluetooth/test/bluetooth_test.h" | 9 #include "device/bluetooth/test/bluetooth_test.h" |
| 10 | 10 |
| 11 #ifdef __OBJC__ |
| 12 @class MockCentralManager; |
| 13 #else |
| 14 class MockCentralManager; |
| 15 #endif // __OBJC__ |
| 16 |
| 11 namespace device { | 17 namespace device { |
| 12 | 18 |
| 13 class BluetoothAdapterMac; | 19 class BluetoothAdapterMac; |
| 14 | 20 |
| 15 // Mac implementation of BluetoothTestBase. | 21 // Mac implementation of BluetoothTestBase. |
| 16 class BluetoothTestMac : public BluetoothTestBase { | 22 class BluetoothTestMac : public BluetoothTestBase { |
| 17 public: | 23 public: |
| 18 static const std::string kTestPeripheralUUID1; | 24 static const std::string kTestPeripheralUUID1; |
| 19 static const std::string kTestPeripheralUUID2; | 25 static const std::string kTestPeripheralUUID2; |
| 20 | 26 |
| 21 BluetoothTestMac(); | 27 BluetoothTestMac(); |
| 22 ~BluetoothTestMac() override; | 28 ~BluetoothTestMac() override; |
| 23 | 29 |
| 24 // Test overrides: | 30 // Test overrides: |
| 25 void SetUp() override; | 31 void SetUp() override; |
| 26 | 32 |
| 27 // BluetoothTestBase overrides: | 33 // BluetoothTestBase overrides: |
| 28 bool PlatformSupportsLowEnergy() override; | 34 bool PlatformSupportsLowEnergy() override; |
| 29 void InitWithDefaultAdapter() override; | 35 void InitWithDefaultAdapter() override; |
| 30 void InitWithoutDefaultAdapter() override; | 36 void InitWithoutDefaultAdapter() override; |
| 31 void InitWithFakeAdapter() override; | 37 void InitWithFakeAdapter() override; |
| 32 BluetoothDevice* DiscoverLowEnergyDevice(int device_ordinal) override; | 38 BluetoothDevice* DiscoverLowEnergyDevice(int device_ordinal) override; |
| 39 void SimulateGattConnection(BluetoothDevice* device) override; |
| 40 void SimulateGattDisconnection(BluetoothDevice* device) override; |
| 41 void SimulateGattConnectionError( |
| 42 BluetoothDevice* device, |
| 43 BluetoothDevice::ConnectErrorCode errorCode) override; |
| 44 |
| 45 // Callback for the bluetooth central manager mock. |
| 46 void OnFakeBluetoothDeviceConnectGattCalled(); |
| 47 void OnFakeBluetoothGattDisconnect(); |
| 33 | 48 |
| 34 protected: | 49 protected: |
| 35 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. | 50 // Utility function for finding CBUUIDs with relatively nice SHA256 hashes. |
| 36 std::string FindCBUUIDForHashTarget(); | 51 std::string FindCBUUIDForHashTarget(); |
| 37 | 52 |
| 38 BluetoothAdapterMac* adapter_mac_ = NULL; | 53 BluetoothAdapterMac* adapter_mac_ = NULL; |
| 54 MockCentralManager* mock_central_manager_ = NULL; |
| 39 }; | 55 }; |
| 40 | 56 |
| 41 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). | 57 // Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName). |
| 42 typedef BluetoothTestMac BluetoothTest; | 58 typedef BluetoothTestMac BluetoothTest; |
| 43 | 59 |
| 44 } // namespace device | 60 } // namespace device |
| 45 | 61 |
| 46 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ | 62 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_MAC_H_ |
| OLD | NEW |