| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MOCK_BLUETOOTH_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ |
| 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "device/bluetooth/bluetooth_device.h" | 15 #include "device/bluetooth/bluetooth_device.h" |
| 16 #include "device/bluetooth/bluetooth_uuid.h" | 16 #include "device/bluetooth/bluetooth_uuid.h" |
| 17 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 17 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 | 19 |
| 20 namespace device { | 20 namespace device { |
| 21 | 21 |
| 22 class BluetoothGattService; | 22 class BluetoothRemoteGattService; |
| 23 class MockBluetoothAdapter; | 23 class MockBluetoothAdapter; |
| 24 | 24 |
| 25 class MockBluetoothDevice : public BluetoothDevice { | 25 class MockBluetoothDevice : public BluetoothDevice { |
| 26 public: | 26 public: |
| 27 MockBluetoothDevice(MockBluetoothAdapter* adapter, | 27 MockBluetoothDevice(MockBluetoothAdapter* adapter, |
| 28 uint32_t bluetooth_class, | 28 uint32_t bluetooth_class, |
| 29 const std::string& name, | 29 const std::string& name, |
| 30 const std::string& address, | 30 const std::string& address, |
| 31 bool paired, | 31 bool paired, |
| 32 bool connected); | 32 bool connected); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void(const BluetoothUUID& uuid, | 84 void(const BluetoothUUID& uuid, |
| 85 const ConnectToServiceCallback& callback, | 85 const ConnectToServiceCallback& callback, |
| 86 const ConnectToServiceErrorCallback& error_callback)); | 86 const ConnectToServiceErrorCallback& error_callback)); |
| 87 MOCK_METHOD2(CreateGattConnection, | 87 MOCK_METHOD2(CreateGattConnection, |
| 88 void(const GattConnectionCallback& callback, | 88 void(const GattConnectionCallback& callback, |
| 89 const ConnectErrorCallback& error_callback)); | 89 const ConnectErrorCallback& error_callback)); |
| 90 | 90 |
| 91 MOCK_METHOD1(SetGattServicesDiscoveryComplete, void(bool)); | 91 MOCK_METHOD1(SetGattServicesDiscoveryComplete, void(bool)); |
| 92 MOCK_CONST_METHOD0(IsGattServicesDiscoveryComplete, bool()); | 92 MOCK_CONST_METHOD0(IsGattServicesDiscoveryComplete, bool()); |
| 93 | 93 |
| 94 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>()); | 94 MOCK_CONST_METHOD0(GetGattServices, |
| 95 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&)); | 95 std::vector<BluetoothRemoteGattService*>()); |
| 96 MOCK_CONST_METHOD1(GetGattService, |
| 97 BluetoothRemoteGattService*(const std::string&)); |
| 96 MOCK_METHOD0(CreateGattConnectionImpl, void()); | 98 MOCK_METHOD0(CreateGattConnectionImpl, void()); |
| 97 MOCK_METHOD0(DisconnectGatt, void()); | 99 MOCK_METHOD0(DisconnectGatt, void()); |
| 98 | 100 |
| 99 // BluetoothDevice manages the lifetime of its BluetoothGATTServices. | 101 // BluetoothDevice manages the lifetime of its BluetoothGATTServices. |
| 100 // This method takes ownership of the MockBluetoothGATTServices. This is only | 102 // This method takes ownership of the MockBluetoothGATTServices. This is only |
| 101 // for convenience as far as testing is concerned, and it's possible to write | 103 // for convenience as far as testing is concerned, and it's possible to write |
| 102 // test cases without using these functions. | 104 // test cases without using these functions. |
| 103 // Example: | 105 // Example: |
| 104 // ON_CALL(*mock_device, GetGattServices)) | 106 // ON_CALL(*mock_device, GetGattServices)) |
| 105 // .WillByDefault(Invoke(*mock_device, | 107 // .WillByDefault(Invoke(*mock_device, |
| 106 // &MockBluetoothDevice::GetMockServices)); | 108 // &MockBluetoothDevice::GetMockServices)); |
| 107 void AddMockService(std::unique_ptr<MockBluetoothGattService> mock_device); | 109 void AddMockService(std::unique_ptr<MockBluetoothGattService> mock_device); |
| 108 std::vector<BluetoothGattService*> GetMockServices() const; | 110 std::vector<BluetoothRemoteGattService*> GetMockServices() const; |
| 109 BluetoothGattService* GetMockService(const std::string& identifier) const; | 111 BluetoothRemoteGattService* GetMockService( |
| 112 const std::string& identifier) const; |
| 110 | 113 |
| 111 private: | 114 private: |
| 112 uint32_t bluetooth_class_; | 115 uint32_t bluetooth_class_; |
| 113 std::string name_; | 116 std::string name_; |
| 114 std::string address_; | 117 std::string address_; |
| 115 BluetoothDevice::UUIDList uuids_; | 118 BluetoothDevice::UUIDList uuids_; |
| 116 | 119 |
| 117 ScopedVector<MockBluetoothGattService> mock_services_; | 120 ScopedVector<MockBluetoothGattService> mock_services_; |
| 118 }; | 121 }; |
| 119 | 122 |
| 120 } // namespace device | 123 } // namespace device |
| 121 | 124 |
| 122 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ | 125 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |