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

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

Issue 22914023: Introducing chrome.usb.getDevices/openDevice API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-interface
Patch Set: Created 7 years, 4 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
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 var tests = [ 7 var tests = [
8 function getDevices() {
9 usb.getDevices({vendorId: 0, productId: 0}, function(devices) {
10 console.log(devices);
11 usb.openDevice(devices[0], function(handle){
12 usb.closeDevice(handle);
13 chrome.test.succeed();
14 });
15 });
16 },
8 function explicitCloseDevice() { 17 function explicitCloseDevice() {
9 usb.findDevices({vendorId: 0, productId: 0}, function(devices) { 18 usb.findDevices({vendorId: 0, productId: 0}, function(devices) {
10 usb.closeDevice(devices[0]); 19 usb.closeDevice(devices[0]);
11 chrome.test.succeed(); 20 chrome.test.succeed();
12 }); 21 });
13 }, 22 }
14 function resetDevice() {
15 usb.findDevices({vendorId: 0, productId: 0}, function(devices) {
16 usb.resetDevice(devices[0], function(result) {
17 chrome.test.assertEq(result, true);
18 // Ensure the device is still open.
19 var transfer = {
20 direction: "out",
21 endpoint: 2,
22 data: new ArrayBuffer(1)
23 };
24 usb.interruptTransfer(devices[0], transfer, function(result) {
25 // This is designed to fail.
26 usb.resetDevice(devices[0], function(result) {
27 chrome.test.assertEq(result, false);
28 usb.interruptTransfer(devices[0], transfer, function(result) {
29 chrome.test.assertEq(result, undefined);
30 chrome.test.assertEq(
31 chrome.runtime.lastError && chrome.runtime.lastError.message,
32 'No such device.'
33 );
34 chrome.test.succeed();
35 });
36 });
37 });
38 });
39 });
40 },
41 ]; 23 ];
42 24
43 chrome.test.runTests(tests); 25 chrome.test.runTests(tests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698