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

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

Issue 1693433003: webusb: Reject the promise if the device is already open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/mojo/device_impl.cc ('k') | device/usb/public/interfaces/device.mojom » ('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 "device/usb/mojo/device_impl.h" 5 #include "device/usb/mojo/device_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 } // namespace 453 } // namespace
454 454
455 TEST_F(USBDeviceImplTest, Open) { 455 TEST_F(USBDeviceImplTest, Open) {
456 DevicePtr device = GetMockDeviceProxy(); 456 DevicePtr device = GetMockDeviceProxy();
457 457
458 EXPECT_FALSE(is_device_open()); 458 EXPECT_FALSE(is_device_open());
459 459
460 EXPECT_CALL(mock_device(), Open(_)); 460 EXPECT_CALL(mock_device(), Open(_));
461 461
462 base::RunLoop loop; 462 {
463 device->Open( 463 base::RunLoop loop;
464 base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure())); 464 device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK,
465 loop.Run(); 465 loop.QuitClosure()));
466 loop.Run();
467 }
468
469 {
470 base::RunLoop loop;
471 device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::ALREADY_OPEN,
472 loop.QuitClosure()));
473 loop.Run();
474 }
466 475
467 EXPECT_CALL(mock_handle(), Close()); 476 EXPECT_CALL(mock_handle(), Close());
468 } 477 }
469 478
470 TEST_F(USBDeviceImplTest, Close) { 479 TEST_F(USBDeviceImplTest, Close) {
471 DevicePtr device = GetMockDeviceProxy(); 480 DevicePtr device = GetMockDeviceProxy();
472 481
473 EXPECT_FALSE(is_device_open()); 482 EXPECT_FALSE(is_device_open());
474 483
475 EXPECT_CALL(mock_device(), Open(_)); 484 EXPECT_CALL(mock_device(), Open(_));
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data, 895 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data,
887 expected_transferred_lengths, loop.QuitClosure())); 896 expected_transferred_lengths, loop.QuitClosure()));
888 loop.Run(); 897 loop.Run();
889 } 898 }
890 899
891 EXPECT_CALL(mock_handle(), Close()); 900 EXPECT_CALL(mock_handle(), Close());
892 } 901 }
893 902
894 } // namespace usb 903 } // namespace usb
895 } // namespace device 904 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/mojo/device_impl.cc ('k') | device/usb/public/interfaces/device.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698