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

Unified Diff: chrome/test/data/extensions/api_test/usb/reset_device/test.js

Issue 22914023: Introducing chrome.usb.getDevices/openDevice API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-interface
Patch Set: Fixes 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/usb/reset_device/test.js
diff --git a/chrome/test/data/extensions/api_test/usb/reset_device/test.js b/chrome/test/data/extensions/api_test/usb/reset_device/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..a0e1728a1d068575c9c2b2c153b4d8484fbc5e85
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/usb/reset_device/test.js
@@ -0,0 +1,35 @@
+// 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;
+
+function resetDevice() {
+ usb.findDevices({vendorId: 0, productId: 0}, function(devices) {
+ usb.resetDevice(devices[0], function(result) {
+ chrome.test.assertEq(result, true);
+ // Ensure the device is still open.
+ var transfer = {
+ direction: "out",
+ endpoint: 2,
+ data: new ArrayBuffer(1)
+ };
+ usb.interruptTransfer(devices[0], transfer, function(result) {
+ // This is designed to fail.
+ usb.resetDevice(devices[0], function(result) {
+ chrome.test.assertEq(result, false);
+ usb.interruptTransfer(devices[0], transfer, function(result) {
+ chrome.test.assertEq(result, undefined);
+ chrome.test.assertEq(
+ chrome.runtime.lastError && chrome.runtime.lastError.message,
+ 'No such device.'
+ );
+ chrome.test.succeed();
+ });
+ });
+ });
+ });
+ });
+}
+
+chrome.test.runTests([resetDevice]);

Powered by Google App Engine
This is Rietveld 408576698