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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/webusb/usb-manual.https.html

Issue 2789723003: Migrate WebUSB LayoutTests into external/wpt (Closed)
Patch Set: Addressed comments from ortuno@ and foolip@ Created 3 years, 8 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/external/wpt/webusb/usb-manual.https.html
diff --git a/third_party/WebKit/LayoutTests/usb/usb.html b/third_party/WebKit/LayoutTests/external/wpt/webusb/usb-manual.https.html
similarity index 57%
rename from third_party/WebKit/LayoutTests/usb/usb.html
rename to third_party/WebKit/LayoutTests/external/wpt/webusb/usb-manual.https.html
index 4f2f30da4a6fa98497bb7432a6f06c8ad111ba79..3a20eb76993ac1756804e443d8c6f760b189aaf5 100644
--- a/third_party/WebKit/LayoutTests/usb/usb.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/webusb/usb-manual.https.html
@@ -1,7 +1,6 @@
<!DOCTYPE html>
ortuno 2017/04/06 01:14:06 I don't think the "-manual" suffix pattern will sc
Reilly Grant (use Gerrit) 2017/04/06 01:52:32 I can get away with it in these tests because the
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
-<script src="../resources/mojo-helpers.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
<script src="resources/fake-devices.js"></script>
<script src="resources/usb-helpers.js"></script>
<script>
@@ -20,17 +19,17 @@ function connectionEventPromise(eventType) {
});
}
-usb_test(usb => {
- usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+usb_test(() => {
+ navigator.usb.test.addFakeDevice(fakeDeviceInit);
ortuno 2017/04/06 01:14:06 In the vein of designing our tests APIs in a way t
Reilly Grant (use Gerrit) 2017/04/06 01:52:32 This call doesn't guarantee that anything happens
ortuno 2017/04/06 02:51:47 Interesting, then how do you guarantee that the de
Reilly Grant (use Gerrit) 2017/04/06 06:53:13 Indeed, you're right, if I were really using this
return navigator.usb.getDevices().then(devices => {
assert_equals(devices.length, 1);
- usb.assertDeviceInfoEquals(devices[0], usb.fakeDevices[0]);
+ assertDeviceInfoEquals(devices[0], fakeDeviceInit);
});
}, 'getDevices returns devices exposed by the DeviceManager service');
-usb_test(usb => {
- usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+usb_test(() => {
+ navigator.usb.test.addFakeDevice(fakeDeviceInit);
return navigator.usb.getDevices().then(devicesFirstTime => {
assert_equals(devicesFirstTime.length, 1);
@@ -40,7 +39,7 @@ usb_test(usb => {
});
}, 'getDevices returns the same objects for each USB device');
-usb_test(usb => {
+usb_test(() => {
return navigator.usb.requestDevice({ filters: [] })
.then(device => {
assert_unreachable('requestDevice should reject without a user gesture');
@@ -50,9 +49,8 @@ usb_test(usb => {
});
}, 'requestDevice rejects when called without a user gesture');
-usb_test(usb => {
- usb.mockChooserService.setChosenDevice(null);
- return callWithKeyDown(() => navigator.usb.requestDevice({ filters: [] })
+usb_test(() => {
+ return callWithTrustedClick(() => navigator.usb.requestDevice({ filters: [] })
ortuno 2017/04/06 01:14:06 hmm callWithTrustedClick just adds a button and se
Reilly Grant (use Gerrit) 2017/04/06 01:52:32 I include wpt_automation/fullscreen/auto-click.js
ortuno 2017/04/06 02:51:47 Wow that's so subtle specially since there is nowh
.then(device => {
assert_unreachable('requestDevice should reject when no device selected');
})
@@ -62,20 +60,22 @@ usb_test(usb => {
);
}, 'requestDevice rejects when no device is chosen');
-usb_test(usb => {
- usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
- usb.mockChooserService.setChosenDevice(usb.fakeDevices[0]);
- return callWithKeyDown(() => navigator.usb.requestDevice({ filters: [] })
+usb_test(() => {
+ let guid = navigator.usb.test.addFakeDevice(fakeDeviceInit);
+ navigator.usb.test.chosenDevice = guid;
+
+ return callWithTrustedClick(() => navigator.usb.requestDevice({ filters: [] })
.then(device => {
- usb.assertDeviceInfoEquals(device, usb.fakeDevices[0]);
+ assertDeviceInfoEquals(device, fakeDeviceInit);
})
);
}, 'requestDevice returns the device chosen by the user');
-usb_test(usb => {
- usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
- usb.mockChooserService.setChosenDevice(usb.fakeDevices[0]);
- return callWithKeyDown(() => navigator.usb.requestDevice({ filters: [] })
+usb_test(() => {
+ let guid = navigator.usb.test.addFakeDevice(fakeDeviceInit);
+ navigator.usb.test.chosenDevice = guid;
+
+ return callWithTrustedClick(() => navigator.usb.requestDevice({ filters: [] })
.then(device => navigator.usb.getDevices().then(devices => {
assert_equals(devices.length, 1);
assert_equals(devices[0], device);
@@ -83,51 +83,40 @@ usb_test(usb => {
);
}, 'getDevices returns the same object as requestDevice');
-usb_test(usb => {
+usb_test(() => {
const expectedFilters = [
{ vendorId: 1234, classCode: 0xFF, serialNumber: "123ABC" },
{ vendorId: 5678, productId: 0xF00F }
];
- usb.mockChooserService.setChosenDevice(null);
- return callWithKeyDown(() => navigator.usb.requestDevice({ filters: expectedFilters })
+
+ return callWithTrustedClick(() => navigator.usb.requestDevice({ filters: expectedFilters })
.then(device => {
assert_unreachable('requestDevice should reject because no device selected');
})
.catch(error => {
assert_equals(error.code, DOMException.NOT_FOUND_ERR);
- let actualFilters = usb.mockChooserService.getLastFilters();
+ let actualFilters = navigator.usb.test.lastFilters;
assert_equals(actualFilters.length, expectedFilters.length);
- assert_true(actualFilters[0].has_vendor_id);
- assert_equals(actualFilters[0].vendor_id, expectedFilters[0].vendorId);
- assert_false(actualFilters[0].has_product_id);
- assert_true(actualFilters[0].has_class_code, expectedFilters[0].classCode);
- assert_false(actualFilters[0].has_subclass_code);
- assert_false(actualFilters[0].has_protocol_code);
- assert_equals(actualFilters[0].serial_number, expectedFilters[0].serialNumber);
- assert_true(actualFilters[1].has_vendor_id);
- assert_equals(actualFilters[1].vendor_id, expectedFilters[1].vendorId);
- assert_true(actualFilters[1].has_product_id);
- assert_equals(actualFilters[1].product_id, expectedFilters[1].productId);
- assert_false(actualFilters[1].has_class_code);
- assert_false(actualFilters[1].has_subclass_code);
- assert_false(actualFilters[1].has_protocol_code);
- assert_equals(actualFilters[1].serial_number, null);
+ for (var i = 0; i < actualFilters.length; ++i)
+ assert_object_equals(actualFilters[i], expectedFilters[i]);
})
);
}, 'filters are sent correctly');
-usb_test(usb => {
+usb_test(() => {
let promise = connectionEventPromise('connect');
- usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+ navigator.usb.test.addFakeDevice(fakeDeviceInit);
+
return promise.then(device => {
- usb.assertDeviceInfoEquals(device, usb.fakeDevices[0]);
+ assertDeviceInfoEquals(device, fakeDeviceInit);
return device.open().then(() => device.close());
});
}, 'onconnect event is trigged by adding a device');
usb_test(usb => {
let promise = connectionEventPromise('connect');
- usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+ navigator.usb.test.addFakeDevice(fakeDeviceInit);
+
return promise
.then(device => navigator.usb.getDevices().then(devices => {
assert_equals(devices.length, 1);
@@ -137,12 +126,13 @@ usb_test(usb => {
usb_test(usb => {
let deviceAdded = connectionEventPromise('connect');
- usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
+ let guid = navigator.usb.test.addFakeDevice(fakeDeviceInit);
+
return deviceAdded.then(device => {
let deviceRemoved = connectionEventPromise('disconnect');
- usb.mockDeviceManager.removeMockDevice(usb.fakeDevices[0]);
+ navigator.usb.test.removeFakeDevice(guid);
return deviceRemoved.then(removedDevice => {
- usb.assertDeviceInfoEquals(removedDevice, usb.fakeDevices[0]);
+ assertDeviceInfoEquals(removedDevice, fakeDeviceInit);
assert_equals(removedDevice, device);
return removedDevice.open().then(() => {
assert_unreachable('should not be able to open a disconnected device');

Powered by Google App Engine
This is Rietveld 408576698