OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <script src="../resources/testharness.js"></script> | |
3 <script src="../resources/testharnessreport.js"></script> | |
4 <script> | |
5 'use strict'; | |
6 | |
7 | |
8 test(t => { | |
9 let data_view = new DataView(Uint8Array.from([1, 2, 3, 4]).buffer); | |
10 let packet_data_view = new DataView(data_view.buffer); | |
11 let packets = [ | |
12 new USBIsochronousInTransferPacket('ok', packet_data_view), | |
13 new USBIsochronousInTransferPacket('stall') | |
14 ]; | |
15 | |
16 let result = new USBIsochronousInTransferResult(packets, data_view); | |
17 assert_equals(result.data.getInt32(0), 16909060); | |
18 assert_equals(result.packets.length, 2); | |
19 assert_equals(result.packets[0].status, 'ok'); | |
20 assert_equals(result.packets[0].data.getInt32(0), 16909060); | |
21 assert_equals(result.packets[1].status, 'stall'); | |
22 assert_equals(result.packets[1].data, null); | |
23 }, 'Can construct a USBIsochronousInTransferResult'); | |
24 | |
25 test(t => { | |
26 let packets = [ | |
27 new USBIsochronousInTransferPacket('stall'), | |
28 new USBIsochronousInTransferPacket('stall') | |
29 ]; | |
30 let result = new USBIsochronousInTransferResult(packets); | |
31 assert_equals(result.data, null); | |
32 assert_equals(result.packets.length, 2); | |
33 assert_equals(result.packets[0].status, 'stall'); | |
34 assert_equals(result.packets[0].data, null); | |
35 assert_equals(result.packets[1].status, 'stall'); | |
36 assert_equals(result.packets[1].data, null); | |
37 }, 'Can construct a USBIsochronousInTransferResult without a DataView'); | |
38 | |
39 test(t => { | |
40 assert_throws(TypeError(), () => new USBIsochronousInTransferResult()); | |
41 }, 'Cannot construct a USBIsochronousInTransferResult without packets'); | |
42 </script> | |
OLD | NEW |