| OLD | NEW |
| 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 getDevices() { | 7 function getDevices() { |
| 8 usb.getDevices({ | 8 usb.getDevices({ |
| 9 vendorId: 0, | 9 vendorId: 0, |
| 10 productId: 0 | 10 productId: 0 |
| 11 }, function(devices) { | 11 }, function(devices) { |
| 12 chrome.test.assertEq(1, devices.length); | 12 chrome.test.assertEq(1, devices.length); |
| 13 var device = devices[0]; | 13 var device = devices[0]; |
| 14 chrome.test.assertEq(0x0100, device.version); |
| 14 chrome.test.assertEq("Test Device", device.productName); | 15 chrome.test.assertEq("Test Device", device.productName); |
| 15 chrome.test.assertEq("Test Manufacturer", device.manufacturerName); | 16 chrome.test.assertEq("Test Manufacturer", device.manufacturerName); |
| 16 chrome.test.assertEq("ABC123", device.serialNumber); | 17 chrome.test.assertEq("ABC123", device.serialNumber); |
| 17 usb.openDevice(device, function(handle) { | 18 usb.openDevice(device, function(handle) { |
| 18 chrome.test.assertNoLastError(); | 19 chrome.test.assertNoLastError(); |
| 19 usb.closeDevice(handle); | 20 usb.closeDevice(handle); |
| 20 chrome.test.succeed(); | 21 chrome.test.succeed(); |
| 21 }); | 22 }); |
| 22 }); | 23 }); |
| 23 } | 24 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 44 productId: 0 | 45 productId: 0 |
| 45 }, function(devices) { | 46 }, function(devices) { |
| 46 usb.closeDevice(devices[0]); | 47 usb.closeDevice(devices[0]); |
| 47 chrome.test.succeed(); | 48 chrome.test.succeed(); |
| 48 }); | 49 }); |
| 49 } | 50 } |
| 50 | 51 |
| 51 chrome.test.runTests([ | 52 chrome.test.runTests([ |
| 52 getDevices, getConfigurations, explicitCloseDevice | 53 getDevices, getConfigurations, explicitCloseDevice |
| 53 ]); | 54 ]); |
| OLD | NEW |