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

Unified Diff: extensions/test/data/api_test/usb/get_user_selected_devices/background.js

Issue 891853002: Add a UsbService::Observer function for cleanup actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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: extensions/test/data/api_test/usb/get_user_selected_devices/background.js
diff --git a/extensions/test/data/api_test/usb/get_user_selected_devices/background.js b/extensions/test/data/api_test/usb/get_user_selected_devices/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..1b4e54ba20f0b0b83a086528f4496ff2afe2d881
--- /dev/null
+++ b/extensions/test/data/api_test/usb/get_user_selected_devices/background.js
@@ -0,0 +1,27 @@
+// Copyright 2015 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 device_from_user = undefined;
+
+chrome.test.runWithUserGesture(function() {
+ chrome.usb.getDevices({}, function(devices) {
+ chrome.test.assertEq(0, devices.length);
+ chrome.usb.getUserSelectedDevices({ multiple: false }, function(devices) {
+ chrome.test.assertEq(1, devices.length);
+ device_from_user = devices[0];
+ chrome.usb.openDevice(device_from_user, function(connection) {
+ chrome.usb.closeDevice(connection);
+ chrome.test.sendMessage("opened_device");
+ });
+ });
+ });
+});
+
+chrome.usb.onDeviceRemoved.addListener(function(device) {
+ if (device.device == device_from_user.device) {
+ chrome.test.sendMessage("success");
+ } else {
+ chrome.test.sendMessage("failure");
+ }
+});
« no previous file with comments | « extensions/browser/api/usb/usb_apitest.cc ('k') | extensions/test/data/api_test/usb/get_user_selected_devices/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698