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

Unified Diff: third_party/WebKit/LayoutTests/usb/usb.html

Issue 1730403006: Basic layout tests for WebUSB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mojo tests that depend on extra module loading. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/usb/usb.html
diff --git a/third_party/WebKit/LayoutTests/usb/usb.html b/third_party/WebKit/LayoutTests/usb/usb.html
new file mode 100644
index 0000000000000000000000000000000000000000..4a2ca697eca0d95114dfbdaea326d1210136fe56
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/usb/usb.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/fake-devices.js"></script>
+<script src="resources/usb-helpers.js"></script>
+<script>
+'use strict';
+
+usb_test(usb => {
+ usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+
+ return navigator.usb.getDevices().then(devices => {
+ assert_equals(devices.length, 1);
+ usb.assertDeviceInfoEquals(devices[0], usb.fakeDevices[0]);
+ });
+}, 'getDevices returns devices exposed by the DeviceManager service.');
+
+usb_test(usb => {
+ return callWithKeyDown(() => navigator.usb.requestDevice({ filters: [] })
+ .then(device => {
+ assert_unreachable('requestDevice should reject when no device selected');
+ })
+ .catch(error => {
+ assert_equals(error.code, DOMException.NOT_FOUND_ERR);
+ return Promise.resolve();
+ })
+ );
+}, 'requestDevice rejects when no device is chosen');
+
+usb_test(usb => {
+ usb.mockPermissionBubble.setChosenDevice(usb.fakeDevices[0]);
+ return callWithKeyDown(() => navigator.usb.requestDevice({ filters: [] })
+ .then(device => {
+ usb.assertDeviceInfoEquals(device, usb.fakeDevices[0]);
+ })
+ );
+}, 'requestDevice returns the device chosen by the user');
+
+usb_test(usb => {
+ let promise = new Promise((resolve, reject) => {
+ navigator.usb.addEventListener('connect', e => {
+ usb.assertDeviceInfoEquals(e.device, usb.fakeDevices[0]);
+ resolve();
+ });
+ });
+
+ usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+ return promise;
+}, 'onconnect event is trigged by adding a device');
+
+usb_test(usb => {
+ let promise = new Promise((resolve, reject) => {
+ navigator.usb.addEventListener('disconnect', e => {
+ usb.assertDeviceInfoEquals(e.device, usb.fakeDevices[0]);
+ resolve();
+ });
+ });
+
+ usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+ usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]);
+ return promise;
+}, 'ondisconnect event is triggered by removing a device');
+</script>
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js ('k') | third_party/WebKit/LayoutTests/usb/usbDevice.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698