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

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

Issue 1695643002: Destroy DeviceImpl when the underlying UsbDevice is disconnected. (Closed) Base URL: reillyg-linux.mtv.corp.google.com:/src/chromium/src@mojo_device_autoclose
Patch Set: Revert change to web_usb_device_impl.cc. 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/usb_device.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 "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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 440
441 std::set<uint8_t> claimed_interfaces_; 441 std::set<uint8_t> claimed_interfaces_;
442 442
443 FakePermissionProvider permission_provider_; 443 FakePermissionProvider permission_provider_;
444 444
445 DISALLOW_COPY_AND_ASSIGN(USBDeviceImplTest); 445 DISALLOW_COPY_AND_ASSIGN(USBDeviceImplTest);
446 }; 446 };
447 447
448 } // namespace 448 } // namespace
449 449
450 TEST_F(USBDeviceImplTest, Disconnect) {
451 DevicePtr device = GetMockDeviceProxy();
452
453 base::RunLoop loop;
454 device.set_connection_error_handler(loop.QuitClosure());
455 mock_device().NotifyDeviceRemoved();
456 loop.Run();
457 }
458
450 TEST_F(USBDeviceImplTest, Open) { 459 TEST_F(USBDeviceImplTest, Open) {
451 DevicePtr device = GetMockDeviceProxy(); 460 DevicePtr device = GetMockDeviceProxy();
452 461
453 EXPECT_FALSE(is_device_open()); 462 EXPECT_FALSE(is_device_open());
454 463
455 EXPECT_CALL(mock_device(), Open(_)); 464 EXPECT_CALL(mock_device(), Open(_));
456 465
457 { 466 {
458 base::RunLoop loop; 467 base::RunLoop loop;
459 device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, 468 device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK,
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data, 899 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data,
891 expected_transferred_lengths, loop.QuitClosure())); 900 expected_transferred_lengths, loop.QuitClosure()));
892 loop.Run(); 901 loop.Run();
893 } 902 }
894 903
895 EXPECT_CALL(mock_handle(), Close()); 904 EXPECT_CALL(mock_handle(), Close());
896 } 905 }
897 906
898 } // namespace usb 907 } // namespace usb
899 } // namespace device 908 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/mojo/device_impl.cc ('k') | device/usb/usb_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698