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