| 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_USB_MOCK_USB_DEVICE_HANDLE_H_ | 5 #ifndef DEVICE_USB_MOCK_USB_DEVICE_HANDLE_H_ |
| 6 #define DEVICE_USB_MOCK_USB_DEVICE_HANDLE_H_ | 6 #define DEVICE_USB_MOCK_USB_DEVICE_HANDLE_H_ |
| 7 | 7 |
| 8 #include "device/usb/usb_device_handle.h" |
| 9 |
| 8 #include <stddef.h> | 10 #include <stddef.h> |
| 9 #include <stdint.h> | 11 #include <stdint.h> |
| 10 | 12 |
| 11 #include <vector> | |
| 12 | |
| 13 #include "device/usb/usb_device_handle.h" | |
| 14 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 16 | 15 |
| 17 namespace device { | 16 namespace device { |
| 18 | 17 |
| 19 class MockUsbDeviceHandle : public UsbDeviceHandle { | 18 class MockUsbDeviceHandle : public UsbDeviceHandle { |
| 20 public: | 19 public: |
| 21 explicit MockUsbDeviceHandle(UsbDevice* device); | 20 MockUsbDeviceHandle(UsbDevice* device); |
| 22 | 21 |
| 23 scoped_refptr<UsbDevice> GetDevice() const override; | 22 scoped_refptr<UsbDevice> GetDevice() const override; |
| 24 MOCK_METHOD0(Close, void()); | 23 MOCK_METHOD0(Close, void()); |
| 25 MOCK_METHOD2(SetConfiguration, | 24 MOCK_METHOD2(SetConfiguration, |
| 26 void(int configuration_value, const ResultCallback& callback)); | 25 void(int configuration_value, const ResultCallback& callback)); |
| 27 MOCK_METHOD2(ClaimInterface, | 26 MOCK_METHOD2(ClaimInterface, |
| 28 void(int interface_number, const ResultCallback& callback)); | 27 void(int interface_number, const ResultCallback& callback)); |
| 29 MOCK_METHOD1(ReleaseInterface, bool(int interface_number)); | 28 MOCK_METHOD1(ReleaseInterface, bool(int interface_number)); |
| 30 MOCK_METHOD3(SetInterfaceAlternateSetting, | 29 MOCK_METHOD3(SetInterfaceAlternateSetting, |
| 31 void(int interface_number, | 30 void(int interface_number, |
| 32 int alternate_setting, | 31 int alternate_setting, |
| 33 const ResultCallback& callback)); | 32 const ResultCallback& callback)); |
| 34 MOCK_METHOD1(ResetDevice, void(const ResultCallback& callback)); | 33 MOCK_METHOD1(ResetDevice, void(const ResultCallback& callback)); |
| 35 MOCK_METHOD2(ClearHalt, | 34 MOCK_METHOD2(ClearHalt, |
| 36 void(uint8_t endpoint, const ResultCallback& callback)); | 35 void(uint8_t endpoint, const ResultCallback& callback)); |
| 37 MOCK_METHOD10(ControlTransfer, | 36 MOCK_METHOD10(ControlTransfer, |
| 38 void(UsbEndpointDirection direction, | 37 void(UsbEndpointDirection direction, |
| 39 TransferRequestType request_type, | 38 TransferRequestType request_type, |
| 40 TransferRecipient recipient, | 39 TransferRecipient recipient, |
| 41 uint8_t request, | 40 uint8_t request, |
| 42 uint16_t value, | 41 uint16_t value, |
| 43 uint16_t index, | 42 uint16_t index, |
| 44 scoped_refptr<net::IOBuffer> buffer, | 43 scoped_refptr<net::IOBuffer> buffer, |
| 45 size_t length, | 44 size_t length, |
| 46 unsigned int timeout, | 45 unsigned int timeout, |
| 47 const TransferCallback& callback)); | 46 const TransferCallback& callback)); |
| 48 MOCK_METHOD4(IsochronousTransferIn, | 47 MOCK_METHOD8(IsochronousTransfer, |
| 49 void(uint8_t endpoint, | 48 void(UsbEndpointDirection direction, |
| 50 const std::vector<uint32_t>& packet_lengths, | 49 uint8_t endpoint, |
| 50 scoped_refptr<net::IOBuffer> buffer, |
| 51 size_t length, |
| 52 unsigned int packets, |
| 53 unsigned int packet_length, |
| 51 unsigned int timeout, | 54 unsigned int timeout, |
| 52 const IsochronousTransferCallback& callback)); | 55 const TransferCallback& callback)); |
| 53 MOCK_METHOD5(IsochronousTransferOut, | |
| 54 void(uint8_t endpoint, | |
| 55 scoped_refptr<net::IOBuffer> buffer, | |
| 56 const std::vector<uint32_t>& packet_lengths, | |
| 57 unsigned int timeout, | |
| 58 const IsochronousTransferCallback& callback)); | |
| 59 MOCK_METHOD6(GenericTransfer, | 56 MOCK_METHOD6(GenericTransfer, |
| 60 void(UsbEndpointDirection direction, | 57 void(UsbEndpointDirection direction, |
| 61 uint8_t endpoint, | 58 uint8_t endpoint, |
| 62 scoped_refptr<net::IOBuffer> buffer, | 59 scoped_refptr<net::IOBuffer> buffer, |
| 63 size_t length, | 60 size_t length, |
| 64 unsigned int timeout, | 61 unsigned int timeout, |
| 65 const TransferCallback& callback)); | 62 const TransferCallback& callback)); |
| 66 MOCK_METHOD2(FindInterfaceByEndpoint, | 63 MOCK_METHOD2(FindInterfaceByEndpoint, |
| 67 bool(uint8_t endpoint_address, uint8_t* interface_number)); | 64 bool(uint8_t endpoint_address, uint8_t* interface_number)); |
| 68 | 65 |
| 69 private: | 66 private: |
| 70 ~MockUsbDeviceHandle() override; | 67 ~MockUsbDeviceHandle() override; |
| 71 | 68 |
| 72 UsbDevice* device_; | 69 UsbDevice* device_; |
| 73 }; | 70 }; |
| 74 | 71 |
| 75 } // namespace device | 72 } // namespace device |
| 76 | 73 |
| 77 #endif // DEVICE_USB_MOCK_USB_DEVICE_HANDLE_H_ | 74 #endif // DEVICE_USB_MOCK_USB_DEVICE_HANDLE_H_ |
| OLD | NEW |