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

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

Issue 1726943002: First set of WebUSB layout tests with Mojo service mocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mojo-helpers.js's define function. 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..9d0fbc56d9e432d4fec62667413ad016cb09e3ca
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/usb/usb.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/device.mojom.js"></script>
+<script src="resources/device_manager.mojom.js"></script>
+<script src="resources/permission_provider.mojom.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 => {
+ 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