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

Side by Side Diff: third_party/WebKit/LayoutTests/usb/usbDevice.html

Issue 1734753003: Revert of First set of WebUSB layout tests with Mojo service mocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/usb.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/device.mojom.js"></script>
6 <script src="resources/device_manager.mojom.js"></script>
7 <script src="resources/permission_provider.mojom.js"></script>
8 <script src="resources/fake-devices.js"></script>
9 <script src="resources/usb-helpers.js"></script>
10 <script>
11 'use strict';
12
13 usb_test(usb => {
14 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
15 return navigator.usb.getDevices().then(devices => {
16 assert_equals(devices.length, 1);
17 let device = devices[0];
18 return device.open().then(() => device.close());
19 });
20 }, 'a device can be opened and closed');
21
22 usb_test(usb => {
23 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
24 return navigator.usb.getDevices().then(devices => {
25 assert_equals(devices.length, 1);
26 let device = devices[0];
27 return device.open()
28 .then(() => device.setConfiguration(1))
29 .then(() => device.getConfiguration())
30 .then(config => {
31 usb.assertConfigurationInfoEquals(
32 config, usb.fakeDevices[0].configurations[0]);
33 })
34 .then(() => device.close());
35 });
36 }, 'device configuration can be set and queried');
37
38 usb_test(usb => {
39 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
40 return navigator.usb.getDevices().then(devices => {
41 assert_equals(devices.length, 1);
42 let device = devices[0];
43 return device.open()
44 .then(() => device.getConfiguration()
45 .then(() => {
46 assert_true(false, 'getConfiguration should reject');
47 })
48 .catch(error => {
49 assert_equals(error.code, DOMException.NOT_FOUND_ERR);
50 return Promise.resolve();
51 }))
52 .then(() => device.close());
53 });
54 }, 'querying an unset configuration raises NotFoundError');
55
56 usb_test(usb => {
57 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
58 return navigator.usb.getDevices().then(devices => {
59 assert_equals(devices.length, 1);
60 let device = devices[0];
61 return device.open()
62 .then(() => device.setConfiguration(1))
63 .then(() => device.claimInterface(0))
64 .then(() => device.releaseInterface(0))
65 .then(() => device.close());
66 });
67 }, 'an interface can be claimed and released');
68
69 usb_test(usb => {
70 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
71 return navigator.usb.getDevices().then(devices => {
72 assert_equals(devices.length, 1);
73 let device = devices[0];
74 return device.open()
75 .then(() => device.setConfiguration(2))
76 .then(() => device.claimInterface(0))
77 .then(() => device.setInterface(0, 1))
78 .then(() => device.close());
79 });
80 }, 'can select an alternate interface');
81
82 usb_test(usb => {
83 usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
84 return navigator.usb.getDevices().then(devices => {
85 assert_equals(devices.length, 1);
86 let device = devices[0];
87 return device.open()
88 .then(() => device.controlTransferIn({
89 requestType: "vendor",
90 recipient: "device",
91 request: 0x42,
92 value: 0x1234,
93 index: 0x5678
94 }, 7))
95 .then(result => {
96 assert_equals("ok", result.status);
97 assert_equals(7, result.data.byteLength);
98 assert_equals(0x07, result.data.getUint16(0));
99 assert_equals(0x42, result.data.getUint8(2));
100 assert_equals(0x1234, result.data.getUint16(3));
101 assert_equals(0x5678, result.data.getUint16(5));
102 });
103 });
104 }, 'can issue IN control transfer');
105 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/usb.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698