1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var device_from_user = undefined;
7 chrome.test.runWithUserGesture(function() {
8 chrome.usb.getDevices({}, function(devices) {
9 chrome.test.assertEq(0, devices.length);
10 chrome.usb.getUserSelectedDevices({ multiple: false }, function(devices) {
11 chrome.test.assertEq(1, devices.length);
12 device_from_user = devices[0];
13 chrome.usb.openDevice(device_from_user, function(connection) {
14 chrome.usb.closeDevice(connection);
15 chrome.test.sendMessage("opened_device");
21 chrome.usb.onDeviceRemoved.addListener(function(device) {
22 if (device.device == device_from_user.device) {
23 chrome.test.sendMessage("success");
25 chrome.test.sendMessage("failure");