| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "device/bluetooth/bluetooth_device.h" | 12 #include "device/bluetooth/bluetooth_device.h" |
| 13 #include "device/bluetooth/bluetooth_uuid.h" | 13 #include "device/bluetooth/bluetooth_uuid.h" |
| 14 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h" |
| 14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 15 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 16 | 17 |
| 17 namespace device { | 18 namespace device { |
| 18 | 19 |
| 19 class BluetoothGattService; | 20 class BluetoothGattService; |
| 20 class MockBluetoothAdapter; | 21 class MockBluetoothAdapter; |
| 21 | 22 |
| 22 class MockBluetoothDevice : public BluetoothDevice { | 23 class MockBluetoothDevice : public BluetoothDevice { |
| 23 public: | 24 public: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 const BluetoothDevice::ErrorCallback& error_callback)); | 72 const BluetoothDevice::ErrorCallback& error_callback)); |
| 72 MOCK_METHOD1(Forget, void(const BluetoothDevice::ErrorCallback&)); | 73 MOCK_METHOD1(Forget, void(const BluetoothDevice::ErrorCallback&)); |
| 73 MOCK_METHOD3(ConnectToService, | 74 MOCK_METHOD3(ConnectToService, |
| 74 void(const BluetoothUUID& uuid, | 75 void(const BluetoothUUID& uuid, |
| 75 const ConnectToServiceCallback& callback, | 76 const ConnectToServiceCallback& callback, |
| 76 const ConnectToServiceErrorCallback& error_callback)); | 77 const ConnectToServiceErrorCallback& error_callback)); |
| 77 MOCK_METHOD3(ConnectToServiceInsecurely, | 78 MOCK_METHOD3(ConnectToServiceInsecurely, |
| 78 void(const BluetoothUUID& uuid, | 79 void(const BluetoothUUID& uuid, |
| 79 const ConnectToServiceCallback& callback, | 80 const ConnectToServiceCallback& callback, |
| 80 const ConnectToServiceErrorCallback& error_callback)); | 81 const ConnectToServiceErrorCallback& error_callback)); |
| 81 MOCK_METHOD2(CreateGattConnection, | 82 MOCK_METHOD2(CreateGattConnectionRaw, |
| 82 void(const GattConnectionCallback& callback, | 83 device::MockBluetoothGattConnection*( |
| 83 const ConnectErrorCallback& error_callback)); | 84 const GattConnectionCallback& callback, |
| 85 const ConnectErrorCallback& error_callback)); |
| 84 | 86 |
| 85 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>()); | 87 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>()); |
| 86 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&)); | 88 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&)); |
| 87 MOCK_METHOD0(CreateGattConnectionImpl, void()); | 89 MOCK_METHOD0(CreateGattConnectionImplRaw, |
| 90 device::MockBluetoothGattConnection*()); |
| 88 MOCK_METHOD0(DisconnectGatt, void()); | 91 MOCK_METHOD0(DisconnectGatt, void()); |
| 89 | 92 |
| 93 scoped_ptr<device::BluetoothGattConnection> CreateGattConnection( |
| 94 const GattConnectionCallback& callback, |
| 95 const ConnectErrorCallback& error_callback); |
| 96 |
| 97 scoped_ptr<device::BluetoothGattConnection> CreateGattConnectionImpl(); |
| 98 |
| 90 // BluetoothDevice manages the lifetime of its BluetoothGATTServices. | 99 // BluetoothDevice manages the lifetime of its BluetoothGATTServices. |
| 91 // This method takes ownership of the MockBluetoothGATTServices. This is only | 100 // This method takes ownership of the MockBluetoothGATTServices. This is only |
| 92 // for convenience as far as testing is concerned, and it's possible to write | 101 // for convenience as far as testing is concerned, and it's possible to write |
| 93 // test cases without using these functions. | 102 // test cases without using these functions. |
| 94 // Example: | 103 // Example: |
| 95 // ON_CALL(*mock_device, GetGattServices)) | 104 // ON_CALL(*mock_device, GetGattServices)) |
| 96 // .WillByDefault(Invoke(*mock_device, | 105 // .WillByDefault(Invoke(*mock_device, |
| 97 // &MockBluetoothDevice::GetMockServices)); | 106 // &MockBluetoothDevice::GetMockServices)); |
| 98 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device); | 107 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device); |
| 99 std::vector<BluetoothGattService*> GetMockServices() const; | 108 std::vector<BluetoothGattService*> GetMockServices() const; |
| 100 BluetoothGattService* GetMockService(const std::string& identifier) const; | 109 BluetoothGattService* GetMockService(const std::string& identifier) const; |
| 101 | 110 |
| 102 private: | 111 private: |
| 103 uint32 bluetooth_class_; | 112 uint32 bluetooth_class_; |
| 104 std::string name_; | 113 std::string name_; |
| 105 std::string address_; | 114 std::string address_; |
| 106 BluetoothDevice::UUIDList uuids_; | 115 BluetoothDevice::UUIDList uuids_; |
| 107 | 116 |
| 108 ScopedVector<MockBluetoothGattService> mock_services_; | 117 ScopedVector<MockBluetoothGattService> mock_services_; |
| 109 }; | 118 }; |
| 110 | 119 |
| 111 } // namespace device | 120 } // namespace device |
| 112 | 121 |
| 113 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ | 122 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |