Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: chrome/browser/extensions/api/usb/usb_apitest.cc

Issue 12494028: Move Requirements out of Extension Class (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/usb/usb_service.h" 8 #include "chrome/browser/usb/usb_service.h"
9 #include "chrome/browser/usb/usb_service_factory.h" 9 #include "chrome/browser/usb/usb_service_factory.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 13
14 using testing::AnyNumber; 14 using testing::AnyNumber;
15 using testing::_; 15 using testing::_;
16 16
17 namespace extensions {
18
17 namespace { 19 namespace {
18 20
19 ACTION_TEMPLATE(InvokeUsbTransferCallback, 21 ACTION_TEMPLATE(InvokeUsbTransferCallback,
20 HAS_1_TEMPLATE_PARAMS(int, k), 22 HAS_1_TEMPLATE_PARAMS(int, k),
21 AND_1_VALUE_PARAMS(p1)) { 23 AND_1_VALUE_PARAMS(p1)) {
22 ::std::tr1::get<k>(args).Run(p1, new net::IOBuffer(1), 1); 24 ::std::tr1::get<k>(args).Run(p1, new net::IOBuffer(1), 1);
23 } 25 }
24 26
25 // MSVC erroneously thinks that at least one of the arguments for the transfer 27 // MSVC erroneously thinks that at least one of the arguments for the transfer
26 // methods differ by const or volatility and emits a warning about the old 28 // methods differ by const or volatility and emits a warning about the old
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #endif 64 #endif
63 65
64 class UsbApiTest : public ExtensionApiTest { 66 class UsbApiTest : public ExtensionApiTest {
65 public: 67 public:
66 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 68 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
67 ExtensionApiTest::SetUpCommandLine(command_line); 69 ExtensionApiTest::SetUpCommandLine(command_line);
68 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 70 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
69 } 71 }
70 72
71 virtual void SetUpOnMainThread() OVERRIDE { 73 virtual void SetUpOnMainThread() OVERRIDE {
74 ExtensionApiTest::SetUpOnMainThread();
72 mock_device_ = new MockUsbDevice(); 75 mock_device_ = new MockUsbDevice();
73 extensions::UsbFindDevicesFunction::SetDeviceForTest(mock_device_.get()); 76 UsbFindDevicesFunction::SetDeviceForTest(mock_device_.get());
74 } 77 }
75 78
76 protected: 79 protected:
77 scoped_refptr<MockUsbDevice> mock_device_; 80 scoped_refptr<MockUsbDevice> mock_device_;
78 }; 81 };
79 82
80 } // namespace 83 } // namespace
81 84
82 IN_PROC_BROWSER_TEST_F(UsbApiTest, DeviceHandling) { 85 IN_PROC_BROWSER_TEST_F(UsbApiTest, DeviceHandling) {
83 EXPECT_CALL(*mock_device_, Close(_)).Times(1); 86 EXPECT_CALL(*mock_device_, Close(_)).Times(1);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT)); 119 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT));
117 EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber()); 120 EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber());
118 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); 121 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure"));
119 } 122 }
120 123
121 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) { 124 IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) {
122 EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber()); 125 EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber());
123 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer")); 126 ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer"));
124 } 127 }
125 128
129 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698