Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change improves the code coverage for the sources files under //third_party/blink/renderer/modules/webusb. The affected files are: * usb.cc * usb_alternate_interface.cc * usb_configuration.cc * usb_device.cc * usb_endpoint.cc * usb_interface.cc Bug: 854831 Change-Id: Ie67533ece27f1c944b0e9186d01a61219a30f805 Reviewed-on: https://chromium-review.googlesource.com/1183789 Commit-Queue: Ovidio Henriquez <odejesush@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#586930}
- Loading branch information
Showing
7 changed files
with
453 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// META: script=/webusb/resources/fake-devices.js | ||
// META: script=/webusb/resources/usb-helpers.js | ||
'use strict'; | ||
|
||
usb_test(async () => { | ||
let { device } = await getFakeDevice(); | ||
let configuration = new USBConfiguration( | ||
device, device.configurations[1].configurationValue); | ||
let usbInterface = new USBInterface( | ||
configuration, configuration.interfaces[0].interfaceNumber); | ||
let alternateInterface = new USBAlternateInterface( | ||
usbInterface, usbInterface.alternates[1].alternateSetting); | ||
assertDeviceInfoEquals( | ||
alternateInterface, | ||
fakeDeviceInit.configurations[1].interfaces[0].alternates[1]); | ||
}, 'Can construct a USBAlternateInterface.'); | ||
|
||
usb_test(async () => { | ||
let { device } = await getFakeDevice(); | ||
let configuration = new USBConfiguration( | ||
device, device.configurations[1].configurationValue); | ||
let usbInterface = new USBInterface( | ||
configuration, configuration.interfaces[0].interfaceNumber); | ||
try { | ||
let alternateInterface = new USBAlternateInterface( | ||
usbInterface, usbInterface.alternates.length); | ||
assert_unreached( | ||
'USBAlternateInterface should reject an invalid alternate setting'); | ||
} catch (error) { | ||
assert_equals(error.name, 'RangeError'); | ||
} | ||
}, 'Constructing a USBAlternateInterface with an invalid alternate setting ' + | ||
'throws a range error.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// META: script=/webusb/resources/fake-devices.js | ||
// META: script=/webusb/resources/usb-helpers.js | ||
'use strict'; | ||
|
||
usb_test(async () => { | ||
let { device } = await getFakeDevice(); | ||
let configuration = new USBConfiguration( | ||
device, device.configurations[1].configurationValue); | ||
assertDeviceInfoEquals(configuration, fakeDeviceInit.configurations[1]); | ||
}, 'Can construct a USBConfiguration.'); | ||
|
||
usb_test(async () => { | ||
let { device } = await getFakeDevice(); | ||
try { | ||
let configuration = | ||
new USBConfiguration(device, device.configurations.length + 1); | ||
assert_unreached( | ||
'USBConfiguration should reject an invalid configuration value'); | ||
} catch (error) { | ||
assert_equals(error.name, 'RangeError'); | ||
} | ||
}, 'Constructing a USBConfiguration with an invalid configuration value ' + | ||
'throws a range error.'); |
Oops, something went wrong.