OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/usb/usb_api.h" | 5 #include "chrome/browser/extensions/api/usb/usb_api.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/common/chrome_switches.h" | |
9 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
11 | 10 |
12 using testing::AnyNumber; | 11 using testing::AnyNumber; |
13 using testing::_; | 12 using testing::_; |
14 using testing::Return; | 13 using testing::Return; |
15 | 14 |
16 namespace { | 15 namespace { |
17 | 16 |
18 ACTION_TEMPLATE(InvokeUsbTransferCallback, | 17 ACTION_TEMPLATE(InvokeUsbTransferCallback, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 58 |
60 protected: | 59 protected: |
61 virtual ~MockUsbDeviceHandle() {} | 60 virtual ~MockUsbDeviceHandle() {} |
62 }; | 61 }; |
63 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
64 #pragma warning(pop) | 63 #pragma warning(pop) |
65 #endif | 64 #endif |
66 | 65 |
67 class UsbApiTest : public ExtensionApiTest { | 66 class UsbApiTest : public ExtensionApiTest { |
68 public: | 67 public: |
69 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
70 ExtensionApiTest::SetUpCommandLine(command_line); | |
71 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | |
72 } | |
73 | |
74 virtual void SetUpOnMainThread() OVERRIDE { | 68 virtual void SetUpOnMainThread() OVERRIDE { |
75 mock_device_ = new MockUsbDeviceHandle(); | 69 mock_device_ = new MockUsbDeviceHandle(); |
76 extensions::UsbFindDevicesFunction::SetDeviceForTest(mock_device_.get()); | 70 extensions::UsbFindDevicesFunction::SetDeviceForTest(mock_device_.get()); |
77 } | 71 } |
78 | 72 |
79 protected: | 73 protected: |
80 scoped_refptr<MockUsbDeviceHandle> mock_device_; | 74 scoped_refptr<MockUsbDeviceHandle> mock_device_; |
81 }; | 75 }; |
82 | 76 |
83 } // namespace | 77 } // namespace |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_ERROR)) | 133 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_ERROR)) |
140 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT)); | 134 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT)); |
141 EXPECT_CALL(*mock_device_.get(), Close()).Times(AnyNumber()); | 135 EXPECT_CALL(*mock_device_.get(), Close()).Times(AnyNumber()); |
142 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); | 136 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); |
143 } | 137 } |
144 | 138 |
145 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) { | 139 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) { |
146 EXPECT_CALL(*mock_device_.get(), Close()).Times(AnyNumber()); | 140 EXPECT_CALL(*mock_device_.get(), Close()).Times(AnyNumber()); |
147 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer")); | 141 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer")); |
148 } | 142 } |
149 | |
OLD | NEW |