| 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> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 11 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 12 #include "device/bluetooth/bluetooth_device.h" | 14 #include "device/bluetooth/bluetooth_device.h" |
| 13 #include "device/bluetooth/bluetooth_uuid.h" | 15 #include "device/bluetooth/bluetooth_uuid.h" |
| 14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 16 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 16 | 18 |
| 17 namespace device { | 19 namespace device { |
| 18 | 20 |
| 19 class BluetoothGattService; | 21 class BluetoothGattService; |
| 20 class MockBluetoothAdapter; | 22 class MockBluetoothAdapter; |
| 21 | 23 |
| 22 class MockBluetoothDevice : public BluetoothDevice { | 24 class MockBluetoothDevice : public BluetoothDevice { |
| 23 public: | 25 public: |
| 24 MockBluetoothDevice(MockBluetoothAdapter* adapter, | 26 MockBluetoothDevice(MockBluetoothAdapter* adapter, |
| 25 uint32 bluetooth_class, | 27 uint32_t bluetooth_class, |
| 26 const std::string& name, | 28 const std::string& name, |
| 27 const std::string& address, | 29 const std::string& address, |
| 28 bool paired, | 30 bool paired, |
| 29 bool connected); | 31 bool connected); |
| 30 virtual ~MockBluetoothDevice(); | 32 virtual ~MockBluetoothDevice(); |
| 31 | 33 |
| 32 MOCK_CONST_METHOD0(GetBluetoothClass, uint32()); | 34 MOCK_CONST_METHOD0(GetBluetoothClass, uint32_t()); |
| 33 MOCK_CONST_METHOD0(GetDeviceName, std::string()); | 35 MOCK_CONST_METHOD0(GetDeviceName, std::string()); |
| 34 MOCK_CONST_METHOD0(GetIdentifier, std::string()); | 36 MOCK_CONST_METHOD0(GetIdentifier, std::string()); |
| 35 MOCK_CONST_METHOD0(GetAddress, std::string()); | 37 MOCK_CONST_METHOD0(GetAddress, std::string()); |
| 36 MOCK_CONST_METHOD0(GetVendorIDSource, BluetoothDevice::VendorIDSource()); | 38 MOCK_CONST_METHOD0(GetVendorIDSource, BluetoothDevice::VendorIDSource()); |
| 37 MOCK_CONST_METHOD0(GetVendorID, uint16()); | 39 MOCK_CONST_METHOD0(GetVendorID, uint16_t()); |
| 38 MOCK_CONST_METHOD0(GetProductID, uint16()); | 40 MOCK_CONST_METHOD0(GetProductID, uint16_t()); |
| 39 MOCK_CONST_METHOD0(GetDeviceID, uint16()); | 41 MOCK_CONST_METHOD0(GetDeviceID, uint16_t()); |
| 40 MOCK_CONST_METHOD0(GetName, base::string16()); | 42 MOCK_CONST_METHOD0(GetName, base::string16()); |
| 41 MOCK_CONST_METHOD0(GetDeviceType, BluetoothDevice::DeviceType()); | 43 MOCK_CONST_METHOD0(GetDeviceType, BluetoothDevice::DeviceType()); |
| 42 MOCK_CONST_METHOD0(IsPaired, bool()); | 44 MOCK_CONST_METHOD0(IsPaired, bool()); |
| 43 MOCK_CONST_METHOD0(IsConnected, bool()); | 45 MOCK_CONST_METHOD0(IsConnected, bool()); |
| 44 MOCK_CONST_METHOD0(IsGattConnected, bool()); | 46 MOCK_CONST_METHOD0(IsGattConnected, bool()); |
| 45 MOCK_CONST_METHOD0(IsConnectable, bool()); | 47 MOCK_CONST_METHOD0(IsConnectable, bool()); |
| 46 MOCK_CONST_METHOD0(IsConnecting, bool()); | 48 MOCK_CONST_METHOD0(IsConnecting, bool()); |
| 47 MOCK_CONST_METHOD0(GetUUIDs, UUIDList()); | 49 MOCK_CONST_METHOD0(GetUUIDs, UUIDList()); |
| 48 MOCK_CONST_METHOD0(GetInquiryRSSI, int16()); | 50 MOCK_CONST_METHOD0(GetInquiryRSSI, int16_t()); |
| 49 MOCK_CONST_METHOD0(GetInquiryTxPower, int16()); | 51 MOCK_CONST_METHOD0(GetInquiryTxPower, int16_t()); |
| 50 MOCK_CONST_METHOD0(ExpectingPinCode, bool()); | 52 MOCK_CONST_METHOD0(ExpectingPinCode, bool()); |
| 51 MOCK_CONST_METHOD0(ExpectingPasskey, bool()); | 53 MOCK_CONST_METHOD0(ExpectingPasskey, bool()); |
| 52 MOCK_CONST_METHOD0(ExpectingConfirmation, bool()); | 54 MOCK_CONST_METHOD0(ExpectingConfirmation, bool()); |
| 53 MOCK_METHOD1(GetConnectionInfo, void(const ConnectionInfoCallback& callback)); | 55 MOCK_METHOD1(GetConnectionInfo, void(const ConnectionInfoCallback& callback)); |
| 54 MOCK_METHOD3(Connect, | 56 MOCK_METHOD3(Connect, |
| 55 void(BluetoothDevice::PairingDelegate* pairing_delegate, | 57 void(BluetoothDevice::PairingDelegate* pairing_delegate, |
| 56 const base::Closure& callback, | 58 const base::Closure& callback, |
| 57 const BluetoothDevice::ConnectErrorCallback& | 59 const BluetoothDevice::ConnectErrorCallback& |
| 58 error_callback)); | 60 error_callback)); |
| 59 MOCK_METHOD3( | 61 MOCK_METHOD3( |
| 60 Pair, | 62 Pair, |
| 61 void(BluetoothDevice::PairingDelegate* pairing_delegate, | 63 void(BluetoothDevice::PairingDelegate* pairing_delegate, |
| 62 const base::Closure& callback, | 64 const base::Closure& callback, |
| 63 const BluetoothDevice::ConnectErrorCallback& error_callback)); | 65 const BluetoothDevice::ConnectErrorCallback& error_callback)); |
| 64 MOCK_METHOD1(SetPinCode, void(const std::string&)); | 66 MOCK_METHOD1(SetPinCode, void(const std::string&)); |
| 65 MOCK_METHOD1(SetPasskey, void(uint32)); | 67 MOCK_METHOD1(SetPasskey, void(uint32_t)); |
| 66 MOCK_METHOD0(ConfirmPairing, void()); | 68 MOCK_METHOD0(ConfirmPairing, void()); |
| 67 MOCK_METHOD0(RejectPairing, void()); | 69 MOCK_METHOD0(RejectPairing, void()); |
| 68 MOCK_METHOD0(CancelPairing, void()); | 70 MOCK_METHOD0(CancelPairing, void()); |
| 69 MOCK_METHOD2(Disconnect, | 71 MOCK_METHOD2(Disconnect, |
| 70 void(const base::Closure& callback, | 72 void(const base::Closure& callback, |
| 71 const BluetoothDevice::ErrorCallback& error_callback)); | 73 const BluetoothDevice::ErrorCallback& error_callback)); |
| 72 MOCK_METHOD2(Forget, | 74 MOCK_METHOD2(Forget, |
| 73 void(const base::Closure& callback, | 75 void(const base::Closure& callback, |
| 74 const BluetoothDevice::ErrorCallback& error_callback)); | 76 const BluetoothDevice::ErrorCallback& error_callback)); |
| 75 MOCK_METHOD3(ConnectToService, | 77 MOCK_METHOD3(ConnectToService, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 95 // test cases without using these functions. | 97 // test cases without using these functions. |
| 96 // Example: | 98 // Example: |
| 97 // ON_CALL(*mock_device, GetGattServices)) | 99 // ON_CALL(*mock_device, GetGattServices)) |
| 98 // .WillByDefault(Invoke(*mock_device, | 100 // .WillByDefault(Invoke(*mock_device, |
| 99 // &MockBluetoothDevice::GetMockServices)); | 101 // &MockBluetoothDevice::GetMockServices)); |
| 100 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device); | 102 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device); |
| 101 std::vector<BluetoothGattService*> GetMockServices() const; | 103 std::vector<BluetoothGattService*> GetMockServices() const; |
| 102 BluetoothGattService* GetMockService(const std::string& identifier) const; | 104 BluetoothGattService* GetMockService(const std::string& identifier) const; |
| 103 | 105 |
| 104 private: | 106 private: |
| 105 uint32 bluetooth_class_; | 107 uint32_t bluetooth_class_; |
| 106 std::string name_; | 108 std::string name_; |
| 107 std::string address_; | 109 std::string address_; |
| 108 BluetoothDevice::UUIDList uuids_; | 110 BluetoothDevice::UUIDList uuids_; |
| 109 | 111 |
| 110 ScopedVector<MockBluetoothGattService> mock_services_; | 112 ScopedVector<MockBluetoothGattService> mock_services_; |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 } // namespace device | 115 } // namespace device |
| 114 | 116 |
| 115 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ | 117 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |