summaryrefslogtreecommitdiffstats
path: root/device/usb/mojo/device_impl_unittest.cc
diff options
context:
space:
mode:
authorreillyg <reillyg@chromium.org>2016-02-11 13:38:49 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-11 21:40:57 +0000
commit01bda807e1f107f607b767281c62d5f9ddb582b0 (patch)
treea77a19ee7dab5da6cf6cda19818c0222dbe32c13 /device/usb/mojo/device_impl_unittest.cc
parent22ecae62b23d376aa68675b4de70ad96c62ad44c (diff)
downloadchromium_src-01bda807e1f107f607b767281c62d5f9ddb582b0.zip
chromium_src-01bda807e1f107f607b767281c62d5f9ddb582b0.tar.gz
chromium_src-01bda807e1f107f607b767281c62d5f9ddb582b0.tar.bz2
webusb: Reject the promise if the device is already open.
This change adds the necessary plumbing for the USB Mojo service implementation to detect when a device is already open and to report this error so that the WebUSB API can reject the promise returned by USBDevice::open() with an InvalidStateError. BUG=492204 Review URL: https://codereview.chromium.org/1693433003 Cr-Commit-Position: refs/heads/master@{#375003}
Diffstat (limited to 'device/usb/mojo/device_impl_unittest.cc')
-rw-r--r--device/usb/mojo/device_impl_unittest.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/device/usb/mojo/device_impl_unittest.cc b/device/usb/mojo/device_impl_unittest.cc
index 626edd9..c6c2e49 100644
--- a/device/usb/mojo/device_impl_unittest.cc
+++ b/device/usb/mojo/device_impl_unittest.cc
@@ -459,10 +459,19 @@ TEST_F(USBDeviceImplTest, Open) {
EXPECT_CALL(mock_device(), Open(_));
- base::RunLoop loop;
- device->Open(
- base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK, loop.QuitClosure()));
- loop.Run();
+ {
+ base::RunLoop loop;
+ device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::OK,
+ loop.QuitClosure()));
+ loop.Run();
+ }
+
+ {
+ base::RunLoop loop;
+ device->Open(base::Bind(&ExpectOpenAndThen, OpenDeviceError::ALREADY_OPEN,
+ loop.QuitClosure()));
+ loop.Run();
+ }
EXPECT_CALL(mock_handle(), Close());
}