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

Side by Side Diff: device/usb/usb_device_handle_unittest.cc

Issue 1897483003: Revert of Replace libusb in the Linux/Chrome OS USB I/O path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « device/usb/usb_device_handle.h ('k') | device/usb/usb_device_handle_usbfs.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 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 "device/usb/usb_device_handle.h" 5 #include "device/usb/usb_device_handle.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 << "Mismatch at index " << i << "."; 246 << "Mismatch at index " << i << ".";
247 } 247 }
248 248
249 TestResultCallback release_interface; 249 TestResultCallback release_interface;
250 handle->ReleaseInterface(1, release_interface.callback()); 250 handle->ReleaseInterface(1, release_interface.callback());
251 ASSERT_TRUE(release_interface.WaitForResult()); 251 ASSERT_TRUE(release_interface.WaitForResult());
252 252
253 handle->Close(); 253 handle->Close();
254 } 254 }
255 255
256 TEST_F(UsbDeviceHandleTest, ControlTransfer) {
257 if (!UsbTestGadget::IsTestEnabled())
258 return;
259
260 scoped_ptr<UsbTestGadget> gadget =
261 UsbTestGadget::Claim(io_thread_->task_runner());
262 ASSERT_TRUE(gadget.get());
263
264 TestOpenCallback open_device;
265 gadget->GetDevice()->Open(open_device.callback());
266 scoped_refptr<UsbDeviceHandle> handle = open_device.WaitForResult();
267 ASSERT_TRUE(handle.get());
268
269 scoped_refptr<net::IOBufferWithSize> buffer(new net::IOBufferWithSize(255));
270 TestCompletionCallback completion;
271 handle->ControlTransfer(USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD,
272 UsbDeviceHandle::DEVICE, 0x06, 0x0301, 0x0409, buffer,
273 buffer->size(), 0, completion.callback());
274 completion.WaitForResult();
275 ASSERT_EQ(USB_TRANSFER_COMPLETED, completion.status());
276 const char expected_str[] = "\x18\x03G\0o\0o\0g\0l\0e\0 \0I\0n\0c\0.\0";
277 EXPECT_EQ(sizeof(expected_str) - 1, completion.transferred());
278 for (size_t i = 0; i < completion.transferred(); ++i) {
279 EXPECT_EQ(expected_str[i], buffer->data()[i]) << "Mismatch at index " << i
280 << ".";
281 }
282
283 handle->Close();
284 }
285
286 TEST_F(UsbDeviceHandleTest, SetInterfaceAlternateSetting) { 256 TEST_F(UsbDeviceHandleTest, SetInterfaceAlternateSetting) {
287 if (!UsbTestGadget::IsTestEnabled()) { 257 if (!UsbTestGadget::IsTestEnabled()) {
288 return; 258 return;
289 } 259 }
290 260
291 std::unique_ptr<UsbTestGadget> gadget = 261 std::unique_ptr<UsbTestGadget> gadget =
292 UsbTestGadget::Claim(io_thread_->task_runner()); 262 UsbTestGadget::Claim(io_thread_->task_runner());
293 ASSERT_TRUE(gadget.get()); 263 ASSERT_TRUE(gadget.get());
294 ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO)); 264 ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
295 265
(...skipping 13 matching lines...) Expand all
309 TestResultCallback release_interface; 279 TestResultCallback release_interface;
310 handle->ReleaseInterface(2, release_interface.callback()); 280 handle->ReleaseInterface(2, release_interface.callback());
311 ASSERT_TRUE(release_interface.WaitForResult()); 281 ASSERT_TRUE(release_interface.WaitForResult());
312 282
313 handle->Close(); 283 handle->Close();
314 } 284 }
315 285
316 } // namespace 286 } // namespace
317 287
318 } // namespace device 288 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_device_handle.h ('k') | device/usb/usb_device_handle_usbfs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698