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