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

Unified Diff: chrome/test/data/extensions/api_test/usb_manual/list_interfaces/test.js

Issue 12471013: Add chrome.usb.listInterfaces API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed "RemoveUsbDeviceResource" call and rebased Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/usb_manual/list_interfaces/test.js
diff --git a/chrome/test/data/extensions/api_test/usb_manual/list_interfaces/test.js b/chrome/test/data/extensions/api_test/usb_manual/list_interfaces/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..f9671a4bb2b6b528c1bca662d742d5119cd25948
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/usb_manual/list_interfaces/test.js
@@ -0,0 +1,45 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var usb = chrome.usb;
+
+var DEVICE_ID = {
+ // Google Nexus S
+ 'vendorId': 6353,
+ 'productId': 20194
+};
+
+var tests = [
+ function listInterfaces() {
+ chrome.permissions.request({
+ permissions: [{'usbDevices': [DEVICE_ID]}]
+ }, function(granted) {
+ if (!granted) {
+ chrome.test.fail('Could not get optional permisson');
+ } else {
+ usb.findDevices(DEVICE_ID, function(devices) {
+ if (typeof devices === 'undefined') {
+ chrome.test.fail('Device optional_permissions seem to be missing');
+ } else {
+ for (var i = 0; i < devices.length; i++) {
+ var device = devices[i];
+ console.log('device: ' + JSON.stringify(device));
+ usb.listInterfaces(device, function(result) {
+ if (typeof result !== 'object') {
+ chrome.test.fail('should be object type. was: '
+ + typeof result);
+ } else {
+ console.log(JSON.stringify(result));
+ chrome.test.succeed();
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ },
+];
+
+chrome.test.runTests(tests);

Powered by Google App Engine
This is Rietveld 408576698