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