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

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

Issue 10972018: Changing USB API buffer ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix, don't memset. Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/usb/usb_device_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 { 17 namespace {
18 18
19 ACTION_TEMPLATE(InvokeUsbTransferCallback, 19 ACTION_TEMPLATE(InvokeUsbTransferCallback,
20 HAS_1_TEMPLATE_PARAMS(int, k), 20 HAS_1_TEMPLATE_PARAMS(int, k),
21 AND_1_VALUE_PARAMS(p1)) { 21 AND_1_VALUE_PARAMS(p1)) {
22 ::std::tr1::get<k>(args).Run(p1); 22 ::std::tr1::get<k>(args).Run(p1, new net::IOBuffer(1), 1);
23 } 23 }
24 24
25 // MSVC erroneously thinks that at least one of the arguments for the transfer 25 // 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 26 // methods differ by const or volatility and emits a warning about the old
27 // standards-noncompliant behaviour of their compiler. 27 // standards-noncompliant behaviour of their compiler.
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 #pragma warning(push) 29 #pragma warning(push)
30 #pragma warning(disable:4373) 30 #pragma warning(disable:4373)
31 #endif 31 #endif
32 class MockUsbDevice : public UsbDevice { 32 class MockUsbDevice : public UsbDevice {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferFailure) { 112 IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferFailure) {
113 EXPECT_CALL(*mock_device_, BulkTransfer(_, _, _, _, _, _)) 113 EXPECT_CALL(*mock_device_, BulkTransfer(_, _, _, _, _, _))
114 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED)) 114 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED))
115 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_ERROR)) 115 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_ERROR))
116 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT)); 116 .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT));
117 EXPECT_CALL(*mock_device_, Close()).Times(AnyNumber()); 117 EXPECT_CALL(*mock_device_, Close()).Times(AnyNumber());
118 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); 118 ASSERT_TRUE(RunExtensionTest("usb/transfer_failure"));
119 } 119 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/usb/usb_device_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698