| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "components/usb_service/usb_service.h" | 7 #include "components/usb_service/usb_service.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/test/test_utils.h" | 9 #include "content/public/test/test_utils.h" |
| 10 #include "extensions/browser/api/usb/usb_api.h" | 10 #include "extensions/browser/api/usb/usb_api.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 void(const UsbEndpointDirection direction, | 77 void(const UsbEndpointDirection direction, |
| 78 const uint8 endpoint, | 78 const uint8 endpoint, |
| 79 net::IOBuffer* buffer, | 79 net::IOBuffer* buffer, |
| 80 const size_t length, | 80 const size_t length, |
| 81 const unsigned int packets, | 81 const unsigned int packets, |
| 82 const unsigned int packet_length, | 82 const unsigned int packet_length, |
| 83 const unsigned int timeout, | 83 const unsigned int timeout, |
| 84 const UsbTransferCallback& callback)); | 84 const UsbTransferCallback& callback)); |
| 85 | 85 |
| 86 MOCK_METHOD0(ResetDevice, bool()); | 86 MOCK_METHOD0(ResetDevice, bool()); |
| 87 MOCK_METHOD1(ClaimInterface, bool(const int interface_number)); |
| 88 MOCK_METHOD1(ReleaseInterface, bool(const int interface_number)); |
| 89 MOCK_METHOD2(SetInterfaceAlternateSetting, |
| 90 bool(const int interface_number, const int alternate_setting)); |
| 91 MOCK_METHOD1(GetSerial, bool(base::string16* serial)); |
| 92 |
| 93 virtual scoped_refptr<UsbDevice> GetDevice() const OVERRIDE { |
| 94 return device_; |
| 95 } |
| 87 | 96 |
| 88 void set_device(UsbDevice* device) { device_ = device; } | 97 void set_device(UsbDevice* device) { device_ = device; } |
| 89 | 98 |
| 90 protected: | 99 protected: |
| 100 UsbDevice* device_; |
| 101 |
| 91 virtual ~MockUsbDeviceHandle() {} | 102 virtual ~MockUsbDeviceHandle() {} |
| 92 }; | 103 }; |
| 93 | 104 |
| 94 class MockUsbConfigDescriptor : public UsbConfigDescriptor { | 105 class MockUsbConfigDescriptor : public UsbConfigDescriptor { |
| 95 public: | 106 public: |
| 96 MOCK_CONST_METHOD0(GetNumInterfaces, size_t()); | 107 MOCK_CONST_METHOD0(GetNumInterfaces, size_t()); |
| 97 MOCK_CONST_METHOD1(GetInterface, | 108 MOCK_CONST_METHOD1(GetInterface, |
| 98 scoped_refptr<const UsbInterfaceDescriptor>(size_t index)); | 109 scoped_refptr<const UsbInterfaceDescriptor>(size_t index)); |
| 99 | 110 |
| 100 protected: | 111 protected: |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 .WillOnce( | 280 .WillOnce( |
| 270 InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_TIMEOUT)); | 281 InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_TIMEOUT)); |
| 271 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber()); | 282 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber()); |
| 272 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); | 283 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); |
| 273 } | 284 } |
| 274 | 285 |
| 275 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) { | 286 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) { |
| 276 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber()); | 287 EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber()); |
| 277 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer")); | 288 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer")); |
| 278 } | 289 } |
| OLD | NEW |