How to use claimInterface method in wpt

Best JavaScript code snippet using wpt

usbDevice.https.any.js

Source:usbDevice.https.any.js Github

copy

Full Screen

...83 await device.open();84 return Promise.all([85 device.selectConfiguration(1),86 assertRejectsWithDeviceStateChangeInProgressError(87 device.claimInterface(0)),88 assertRejectsWithDeviceStateChangeInProgressError(89 device.releaseInterface(0)),90 assertRejectsWithDeviceStateChangeInProgressError(device.open()),91 assertRejectsWithDeviceStateChangeInProgressError(92 device.selectConfiguration(1)),93 assertRejectsWithDeviceStateChangeInProgressError(device.reset()),94 assertRejectsWithDeviceStateChangeInProgressError(95 device.selectAlternateInterface(0, 0)),96 assertRejectsWithDeviceStateChangeInProgressError(97 device.controlTransferOut({98 requestType: 'standard',99 recipient: 'interface',100 request: 0x42,101 value: 0x1234,102 index: 0x0000,103 })),104 assertRejectsWithDeviceStateChangeInProgressError(105 device.controlTransferOut({106 requestType: 'standard',107 recipient: 'interface',108 request: 0x42,109 value: 0x1234,110 index: 0x0000,111 }, new Uint8Array([1, 2, 3]))),112 assertRejectsWithDeviceStateChangeInProgressError(113 device.controlTransferIn({114 requestType: 'standard',115 recipient: 'interface',116 request: 0x42,117 value: 0x1234,118 index: 0x0000119 }, 0)),120 assertRejectsWithDeviceStateChangeInProgressError(device.close()),121 ]);122}, 'device operations reject if an device state change is in progress');123usb_test(() => {124 return getFakeDevice().then(({ device, fakeDevice }) => {125 return device.open()126 .then(() => waitForDisconnect(fakeDevice))127 .then(() => assertRejectsWithNotFoundError(device.close()));128 });129}, 'close rejects when called on a disconnected device');130usb_test(() => {131 return getFakeDevice().then(({ device, fakeDevice }) => {132 return device.open()133 .then(() => waitForDisconnect(fakeDevice))134 .then(() => assertRejectsWithNotFoundError(device.selectConfiguration(1)));135 });136}, 'selectConfiguration rejects when called on a disconnected device');137usb_test(() => {138 return getFakeDevice().then(({ device }) => Promise.all([139 assertRejectsWithNotOpenError(device.selectConfiguration(1)),140 assertRejectsWithNotOpenError(device.claimInterface(0)),141 assertRejectsWithNotOpenError(device.releaseInterface(0)),142 assertRejectsWithNotOpenError(device.selectAlternateInterface(0, 1)),143 assertRejectsWithNotOpenError(device.controlTransferIn({144 requestType: 'vendor',145 recipient: 'device',146 request: 0x42,147 value: 0x1234,148 index: 0x5678149 }, 7)),150 assertRejectsWithNotOpenError(device.controlTransferOut({151 requestType: 'vendor',152 recipient: 'device',153 request: 0x42,154 value: 0x1234,155 index: 0x5678156 }, new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]))),157 assertRejectsWithNotOpenError(device.clearHalt('in', 1)),158 assertRejectsWithNotOpenError(device.transferIn(1, 8)),159 assertRejectsWithNotOpenError(160 device.transferOut(1, new ArrayBuffer(8))),161 assertRejectsWithNotOpenError(device.isochronousTransferIn(1, [8])),162 assertRejectsWithNotOpenError(163 device.isochronousTransferOut(1, new ArrayBuffer(8), [8])),164 assertRejectsWithNotOpenError(device.reset())165 ]));166}, 'methods requiring it reject when the device is not open');167usb_test(() => {168 return getFakeDevice().then(({ device }) => {169 assert_equals(device.configuration, null);170 return device.open()171 .then(() => {172 assert_equals(device.configuration, null);173 return device.selectConfiguration(1);174 })175 .then(() => {176 assertDeviceInfoEquals(177 device.configuration, fakeDeviceInit.configurations[0]);178 })179 .then(() => device.close());180 });181}, 'device configuration can be set and queried');182usb_test(async () => {183 let { device } = await getFakeDevice();184 assert_equals(device.configuration, null);185 await device.open();186 assert_equals(device.configuration, null);187 await device.selectConfiguration(1);188 await device.selectConfiguration(1);189 assertDeviceInfoEquals(190 device.configuration, fakeDeviceInit.configurations[0]);191 await device.selectConfiguration(2);192 assertDeviceInfoEquals(193 device.configuration, fakeDeviceInit.configurations[1]);194 await device.close();195}, 'a device configuration value can be set again');196usb_test(() => {197 return getFakeDevice().then(({ device }) => {198 assert_equals(device.configuration, null);199 return device.open()200 .then(() => assertRejectsWithError(201 device.selectConfiguration(3), 'NotFoundError',202 'The configuration value provided is not supported by the device.'))203 .then(() => device.close());204 });205}, 'selectConfiguration rejects on invalid configurations');206usb_test(() => {207 return getFakeDevice().then(({ device }) => {208 assert_equals(device.configuration, null);209 return device.open().then(() => Promise.all([210 assertRejectsWithNotConfiguredError(device.claimInterface(0)),211 assertRejectsWithNotConfiguredError(device.releaseInterface(0)),212 assertRejectsWithNotConfiguredError(device.selectAlternateInterface(0, 1)),213 assertRejectsWithNotConfiguredError(device.controlTransferIn({214 requestType: 'vendor',215 recipient: 'device',216 request: 0x42,217 value: 0x1234,218 index: 0x5678219 }, 7)),220 assertRejectsWithNotConfiguredError(device.controlTransferOut({221 requestType: 'vendor',222 recipient: 'device',223 request: 0x42,224 value: 0x1234,225 index: 0x5678226 }, new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]))),227 assertRejectsWithNotConfiguredError(device.clearHalt('in', 1)),228 assertRejectsWithNotConfiguredError(device.transferIn(1, 8)),229 assertRejectsWithNotConfiguredError(230 device.transferOut(1, new ArrayBuffer(8))),231 assertRejectsWithNotConfiguredError(232 device.isochronousTransferIn(1, [8])),233 assertRejectsWithNotConfiguredError(234 device.isochronousTransferOut(1, new ArrayBuffer(8), [8])),235 ])).then(() => device.close());236 });237}, 'methods requiring it reject when the device is unconfigured');238usb_test(() => {239 return getFakeDevice().then(({ device }) => {240 return device.open()241 .then(() => device.selectConfiguration(1))242 .then(() => device.claimInterface(0))243 .then(() => {244 assert_true(device.configuration.interfaces[0].claimed);245 return device.releaseInterface(0);246 })247 .then(() => {248 assert_false(device.configuration.interfaces[0].claimed);249 return device.close();250 });251 });252}, 'an interface can be claimed and released');253usb_test(async () => {254 let { device } = await getFakeDevice()255 await device.open();256 await device.selectConfiguration(1);257 await device.claimInterface(0);258 assert_true(device.configuration.interfaces[0].claimed);259 await device.claimInterface(0);260 assert_true(device.configuration.interfaces[0].claimed);261 await device.close();262}, 'an interface can be claimed multiple times');263usb_test(async () => {264 let { device } = await getFakeDevice();265 await device.open();266 await device.selectConfiguration(1);267 await device.claimInterface(0);268 assert_true(device.configuration.interfaces[0].claimed);269 await device.releaseInterface(0);270 assert_false(device.configuration.interfaces[0].claimed);271 await device.releaseInterface(0);272 assert_false(device.configuration.interfaces[0].claimed);273 await device.close();274}, 'an interface can be released multiple times');275usb_test(async () => {276 let { device } = await getFakeDevice();277 await device.open();278 await device.selectConfiguration(1);279 return Promise.all([280 device.claimInterface(0),281 assertRejectsWithInterfaceStateChangeInProgressError(282 device.claimInterface(0)),283 assertRejectsWithInterfaceStateChangeInProgressError(284 device.releaseInterface(0)),285 assertRejectsWithInterfaceStateChangeInProgressError(device.open()),286 assertRejectsWithInterfaceStateChangeInProgressError(287 device.selectConfiguration(1)),288 assertRejectsWithInterfaceStateChangeInProgressError(device.reset()),289 assertRejectsWithInterfaceStateChangeInProgressError(290 device.selectAlternateInterface(0, 0)),291 assertRejectsWithInterfaceStateChangeInProgressError(292 device.controlTransferOut({293 requestType: 'standard',294 recipient: 'interface',295 request: 0x42,296 value: 0x1234,297 index: 0x0000,298 })),299 assertRejectsWithInterfaceStateChangeInProgressError(300 device.controlTransferOut({301 requestType: 'standard',302 recipient: 'interface',303 request: 0x42,304 value: 0x1234,305 index: 0x0000,306 }, new Uint8Array([1, 2, 3]))),307 assertRejectsWithInterfaceStateChangeInProgressError(308 device.controlTransferIn({309 requestType: 'standard',310 recipient: 'interface',311 request: 0x42,312 value: 0x1234,313 index: 0x0000314 }, 0)),315 assertRejectsWithInterfaceStateChangeInProgressError(device.close()),316 ]);317}, 'device operations reject if an interface state change is in progress');318usb_test(async () => {319 let { device } = await getFakeDevice();320 await device.open();321 await device.selectConfiguration(1);322 await device.claimInterface(0);323 assert_true(device.configuration.interfaces[0].claimed);324 await device.close(0);325 assert_false(device.configuration.interfaces[0].claimed);326}, 'interfaces are released on close');327usb_test(() => {328 return getFakeDevice().then(({ device }) => {329 const message = 'The interface number provided is not supported by the ' +330 'device in its current configuration.';331 return device.open()332 .then(() => device.selectConfiguration(1))333 .then(() => Promise.all([334 assertRejectsWithError(335 device.claimInterface(2), 'NotFoundError', message),336 assertRejectsWithError(337 device.releaseInterface(2), 'NotFoundError', message),338 ]))339 .then(() => device.close());340 });341}, 'a non-existent interface cannot be claimed or released');342usb_test(() => {343 return getFakeDevice().then(({ device, fakeDevice }) => {344 return device.open()345 .then(() => device.selectConfiguration(1))346 .then(() => waitForDisconnect(fakeDevice))347 .then(() => assertRejectsWithNotFoundError(device.claimInterface(0)));348 });349}, 'claimInterface rejects when called on a disconnected device');350usb_test(() => {351 return getFakeDevice().then(({ device, fakeDevice }) => {352 return device.open()353 .then(() => device.selectConfiguration(1))354 .then(() => device.claimInterface(0))355 .then(() => waitForDisconnect(fakeDevice))356 .then(() => assertRejectsWithNotFoundError(device.releaseInterface(0)));357 });358}, 'releaseInterface rejects when called on a disconnected device');359usb_test(() => {360 return getFakeDevice().then(({ device }) => {361 return device.open()362 .then(() => device.selectConfiguration(2))363 .then(() => device.claimInterface(0))364 .then(() => device.selectAlternateInterface(0, 1))365 .then(() => device.close());366 });367}, 'can select an alternate interface');368usb_test(() => {369 return getFakeDevice().then(({ device }) => {370 return device.open()371 .then(() => device.selectConfiguration(2))372 .then(() => device.claimInterface(0))373 .then(() => assertRejectsWithError(374 device.selectAlternateInterface(0, 2), 'NotFoundError',375 'The alternate setting provided is not supported by the device in ' +376 'its current configuration.'))377 .then(() => device.close());378 });379}, 'cannot select a non-existent alternate interface');380usb_test(() => {381 return getFakeDevice().then(({ device, fakeDevice }) => {382 return device.open()383 .then(() => device.selectConfiguration(2))384 .then(() => device.claimInterface(0))385 .then(() => waitForDisconnect(fakeDevice))386 .then(() => assertRejectsWithNotFoundError(device.selectAlternateInterface(0, 1)));387 });388}, 'selectAlternateInterface rejects when called on a disconnected device');389usb_test(async () => {390 let { device } = await getFakeDevice();391 let usbRequestTypes = ['standard', 'class', 'vendor'];392 let usbRecipients = ['device', 'interface', 'endpoint', 'other'];393 await device.open();394 await device.selectConfiguration(1);395 await device.claimInterface(0);396 await device.selectAlternateInterface(0, 0);397 for (const requestType of usbRequestTypes) {398 for (const recipient of usbRecipients) {399 let index = recipient === 'interface' ? 0x5600 : 0x5681;400 let result = await device.controlTransferIn({401 requestType: requestType,402 recipient: recipient,403 request: 0x42,404 value: 0x1234,405 index: index406 }, 7);407 assert_true(result instanceof USBInTransferResult);408 assert_equals(result.status, 'ok');409 assert_equals(result.data.byteLength, 7);410 assert_equals(result.data.getUint16(0), 0x07);411 assert_equals(result.data.getUint8(2), 0x42);412 assert_equals(result.data.getUint16(3), 0x1234);413 assert_equals(result.data.getUint16(5), index);414 }415 }416 await device.close();417}, 'can issue all types of IN control transfers');418usb_test(() => {419 return getFakeDevice().then(({ device, fakeDevice }) => {420 return device.open()421 .then(() => device.selectConfiguration(1))422 .then(() => waitForDisconnect(fakeDevice))423 .then(() => assertRejectsWithNotFoundError(device.controlTransferIn({424 requestType: 'vendor',425 recipient: 'device',426 request: 0x42,427 value: 0x1234,428 index: 0x5678429 }, 7)));430 });431}, 'controlTransferIn rejects when called on a disconnected device');432usb_test(async () => {433 let { device } = await getFakeDevice();434 let usbRequestTypes = ['standard', 'class', 'vendor'];435 let usbRecipients = ['device', 'interface', 'endpoint', 'other'];436 let dataArray = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);437 let dataTypes = [dataArray, dataArray.buffer];438 await device.open();439 await device.selectConfiguration(1);440 await device.claimInterface(0);441 await device.selectAlternateInterface(0, 0);442 for (const requestType of usbRequestTypes) {443 for (const recipient of usbRecipients) {444 let index = recipient === 'interface' ? 0x5600 : 0x5681;445 let transferParams = {446 requestType: requestType,447 recipient: recipient,448 request: 0x42,449 value: 0x1234,450 index: index451 };452 for (const data of dataTypes) {453 let result = await device.controlTransferOut(transferParams, data);454 assert_true(result instanceof USBOutTransferResult);455 assert_equals(result.status, 'ok');456 assert_equals(result.bytesWritten, 8);457 }458 let result = await device.controlTransferOut(transferParams);459 assert_true(result instanceof USBOutTransferResult);460 assert_equals(result.status, 'ok');461 }462 }463 await device.close();464}, 'can issue all types of OUT control transfers');465usb_test(() => {466 return getFakeDevice().then(({ device, fakeDevice }) => {467 return device.open()468 .then(() => device.selectConfiguration(1))469 .then(() => waitForDisconnect(fakeDevice))470 .then(() => assertRejectsWithNotFoundError(device.controlTransferOut({471 requestType: 'vendor',472 recipient: 'device',473 request: 0x42,474 value: 0x1234,475 index: 0x5678476 }, new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]))));477 });478}, 'controlTransferOut rejects when called on a disconnected device');479usb_test(async () => {480 let { device } = await getFakeDevice();481 await device.open();482 await device.selectConfiguration(1);483 await device.claimInterface(0);484 assertRejectsWithTypeError(device.controlTransferOut({485 requestType: 'invalid',486 recipient: 'device',487 request: 0x42,488 value: 0x1234,489 index: 0x5678490 }, new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])));491 assertRejectsWithTypeError(device.controlTransferIn({492 requestType: 'invalid',493 recipient: 'device',494 request: 0x42,495 value: 0x1234,496 index: 0x5678497 }, 0));498 await device.close();499}, 'control transfers with a invalid request type reject');500usb_test(async () => {501 let { device } = await getFakeDevice();502 await device.open();503 await device.selectConfiguration(1);504 await device.claimInterface(0);505 assertRejectsWithTypeError(device.controlTransferOut({506 requestType: 'vendor',507 recipient: 'invalid',508 request: 0x42,509 value: 0x1234,510 index: 0x5678511 }, new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])));512 assertRejectsWithTypeError(device.controlTransferIn({513 requestType: 'vendor',514 recipient: 'invalid',515 request: 0x42,516 value: 0x1234,517 index: 0x5678518 }, 0));519}, 'control transfers with a invalid recipient type reject');520usb_test(async () => {521 let { device } = await getFakeDevice();522 await device.open();523 await device.selectConfiguration(1);524 await device.claimInterface(0);525 assertRejectsWithNotFoundError(device.controlTransferOut({526 requestType: 'vendor',527 recipient: 'interface',528 request: 0x42,529 value: 0x1234,530 index: 0x0002 // Last byte of index is interface number.531 }, new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])));532 assertRejectsWithNotFoundError(device.controlTransferIn({533 requestType: 'vendor',534 recipient: 'interface',535 request: 0x42,536 value: 0x1234,537 index: 0x0002 // Last byte of index is interface number.538 }, 0));539}, 'control transfers to a non-existant interface reject');540usb_test(() => {541 return getFakeDevice().then(({ device }) => {542 let interfaceRequest = {543 requestType: 'vendor',544 recipient: 'interface',545 request: 0x42,546 value: 0x1234,547 index: 0x5600 // Last byte of index is interface number.548 };549 let endpointRequest = {550 requestType: 'vendor',551 recipient: 'endpoint',552 request: 0x42,553 value: 0x1234,554 index: 0x5681 // Last byte of index is endpoint address.555 };556 let data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);557 return device.open()558 .then(() => device.selectConfiguration(1))559 .then(() => Promise.all([560 assertRejectsWithError(561 device.controlTransferIn(interfaceRequest, 7),562 'InvalidStateError'),563 assertRejectsWithError(564 device.controlTransferIn(endpointRequest, 7),565 'NotFoundError'),566 assertRejectsWithError(567 device.controlTransferOut(interfaceRequest, data),568 'InvalidStateError'),569 assertRejectsWithError(570 device.controlTransferOut(endpointRequest, data),571 'NotFoundError'),572 ]))573 .then(() => device.claimInterface(0))574 .then(() => Promise.all([575 device.controlTransferIn(interfaceRequest, 7).then(result => {576 assert_true(result instanceof USBInTransferResult);577 assert_equals(result.status, 'ok');578 assert_equals(result.data.byteLength, 7);579 assert_equals(result.data.getUint16(0), 0x07);580 assert_equals(result.data.getUint8(2), 0x42);581 assert_equals(result.data.getUint16(3), 0x1234);582 assert_equals(result.data.getUint16(5), 0x5600);583 }),584 device.controlTransferIn(endpointRequest, 7).then(result => {585 assert_true(result instanceof USBInTransferResult);586 assert_equals(result.status, 'ok');587 assert_equals(result.data.byteLength, 7);588 assert_equals(result.data.getUint16(0), 0x07);589 assert_equals(result.data.getUint8(2), 0x42);590 assert_equals(result.data.getUint16(3), 0x1234);591 assert_equals(result.data.getUint16(5), 0x5681);592 }),593 device.controlTransferOut(interfaceRequest, data),594 device.controlTransferOut(endpointRequest, data),595 ]))596 .then(() => device.close());597 });598}, 'requests to interfaces and endpoint require an interface claim');599usb_test(() => {600 return getFakeDevice().then(({ device }) => {601 return device.open()602 .then(() => device.selectConfiguration(1))603 .then(() => device.claimInterface(0))604 .then(() => device.clearHalt('in', 1))605 .then(() => device.close());606 });607}, 'can clear a halt condition');608usb_test(() => {609 return getFakeDevice().then(({ device, fakeDevice }) => {610 return device.open()611 .then(() => device.selectConfiguration(1))612 .then(() => device.claimInterface(0))613 .then(() => waitForDisconnect(fakeDevice))614 .then(() => assertRejectsWithNotFoundError(device.clearHalt('in', 1)));615 });616}, 'clearHalt rejects when called on a disconnected device');617usb_test(() => {618 return getFakeDevice().then(({ device }) => {619 let data = new DataView(new ArrayBuffer(1024));620 for (let i = 0; i < 1024; ++i)621 data.setUint8(i, i & 0xff);622 const notFoundMessage = 'The specified endpoint is not part of a claimed ' +623 'and selected alternate interface.';624 const rangeError = 'The specified endpoint number is out of range.';625 return device.open()626 .then(() => device.selectConfiguration(1))627 .then(() => device.claimInterface(0))628 .then(() => Promise.all([629 assertRejectsWithError(device.transferIn(2, 8),630 'NotFoundError', notFoundMessage), // Unclaimed631 assertRejectsWithError(device.transferIn(3, 8), 'NotFoundError',632 notFoundMessage), // Non-existent633 assertRejectsWithError(634 device.transferIn(16, 8), 'IndexSizeError', rangeError),635 assertRejectsWithError(device.transferOut(2, data),636 'NotFoundError', notFoundMessage), // Unclaimed637 assertRejectsWithError(device.transferOut(3, data), 'NotFoundError',638 notFoundMessage), // Non-existent639 assertRejectsWithError(640 device.transferOut(16, data), 'IndexSizeError', rangeError),641 ]));642 });643}, 'transfers to unavailable endpoints are rejected');644usb_test(() => {645 return getFakeDevice().then(({ device }) => {646 return device.open()647 .then(() => device.selectConfiguration(1))648 .then(() => device.claimInterface(0))649 .then(() => device.transferIn(1, 8))650 .then(result => {651 assert_true(result instanceof USBInTransferResult);652 assert_equals(result.status, 'ok');653 assert_equals(result.data.byteLength, 8);654 for (let i = 0; i < 8; ++i)655 assert_equals(result.data.getUint8(i), i, 'mismatch at byte ' + i);656 return device.close();657 });658 });659}, 'can issue IN interrupt transfer');660usb_test(() => {661 return getFakeDevice().then(({ device }) => {662 return device.open()663 .then(() => device.selectConfiguration(1))664 .then(() => device.claimInterface(1))665 .then(() => device.transferIn(2, 1024))666 .then(result => {667 assert_true(result instanceof USBInTransferResult);668 assert_equals(result.status, 'ok');669 assert_equals(result.data.byteLength, 1024);670 for (let i = 0; i < 1024; ++i)671 assert_equals(result.data.getUint8(i), i & 0xff,672 'mismatch at byte ' + i);673 return device.close();674 });675 });676}, 'can issue IN bulk transfer');677usb_test(() => {678 return getFakeDevice().then(({ device, fakeDevice }) => {679 return device.open()680 .then(() => device.selectConfiguration(1))681 .then(() => device.claimInterface(1))682 .then(() => waitForDisconnect(fakeDevice))683 .then(() => assertRejectsWithNotFoundError(device.transferIn(2, 1024)));684 });685}, 'transferIn rejects if called on a disconnected device');686usb_test(() => {687 return getFakeDevice().then(({ device }) => {688 return device.open()689 .then(() => device.selectConfiguration(1))690 .then(() => device.claimInterface(1))691 .then(() => {692 let data = new DataView(new ArrayBuffer(1024));693 for (let i = 0; i < 1024; ++i)694 data.setUint8(i, i & 0xff);695 return device.transferOut(2, data);696 })697 .then(result => {698 assert_true(result instanceof USBOutTransferResult);699 assert_equals(result.status, 'ok');700 assert_equals(result.bytesWritten, 1024);701 return device.close();702 });703 });704}, 'can issue OUT bulk transfer');705usb_test(() => {706 return getFakeDevice().then(({ device, fakeDevice }) => {707 return device.open()708 .then(() => device.selectConfiguration(1))709 .then(() => device.claimInterface(1))710 .then(() => {711 let data = new DataView(new ArrayBuffer(1024));712 for (let i = 0; i < 1024; ++i)713 data.setUint8(i, i & 0xff);714 return waitForDisconnect(fakeDevice)715 .then(() => assertRejectsWithNotFoundError(device.transferOut(2, data)));716 });717 });718}, 'transferOut rejects if called on a disconnected device');719usb_test(() => {720 return getFakeDevice().then(({ device }) => {721 return device.open()722 .then(() => device.selectConfiguration(2))723 .then(() => device.claimInterface(0))724 .then(() => device.selectAlternateInterface(0, 1))725 .then(() => device.isochronousTransferIn(726 1, [64, 64, 64, 64, 64, 64, 64, 64]))727 .then(result => {728 assert_true(result instanceof USBIsochronousInTransferResult);729 assert_equals(result.data.byteLength, 64 * 8, 'buffer size');730 assert_equals(result.packets.length, 8, 'number of packets');731 let byteOffset = 0;732 for (let i = 0; i < result.packets.length; ++i) {733 assert_true(734 result.packets[i] instanceof USBIsochronousInTransferPacket);735 assert_equals(result.packets[i].status, 'ok');736 assert_equals(result.packets[i].data.byteLength, 64);737 assert_equals(result.packets[i].data.buffer, result.data.buffer);738 assert_equals(result.packets[i].data.byteOffset, byteOffset);739 for (let j = 0; j < 64; ++j)740 assert_equals(result.packets[i].data.getUint8(j), j & 0xff,741 'mismatch at byte ' + j + ' of packet ' + i);742 byteOffset += result.packets[i].data.byteLength;743 }744 return device.close();745 });746 });747}, 'can issue IN isochronous transfer');748usb_test(() => {749 return getFakeDevice().then(({ device, fakeDevice }) => {750 return device.open()751 .then(() => device.selectConfiguration(2))752 .then(() => device.claimInterface(0))753 .then(() => device.selectAlternateInterface(0, 1))754 .then(() => waitForDisconnect(fakeDevice))755 .then(() => assertRejectsWithNotFoundError(device.isochronousTransferIn(756 1, [64, 64, 64, 64, 64, 64, 64, 64])));757 });758}, 'isochronousTransferIn rejects when called on a disconnected device');759usb_test(() => {760 return getFakeDevice().then(({ device }) => {761 return device.open()762 .then(() => device.selectConfiguration(2))763 .then(() => device.claimInterface(0))764 .then(() => device.selectAlternateInterface(0, 1))765 .then(() => {766 let data = new DataView(new ArrayBuffer(64 * 8));767 for (let i = 0; i < 8; ++i) {768 for (let j = 0; j < 64; ++j)769 data.setUint8(i * j, j & 0xff);770 }771 return device.isochronousTransferOut(772 1, data, [64, 64, 64, 64, 64, 64, 64, 64]);773 })774 .then(result => {775 assert_true(result instanceof USBIsochronousOutTransferResult);776 assert_equals(result.packets.length, 8, 'number of packets');777 let byteOffset = 0;778 for (let i = 0; i < result.packets.length; ++i) {779 assert_true(780 result.packets[i] instanceof USBIsochronousOutTransferPacket);781 assert_equals(result.packets[i].status, 'ok');782 assert_equals(result.packets[i].bytesWritten, 64);783 }784 return device.close();785 });786 });787}, 'can issue OUT isochronous transfer');788usb_test(() => {789 return getFakeDevice().then(({ device, fakeDevice }) => {790 return device.open()791 .then(() => device.selectConfiguration(2))792 .then(() => device.claimInterface(0))793 .then(() => device.selectAlternateInterface(0, 1))794 .then(() => {795 let data = new DataView(new ArrayBuffer(64 * 8));796 for (let i = 0; i < 8; ++i) {797 for (let j = 0; j < 64; ++j)798 data.setUint8(i * j, j & 0xff);799 }800 return waitForDisconnect(fakeDevice)801 .then(() => assertRejectsWithNotFoundError(device.isochronousTransferOut(802 1, data, [64, 64, 64, 64, 64, 64, 64, 64])));803 });804 });805}, 'isochronousTransferOut rejects when called on a disconnected device');806usb_test(() => {...

Full Screen

Full Screen

admin-home.component.ts

Source:admin-home.component.ts Github

copy

Full Screen

1import { Component, OnInit, OnDestroy } from '@angular/core';2import { AdminFnService } from "../../shared/services/admin-fn.service"3import { claimInterface } from "../../shared/interfaces/interfaces"4import 'rxjs/add/operator/takeUntil';5import { Subject } from 'rxjs/Subject';6@Component({7 selector: 'app-admin-home',8 templateUrl: './admin-home.component.html',9 styleUrls: ['./admin-home.component.sass']10})11export class AdminHomeComponent implements OnInit, OnDestroy {12 private ngUnsubscribe: Subject<void> = new Subject<void>();13 //pending to change typing14 public Pending: Array<claimInterface> = [];15 public ClaimCompany: Array<claimInterface> = [];16 public PendingClaimAdmin: Array<claimInterface> = [];17 public ClaimAdmin1: Array<claimInterface> = [];18 public ClaimAdmin2: Array<claimInterface> = [];19 public WaitingPayment1: Array<claimInterface> = [];20 public WaitingPayment2: Array<claimInterface> = [];21 public Court: Array<claimInterface> = [];22 public CourtPayment: Array<claimInterface> = [];23 public PaymentReceived: Array<claimInterface> = [];24 public PaymentDone: Array<claimInterface> = [];25 public Rejected: Array<claimInterface> = [];26 public Abandoned: Array<claimInterface> = [];27 private claimId: string;28 private statusForm: object;29 private list: Array<claimInterface>;30 constructor(31 private adminService: AdminFnService32 ) {}33 ngOnInit(): void {34 this.getAllClaims();35 }36 getAllClaims(): void {37 this.adminService.list()38 .takeUntil(this.ngUnsubscribe)39 .subscribe(claims => {40 this.Pending = [];41 this.ClaimCompany = [];42 this.PendingClaimAdmin = [];43 this.ClaimAdmin1 = [];44 this.ClaimAdmin2 = [];45 this.WaitingPayment1 = [];46 this.WaitingPayment2 = [];47 this.Court = [];48 this.CourtPayment = [];49 this.PaymentReceived = [];50 this.PaymentDone = [];51 this.Rejected = [];52 this.Abandoned = [];53 this.list = claims;54 this.filterLists(claims)55 })56 }57 ngOnDestroy(): void {58 this.ngUnsubscribe.next();59 this.ngUnsubscribe.complete();60 }61 filterLists(list: Array<claimInterface>): void {62 list.forEach((e) => {63 switch (e.status) {64 case "Pending":65 this.Pending.push(e)66 break;67 case "ClaimCompany":68 this.ClaimCompany.push(e)69 break;70 case "PendingClaimAdmin":71 this.PendingClaimAdmin.push(e)72 break;73 case "ClaimAdmin1":74 this.ClaimAdmin1.push(e)75 break;76 case "ClaimAdmin2":77 this.ClaimAdmin2.push(e)78 break;79 case "WaitingPayment1":80 this.WaitingPayment1.push(e)81 break;82 case "WaitingPayment2":83 this.WaitingPayment2.push(e)84 break;85 case "Court":86 this.Court.push(e)87 break;88 case "CourtPayment":89 this.CourtPayment.push(e)90 break;91 case "PaymentReceived":92 this.PaymentReceived.push(e)93 break;94 case "PaymentDone":95 this.PaymentDone.push(e)96 break;97 case "Rejected":98 this.Rejected.push(e)99 break;100 case "Abandoned":101 this.Abandoned.push(e)102 break;103 }104 })105 }106 updateStatus(claimId: string, event: any): void {107 this.statusForm = { claimId, status: event.target.value }108 this.adminService.updateStatus(this.statusForm)109 .takeUntil(this.ngUnsubscribe)110 .subscribe(response => this.getAllClaims())111 }...

Full Screen

Full Screen

types.ts

Source:types.ts Github

copy

Full Screen

1export type ContextEntry = string | { [key: string]: ContextEntry }2export type ClaimInterface = {3 [key: string]: string | number | boolean | ClaimInterface | ClaimInterface[]4}5export interface BaseMetadata {6 type: string[]7 name: string8 context?: ContextEntry[]9 claimInterface?: ClaimInterface10}11export interface EmailClaimMetadata extends BaseMetadata {12 claimInterface?: {13 email: string14 }15}16export interface MobilePhoneNumberClaimMetadata extends BaseMetadata {17 claimInterface?: {18 telephone: string19 }20}21export interface NameClaimMetadata extends BaseMetadata {22 claimInterface?: {23 givenName: string24 familyName: string25 }26}27export interface PublicProfileClaimMetadata extends BaseMetadata {28 claimInterface?: {29 name: string30 description: string31 image?: string32 url?: string33 }34}35export interface PostalAddressClaimMetadata extends BaseMetadata {36 claimInterface?: {37 addressLine1: "schema:streetAddress",38 addressLine2?: "schema:streetAddress",39 postalCode: "schema:postalCode",40 city: "schema:addressLocality",41 country: "schema:addressCountry"42 }43}44export interface ClaimsMetadataSummary {45 emailAddress: EmailClaimMetadata46 mobilePhoneNumber: MobilePhoneNumberClaimMetadata47 name: NameClaimMetadata48 publicProfile: PublicProfileClaimMetadata49 postalAddress: PostalAddressClaimMetadata...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.claimInterface().then(function(result){2 console.log(result);3});4wpt.claimInterface().then(function(result){5 console.log(result);6});7wpt.claimInterface().then(function(result){8 console.log(result);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('webpagetest');2const client = wpt('your api key');3}, (err, data) => {4 if (err) {5 console.log('Error: ', err);6 } else {7 console.log('Data: ', data);8 }9});10const wpt = require('webpagetest');11const client = wpt('your api key');12}, (err, data) => {13 if (err) {14 console.log('Error: ', err);15 } else {16 console.log('Data: ', data);17 }18});19const wpt = require('webpagetest');20const client = wpt('your api key');21}, (err, data) => {22 if (err) {23 console.log('Error: ', err);24 } else {25 console.log('Data: ', data);26 }27});28const wpt = require('webpagetest');29const client = wpt('your api key');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.claimInterface('test', (err, data) => {4 if(err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12wpt.claimInterface('test', (err, data) => {13 if(err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.claimInterface('test', (err, data) => {22 if(err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var wpt = require('webpagetest');29var wpt = new WebPageTest('www.webpagetest.org');30wpt.claimInterface('test', (err, data) => {31 if(err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37var wpt = require('webpagetest');38var wpt = new WebPageTest('www.webpagetest.org');39wpt.claimInterface('test', (err, data) => {40 if(err) {41 console.log(err);42 } else {43 console.log(data);44 }45});46var wpt = require('webpagetest');47var wpt = new WebPageTest('www.webpagetest.org');48wpt.claimInterface('test', (err, data) => {49 if(err) {50 console.log(err);51 } else {52 console.log(data);53 }54});55var wpt = require('webpagetest');56var wpt = new WebPageTest('www.webpagetest.org');57wpt.claimInterface('test', (err, data) => {58 if(err) {59 console.log(err

Full Screen

Using AI Code Generation

copy

Full Screen

1(function() {2var wpt = new WPT();3wpt.claimInterface("test", function() {4 console.log("Claimed interface: test");5});6})();7 window.addEventListener('message', function(e) {8 if (e.data.type == 'test') {9 console.log("Received message from test.js: " + e.data.msg);10 }11 });12wpt.sendInterfaceMessage("test", "Hello from test.js");

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wptClient = new wpt('www.webpagetest.org');3var interface = wptClient.claimInterface('test');4interface.sendMessage('test message');5interface.sendMessage('test message 2');6interface.sendMessage('test message 3');7interface.sendMessage('test message 4');8interface.sendMessage('test message 5');9interface.sendMessage('test message 6');10interface.sendMessage('test message 7');11interface.sendMessage('test message 8');12interface.sendMessage('test message 9');13interface.sendMessage('test message 10');14interface.sendMessage('test message 11');15interface.sendMessage('test message 12');16interface.sendMessage('test message 13');17interface.sendMessage('test message 14');18interface.sendMessage('test message 15');19interface.sendMessage('test message 16');20interface.sendMessage('test message 17');21interface.sendMessage('test message 18');22interface.sendMessage('test message 19');23interface.sendMessage('test message 20');24interface.sendMessage('test message 21');25interface.sendMessage('test message 22');26interface.sendMessage('test message 23');27interface.sendMessage('test message 24');28interface.sendMessage('test message 25');29interface.sendMessage('test message 26');30interface.sendMessage('test message 27');31interface.sendMessage('test message 28');32interface.sendMessage('test message 29');33interface.sendMessage('test message 30');34interface.sendMessage('test message 31');35interface.sendMessage('test message 32');36interface.sendMessage('test message 33');37interface.sendMessage('test message 34');38interface.sendMessage('test message 35');39interface.sendMessage('test message 36');40interface.sendMessage('test message 37');41interface.sendMessage('test message 38');42interface.sendMessage('test message 39');43interface.sendMessage('test message 40');44interface.sendMessage('test message 41');45interface.sendMessage('test message 42');46interface.sendMessage('test message 43');47interface.sendMessage('test message 44');48interface.sendMessage('test message 45');49interface.sendMessage('test message 46');50interface.sendMessage('test message 47');51interface.sendMessage('test message 48');52interface.sendMessage('test message 49');53interface.sendMessage('test message 50');54interface.sendMessage('test message 51');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful