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

Side by Side Diff: device/devices_app/usb/device_impl_unittest.cc

Issue 1352683006: Move device opening from DeviceManager to Device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/devices_app/usb/device_impl.cc ('k') | device/devices_app/usb/device_manager_impl.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 config_.interfaces.push_back(interface); 44 config_.interfaces.push_back(interface);
45 return *this; 45 return *this;
46 } 46 }
47 47
48 const UsbConfigDescriptor& config() const { return config_; } 48 const UsbConfigDescriptor& config() const { return config_; }
49 49
50 private: 50 private:
51 UsbConfigDescriptor config_; 51 UsbConfigDescriptor config_;
52 }; 52 };
53 53
54 void ExpectOpenAndThen(OpenDeviceError expected,
55 const base::Closure& continuation,
56 OpenDeviceError error) {
57 EXPECT_EQ(expected, error);
58 continuation.Run();
59 }
60
54 void ExpectDeviceInfoAndThen(const std::string& guid, 61 void ExpectDeviceInfoAndThen(const std::string& guid,
55 uint16_t vendor_id, 62 uint16_t vendor_id,
56 uint16_t product_id, 63 uint16_t product_id,
57 const std::string& manufacturer_name, 64 const std::string& manufacturer_name,
58 const std::string& product_name, 65 const std::string& product_name,
59 const std::string& serial_number, 66 const std::string& serial_number,
60 const base::Closure& continuation, 67 const base::Closure& continuation,
61 DeviceInfoPtr device_info) { 68 DeviceInfoPtr device_info) {
62 EXPECT_EQ(guid, device_info->guid); 69 EXPECT_EQ(guid, device_info->guid);
63 EXPECT_EQ(vendor_id, device_info->vendor_id); 70 EXPECT_EQ(vendor_id, device_info->vendor_id);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 139
133 void set_allow_reset(bool allow_reset) { allow_reset_ = allow_reset; } 140 void set_allow_reset(bool allow_reset) { allow_reset_ = allow_reset; }
134 141
135 // Creates a mock device and binds a Device proxy to a Device service impl 142 // Creates a mock device and binds a Device proxy to a Device service impl
136 // wrapping the mock device. 143 // wrapping the mock device.
137 DevicePtr GetMockDeviceProxy(uint16_t vendor_id, 144 DevicePtr GetMockDeviceProxy(uint16_t vendor_id,
138 uint16_t product_id, 145 uint16_t product_id,
139 const std::string& manufacturer, 146 const std::string& manufacturer,
140 const std::string& product, 147 const std::string& product,
141 const std::string& serial) { 148 const std::string& serial) {
142 is_device_open_ = true;
143
144 mock_device_ = 149 mock_device_ =
145 new MockUsbDevice(vendor_id, product_id, manufacturer, product, serial); 150 new MockUsbDevice(vendor_id, product_id, manufacturer, product, serial);
146 mock_handle_ = new MockUsbDeviceHandle(mock_device_.get()); 151 mock_handle_ = new MockUsbDeviceHandle(mock_device_.get());
147 152
148 DevicePtr proxy; 153 DevicePtr proxy;
149 new DeviceImpl(mock_handle_, mojo::GetProxy(&proxy)); 154 new DeviceImpl(mock_device_, mojo::GetProxy(&proxy));
150 155
151 // Set up mock handle calls to respond based on mock device configs 156 // Set up mock handle calls to respond based on mock device configs
152 // established by the test. 157 // established by the test.
158 ON_CALL(mock_device(), Open(_))
159 .WillByDefault(Invoke(this, &USBDeviceImplTest::OpenMockHandle));
153 ON_CALL(mock_handle(), Close()) 160 ON_CALL(mock_handle(), Close())
154 .WillByDefault(Invoke(this, &USBDeviceImplTest::CloseMockHandle)); 161 .WillByDefault(Invoke(this, &USBDeviceImplTest::CloseMockHandle));
155 ON_CALL(mock_handle(), SetConfiguration(_, _)) 162 ON_CALL(mock_handle(), SetConfiguration(_, _))
156 .WillByDefault(Invoke(this, &USBDeviceImplTest::SetConfiguration)); 163 .WillByDefault(Invoke(this, &USBDeviceImplTest::SetConfiguration));
157 ON_CALL(mock_handle(), ClaimInterface(_, _)) 164 ON_CALL(mock_handle(), ClaimInterface(_, _))
158 .WillByDefault(Invoke(this, &USBDeviceImplTest::ClaimInterface)); 165 .WillByDefault(Invoke(this, &USBDeviceImplTest::ClaimInterface));
159 ON_CALL(mock_handle(), ReleaseInterface(_)) 166 ON_CALL(mock_handle(), ReleaseInterface(_))
160 .WillByDefault(Invoke(this, &USBDeviceImplTest::ReleaseInterface)); 167 .WillByDefault(Invoke(this, &USBDeviceImplTest::ReleaseInterface));
161 ON_CALL(mock_handle(), SetInterfaceAlternateSetting(_, _, _)) 168 ON_CALL(mock_handle(), SetInterfaceAlternateSetting(_, _, _))
162 .WillByDefault( 169 .WillByDefault(
(...skipping 22 matching lines...) Expand all
185 192
186 void AddMockInboundData(const std::vector<uint8_t>& data) { 193 void AddMockInboundData(const std::vector<uint8_t>& data) {
187 mock_inbound_data_.push(data); 194 mock_inbound_data_.push(data);
188 } 195 }
189 196
190 void AddMockOutboundData(const std::vector<uint8_t>& data) { 197 void AddMockOutboundData(const std::vector<uint8_t>& data) {
191 mock_outbound_data_.push(data); 198 mock_outbound_data_.push(data);
192 } 199 }
193 200
194 private: 201 private:
202 void OpenMockHandle(const UsbDevice::OpenCallback& callback) {
203 EXPECT_FALSE(is_device_open_);
204 is_device_open_ = true;
205 callback.Run(mock_handle_);
206 }
207
195 void CloseMockHandle() { 208 void CloseMockHandle() {
196 EXPECT_TRUE(is_device_open_); 209 EXPECT_TRUE(is_device_open_);
197 is_device_open_ = false; 210 is_device_open_ = false;
198 } 211 }
199 212
200 void SetConfiguration(uint8_t value, 213 void SetConfiguration(uint8_t value,
201 const UsbDeviceHandle::ResultCallback& callback) { 214 const UsbDeviceHandle::ResultCallback& callback) {
202 if (mock_configs_.find(value) != mock_configs_.end()) { 215 if (mock_configs_.find(value) != mock_configs_.end()) {
203 current_config_ = value; 216 current_config_ = value;
204 callback.Run(true); 217 callback.Run(true);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 std::queue<std::vector<uint8_t>> mock_inbound_data_; 340 std::queue<std::vector<uint8_t>> mock_inbound_data_;
328 std::queue<std::vector<uint8_t>> mock_outbound_data_; 341 std::queue<std::vector<uint8_t>> mock_outbound_data_;
329 342
330 std::set<uint8_t> claimed_interfaces_; 343 std::set<uint8_t> claimed_interfaces_;
331 344
332 DISALLOW_COPY_AND_ASSIGN(USBDeviceImplTest); 345 DISALLOW_COPY_AND_ASSIGN(USBDeviceImplTest);
333 }; 346 };
334 347
335 } // namespace 348 } // namespace
336 349
350 TEST_F(USBDeviceImplTest, Open) {
351 DevicePtr device = GetMockDeviceProxy();
352
353 EXPECT_FALSE(is_device_open());
354
355 EXPECT_CALL(mock_device(), Open(_));
356
357 base::RunLoop loop;
358 device->Open(
359 base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK, loop.QuitClosure()));
360 loop.Run();
361
362 EXPECT_CALL(mock_handle(), Close());
363 }
364
337 TEST_F(USBDeviceImplTest, Close) { 365 TEST_F(USBDeviceImplTest, Close) {
338 DevicePtr device = GetMockDeviceProxy(); 366 DevicePtr device = GetMockDeviceProxy();
339 367
340 EXPECT_TRUE(is_device_open()); 368 EXPECT_FALSE(is_device_open());
369
370 EXPECT_CALL(mock_device(), Open(_));
371
372 {
373 base::RunLoop loop;
374 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
375 loop.QuitClosure()));
376 loop.Run();
377 }
341 378
342 EXPECT_CALL(mock_handle(), Close()); 379 EXPECT_CALL(mock_handle(), Close());
343 380
344 base::RunLoop loop; 381 {
345 device->Close(loop.QuitClosure()); 382 base::RunLoop loop;
346 loop.Run(); 383 device->Close(loop.QuitClosure());
384 loop.Run();
385 }
347 386
348 EXPECT_FALSE(is_device_open()); 387 EXPECT_FALSE(is_device_open());
349 } 388 }
350 389
351 // Test that the information returned via the Device::GetDeviceInfo matches that 390 // Test that the information returned via the Device::GetDeviceInfo matches that
352 // of the underlying device. 391 // of the underlying device.
353 TEST_F(USBDeviceImplTest, GetDeviceInfo) { 392 TEST_F(USBDeviceImplTest, GetDeviceInfo) {
354 DevicePtr device = 393 DevicePtr device =
355 GetMockDeviceProxy(0x1234, 0x5678, "ACME", "Frobinator", "ABCDEF"); 394 GetMockDeviceProxy(0x1234, 0x5678, "ACME", "Frobinator", "ABCDEF");
356 395
357 base::RunLoop loop; 396 base::RunLoop loop;
358 device->GetDeviceInfo(base::Bind(&ExpectDeviceInfoAndThen, 397 device->GetDeviceInfo(base::Bind(&ExpectDeviceInfoAndThen,
359 mock_device().guid(), 0x1234, 0x5678, "ACME", 398 mock_device().guid(), 0x1234, 0x5678, "ACME",
360 "Frobinator", "ABCDEF", loop.QuitClosure())); 399 "Frobinator", "ABCDEF", loop.QuitClosure()));
361 loop.Run(); 400 loop.Run();
362
363 EXPECT_CALL(mock_handle(), Close());
364 } 401 }
365 402
366 TEST_F(USBDeviceImplTest, SetInvalidConfiguration) { 403 TEST_F(USBDeviceImplTest, SetInvalidConfiguration) {
367 DevicePtr device = GetMockDeviceProxy(); 404 DevicePtr device = GetMockDeviceProxy();
368 405
406 EXPECT_CALL(mock_device(), Open(_));
407
408 {
409 base::RunLoop loop;
410 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
411 loop.QuitClosure()));
412 loop.Run();
413 }
414
369 EXPECT_CALL(mock_handle(), SetConfiguration(42, _)); 415 EXPECT_CALL(mock_handle(), SetConfiguration(42, _));
370 416
371 // SetConfiguration should fail because 42 is not a valid mock configuration. 417 {
372 base::RunLoop loop; 418 // SetConfiguration should fail because 42 is not a valid mock
373 device->SetConfiguration( 419 // configuration.
374 42, base::Bind(&ExpectResultAndThen, false, loop.QuitClosure())); 420 base::RunLoop loop;
375 loop.Run(); 421 device->SetConfiguration(
422 42, base::Bind(&ExpectResultAndThen, false, loop.QuitClosure()));
423 loop.Run();
424 }
376 425
377 EXPECT_CALL(mock_handle(), Close()); 426 EXPECT_CALL(mock_handle(), Close());
378 } 427 }
379 428
380 TEST_F(USBDeviceImplTest, SetValidConfiguration) { 429 TEST_F(USBDeviceImplTest, SetValidConfiguration) {
381 DevicePtr device = GetMockDeviceProxy(); 430 DevicePtr device = GetMockDeviceProxy();
382 431
432 EXPECT_CALL(mock_device(), Open(_));
433
434 {
435 base::RunLoop loop;
436 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
437 loop.QuitClosure()));
438 loop.Run();
439 }
440
383 EXPECT_CALL(mock_handle(), SetConfiguration(42, _)); 441 EXPECT_CALL(mock_handle(), SetConfiguration(42, _));
384 442
385 AddMockConfig(ConfigBuilder(42)); 443 AddMockConfig(ConfigBuilder(42));
386 444
387 // SetConfiguration should succeed because 42 is a valid mock configuration. 445 {
388 base::RunLoop loop; 446 // SetConfiguration should succeed because 42 is a valid mock configuration.
389 device->SetConfiguration( 447 base::RunLoop loop;
390 42, base::Bind(&ExpectResultAndThen, true, loop.QuitClosure())); 448 device->SetConfiguration(
391 loop.Run(); 449 42, base::Bind(&ExpectResultAndThen, true, loop.QuitClosure()));
450 loop.Run();
451 }
392 452
393 EXPECT_CALL(mock_handle(), Close()); 453 EXPECT_CALL(mock_handle(), Close());
394 } 454 }
395 455
396 // Verify that the result of Reset() reflects the underlying UsbDeviceHandle's 456 // Verify that the result of Reset() reflects the underlying UsbDeviceHandle's
397 // ResetDevice() result. 457 // ResetDevice() result.
398 TEST_F(USBDeviceImplTest, Reset) { 458 TEST_F(USBDeviceImplTest, Reset) {
399 DevicePtr device = GetMockDeviceProxy(); 459 DevicePtr device = GetMockDeviceProxy();
400 460
461 EXPECT_CALL(mock_device(), Open(_));
462
463 {
464 base::RunLoop loop;
465 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
466 loop.QuitClosure()));
467 loop.Run();
468 }
469
401 EXPECT_CALL(mock_handle(), ResetDevice(_)); 470 EXPECT_CALL(mock_handle(), ResetDevice(_));
402 471
403 set_allow_reset(true); 472 set_allow_reset(true);
404 473
405 { 474 {
406 base::RunLoop loop; 475 base::RunLoop loop;
407 device->Reset(base::Bind(&ExpectResultAndThen, true, loop.QuitClosure())); 476 device->Reset(base::Bind(&ExpectResultAndThen, true, loop.QuitClosure()));
408 loop.Run(); 477 loop.Run();
409 } 478 }
410 479
411 EXPECT_CALL(mock_handle(), ResetDevice(_)); 480 EXPECT_CALL(mock_handle(), ResetDevice(_));
412 481
413 set_allow_reset(false); 482 set_allow_reset(false);
414 483
415 { 484 {
416 base::RunLoop loop; 485 base::RunLoop loop;
417 device->Reset(base::Bind(&ExpectResultAndThen, false, loop.QuitClosure())); 486 device->Reset(base::Bind(&ExpectResultAndThen, false, loop.QuitClosure()));
418 loop.Run(); 487 loop.Run();
419 } 488 }
420 489
421 EXPECT_CALL(mock_handle(), Close()); 490 EXPECT_CALL(mock_handle(), Close());
422 } 491 }
423 492
424 TEST_F(USBDeviceImplTest, ClaimAndReleaseInterface) { 493 TEST_F(USBDeviceImplTest, ClaimAndReleaseInterface) {
425 DevicePtr device = GetMockDeviceProxy(); 494 DevicePtr device = GetMockDeviceProxy();
426 495
496 EXPECT_CALL(mock_device(), Open(_));
497
498 {
499 base::RunLoop loop;
500 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
501 loop.QuitClosure()));
502 loop.Run();
503 }
504
427 // Now add a mock interface #1. 505 // Now add a mock interface #1.
428 AddMockConfig(ConfigBuilder(0).AddInterface(1, 0, 1, 2, 3)); 506 AddMockConfig(ConfigBuilder(0).AddInterface(1, 0, 1, 2, 3));
429 507
430 EXPECT_CALL(mock_handle(), ClaimInterface(2, _)); 508 EXPECT_CALL(mock_handle(), ClaimInterface(2, _));
431 509
432 { 510 {
433 // Try to claim an invalid interface and expect failure. 511 // Try to claim an invalid interface and expect failure.
434 base::RunLoop loop; 512 base::RunLoop loop;
435 device->ClaimInterface( 513 device->ClaimInterface(
436 2, base::Bind(&ExpectResultAndThen, false, loop.QuitClosure())); 514 2, base::Bind(&ExpectResultAndThen, false, loop.QuitClosure()));
(...skipping 28 matching lines...) Expand all
465 1, base::Bind(&ExpectResultAndThen, true, loop.QuitClosure())); 543 1, base::Bind(&ExpectResultAndThen, true, loop.QuitClosure()));
466 loop.Run(); 544 loop.Run();
467 } 545 }
468 546
469 EXPECT_CALL(mock_handle(), Close()); 547 EXPECT_CALL(mock_handle(), Close());
470 } 548 }
471 549
472 TEST_F(USBDeviceImplTest, SetInterfaceAlternateSetting) { 550 TEST_F(USBDeviceImplTest, SetInterfaceAlternateSetting) {
473 DevicePtr device = GetMockDeviceProxy(); 551 DevicePtr device = GetMockDeviceProxy();
474 552
553 EXPECT_CALL(mock_device(), Open(_));
554
555 {
556 base::RunLoop loop;
557 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
558 loop.QuitClosure()));
559 loop.Run();
560 }
561
475 AddMockConfig(ConfigBuilder(0) 562 AddMockConfig(ConfigBuilder(0)
476 .AddInterface(1, 0, 1, 2, 3) 563 .AddInterface(1, 0, 1, 2, 3)
477 .AddInterface(1, 42, 1, 2, 3) 564 .AddInterface(1, 42, 1, 2, 3)
478 .AddInterface(2, 0, 1, 2, 3)); 565 .AddInterface(2, 0, 1, 2, 3));
479 566
480 EXPECT_CALL(mock_handle(), SetInterfaceAlternateSetting(1, 42, _)); 567 EXPECT_CALL(mock_handle(), SetInterfaceAlternateSetting(1, 42, _));
481 568
482 { 569 {
483 base::RunLoop loop; 570 base::RunLoop loop;
484 device->SetInterfaceAlternateSetting( 571 device->SetInterfaceAlternateSetting(
485 1, 42, base::Bind(&ExpectResultAndThen, true, loop.QuitClosure())); 572 1, 42, base::Bind(&ExpectResultAndThen, true, loop.QuitClosure()));
486 loop.Run(); 573 loop.Run();
487 } 574 }
488 575
489 EXPECT_CALL(mock_handle(), SetInterfaceAlternateSetting(1, 100, _)); 576 EXPECT_CALL(mock_handle(), SetInterfaceAlternateSetting(1, 100, _));
490 577
491 { 578 {
492 base::RunLoop loop; 579 base::RunLoop loop;
493 device->SetInterfaceAlternateSetting( 580 device->SetInterfaceAlternateSetting(
494 1, 100, base::Bind(&ExpectResultAndThen, false, loop.QuitClosure())); 581 1, 100, base::Bind(&ExpectResultAndThen, false, loop.QuitClosure()));
495 loop.Run(); 582 loop.Run();
496 } 583 }
497 584
498 EXPECT_CALL(mock_handle(), Close()); 585 EXPECT_CALL(mock_handle(), Close());
499 } 586 }
500 587
501 TEST_F(USBDeviceImplTest, ControlTransfer) { 588 TEST_F(USBDeviceImplTest, ControlTransfer) {
502 DevicePtr device = GetMockDeviceProxy(); 589 DevicePtr device = GetMockDeviceProxy();
503 590
591 EXPECT_CALL(mock_device(), Open(_));
592
593 {
594 base::RunLoop loop;
595 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
596 loop.QuitClosure()));
597 loop.Run();
598 }
599
504 std::vector<uint8_t> fake_data; 600 std::vector<uint8_t> fake_data;
505 fake_data.push_back(41); 601 fake_data.push_back(41);
506 fake_data.push_back(42); 602 fake_data.push_back(42);
507 fake_data.push_back(43); 603 fake_data.push_back(43);
508 604
509 AddMockInboundData(fake_data); 605 AddMockInboundData(fake_data);
510 606
511 EXPECT_CALL(mock_handle(), 607 EXPECT_CALL(mock_handle(),
512 ControlTransfer(USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD, 608 ControlTransfer(USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD,
513 UsbDeviceHandle::DEVICE, 5, 6, 7, _, _, 0, _)); 609 UsbDeviceHandle::DEVICE, 5, 6, 7, _, _, 0, _));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 loop.QuitClosure())); 644 loop.QuitClosure()));
549 loop.Run(); 645 loop.Run();
550 } 646 }
551 647
552 EXPECT_CALL(mock_handle(), Close()); 648 EXPECT_CALL(mock_handle(), Close());
553 } 649 }
554 650
555 TEST_F(USBDeviceImplTest, GenericTransfer) { 651 TEST_F(USBDeviceImplTest, GenericTransfer) {
556 DevicePtr device = GetMockDeviceProxy(); 652 DevicePtr device = GetMockDeviceProxy();
557 653
654 EXPECT_CALL(mock_device(), Open(_));
655
656 {
657 base::RunLoop loop;
658 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
659 loop.QuitClosure()));
660 loop.Run();
661 }
662
558 std::string message1 = "say hello please"; 663 std::string message1 = "say hello please";
559 std::vector<uint8_t> fake_outbound_data(message1.size()); 664 std::vector<uint8_t> fake_outbound_data(message1.size());
560 std::copy(message1.begin(), message1.end(), fake_outbound_data.begin()); 665 std::copy(message1.begin(), message1.end(), fake_outbound_data.begin());
561 666
562 std::string message2 = "hello world!"; 667 std::string message2 = "hello world!";
563 std::vector<uint8_t> fake_inbound_data(message2.size()); 668 std::vector<uint8_t> fake_inbound_data(message2.size());
564 std::copy(message2.begin(), message2.end(), fake_inbound_data.begin()); 669 std::copy(message2.begin(), message2.end(), fake_inbound_data.begin());
565 670
566 AddMockConfig(ConfigBuilder(0).AddInterface(7, 0, 1, 2, 3)); 671 AddMockConfig(ConfigBuilder(0).AddInterface(7, 0, 1, 2, 3));
567 AddMockOutboundData(fake_outbound_data); 672 AddMockOutboundData(fake_outbound_data);
(...skipping 22 matching lines...) Expand all
590 fake_inbound_data, loop.QuitClosure())); 695 fake_inbound_data, loop.QuitClosure()));
591 loop.Run(); 696 loop.Run();
592 } 697 }
593 698
594 EXPECT_CALL(mock_handle(), Close()); 699 EXPECT_CALL(mock_handle(), Close());
595 } 700 }
596 701
597 TEST_F(USBDeviceImplTest, IsochronousTransfer) { 702 TEST_F(USBDeviceImplTest, IsochronousTransfer) {
598 DevicePtr device = GetMockDeviceProxy(); 703 DevicePtr device = GetMockDeviceProxy();
599 704
705 EXPECT_CALL(mock_device(), Open(_));
706
707 {
708 base::RunLoop loop;
709 device->Open(base::Bind(&ExpectOpenAndThen, OPEN_DEVICE_ERROR_OK,
710 loop.QuitClosure()));
711 loop.Run();
712 }
713
600 std::string outbound_packet_data = "aaaaaaaabbbbbbbbccccccccdddddddd"; 714 std::string outbound_packet_data = "aaaaaaaabbbbbbbbccccccccdddddddd";
601 std::vector<uint8_t> fake_outbound_packets(outbound_packet_data.size()); 715 std::vector<uint8_t> fake_outbound_packets(outbound_packet_data.size());
602 std::copy(outbound_packet_data.begin(), outbound_packet_data.end(), 716 std::copy(outbound_packet_data.begin(), outbound_packet_data.end(),
603 fake_outbound_packets.begin()); 717 fake_outbound_packets.begin());
604 718
605 std::string inbound_packet_data = "ddddddddccccccccbbbbbbbbaaaaaaaa"; 719 std::string inbound_packet_data = "ddddddddccccccccbbbbbbbbaaaaaaaa";
606 std::vector<uint8_t> fake_inbound_packets(inbound_packet_data.size()); 720 std::vector<uint8_t> fake_inbound_packets(inbound_packet_data.size());
607 std::copy(inbound_packet_data.begin(), inbound_packet_data.end(), 721 std::copy(inbound_packet_data.begin(), inbound_packet_data.end(),
608 fake_inbound_packets.begin()); 722 fake_inbound_packets.begin());
609 723
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 1, 4, 8, 0, base::Bind(&ExpectPacketsAndThen, TRANSFER_STATUS_COMPLETED, 762 1, 4, 8, 0, base::Bind(&ExpectPacketsAndThen, TRANSFER_STATUS_COMPLETED,
649 packets, loop.QuitClosure())); 763 packets, loop.QuitClosure()));
650 loop.Run(); 764 loop.Run();
651 } 765 }
652 766
653 EXPECT_CALL(mock_handle(), Close()); 767 EXPECT_CALL(mock_handle(), Close());
654 } 768 }
655 769
656 } // namespace usb 770 } // namespace usb
657 } // namespace device 771 } // namespace device
OLDNEW
« no previous file with comments | « device/devices_app/usb/device_impl.cc ('k') | device/devices_app/usb/device_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698