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

Side by Side Diff: extensions/test/data/api_test/usb/transfer_failure/test.js

Issue 1618393004: Update device/usb and its Mojo interface for variable size ISO packets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document use of ErrorWithArguments. 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 unified diff | Download patch
« no previous file with comments | « extensions/test/data/api_test/usb/transfer_event/test.js ('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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var usb = chrome.usb; 5 var usb = chrome.usb;
6 6
7 function createErrorTest(resultCode, errorMessage) { 7 function createErrorTest(resultCode, errorMessage) {
8 return function() { 8 return function() {
9 usb.findDevices({vendorId: 0, productId: 0}, function(devices) { 9 usb.findDevices({vendorId: 0, productId: 0}, function(devices) {
10 var device = devices[0]; 10 var device = devices[0];
11 var transfer = new Object(); 11 var transfer = new Object();
12 transfer.direction = "out"; 12 transfer.direction = "out";
13 transfer.endpoint = 1; 13 transfer.endpoint = 1;
14 transfer.data = new ArrayBuffer(0); 14 transfer.data = new ArrayBuffer(0);
15 usb.bulkTransfer(device, transfer, function (result) { 15 usb.bulkTransfer(device, transfer, function (result) {
16 if (errorMessage) { 16 if (errorMessage) {
17 chrome.test.assertLastError(errorMessage); 17 chrome.test.assertLastError(errorMessage);
18 } else { 18 } else {
19 chrome.test.assertNoLastError(); 19 chrome.test.assertNoLastError();
20 } 20 }
21 chrome.test.assertTrue(resultCode == result.resultCode); 21 chrome.test.assertTrue(resultCode == result.resultCode);
22 chrome.test.succeed(); 22 chrome.test.succeed();
23 }); 23 });
24 }); 24 });
25 }; 25 };
26 } 26 }
27 27
28 function createIsochronousErrorTest(resultCode, errorMessage) {
29 return function() {
30 usb.findDevices({vendorId: 0, productId: 0}, function(devices) {
31 var device = devices[0];
32 var transfer = {
33 'transferInfo': {
34 'direction': "in",
35 'endpoint': 2,
36 'length': 160
37 },
38 'packets': 10,
39 'packetLength': 16
40 };
41 usb.isochronousTransfer(device, transfer, function (result) {
42 if (errorMessage) {
43 chrome.test.assertLastError(errorMessage);
44 // Device responds with only 8-byte packets and the second half fail.
45 chrome.test.assertTrue(result.data.byteLength == 40);
46 } else {
47 chrome.test.assertNoLastError();
48 // Device responds with a full set of 10 8-byte packets.
49 chrome.test.assertTrue(result.data.byteLength == 80);
50 }
51 chrome.test.assertTrue(resultCode == result.resultCode);
52 chrome.test.succeed();
53 });
54 });
55 };
56 }
57
28 var tests = [ 58 var tests = [
29 createErrorTest(0, undefined), 59 createErrorTest(0, undefined),
30 createErrorTest(1, "Transfer failed."), 60 createErrorTest(1, "Transfer failed."),
31 createErrorTest(2, "Transfer timed out."), 61 createErrorTest(2, "Transfer timed out."),
62 createIsochronousErrorTest(0, undefined),
63 createIsochronousErrorTest(1, "Transfer failed."),
32 ]; 64 ];
33 65
34 chrome.test.runTests(tests); 66 chrome.test.runTests(tests);
OLDNEW
« no previous file with comments | « extensions/test/data/api_test/usb/transfer_event/test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698