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

Side by Side Diff: extensions/test/data/api_test/hid/get_user_selected_devices/background.js

Issue 1115213004: Add chrome.hid.getUserSelectedDevices API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 var device_from_user;
6
7 chrome.test.runWithUserGesture(function() {
8 chrome.hid.getDevices({}, function(devices) {
9 chrome.test.assertNoLastError();
10 chrome.test.assertEq(0, devices.length);
11 chrome.hid.getUserSelectedDevices({ multiple: false }, function(devices) {
12 chrome.test.assertNoLastError();
13 chrome.test.assertEq(1, devices.length);
14 device_from_user = devices[0];
15 chrome.hid.connect(device_from_user.deviceId, function(connection) {
16 chrome.test.assertNoLastError();
17 chrome.hid.disconnect(connection.connectionId);
18 chrome.test.sendMessage("opened_device");
19 });
20 });
21 });
22 });
23
24 chrome.hid.onDeviceRemoved.addListener(function(deviceId) {
25 chrome.test.assertEq(device_from_user.deviceId, deviceId);
26 chrome.test.sendMessage("removed");
27 });
28
29 chrome.hid.onDeviceAdded.addListener(function(device) {
30 chrome.test.assertTrue(device_from_user.deviceId != device.deviceId);
31 chrome.test.assertEq(device_from_user.vendorId, device.vendorId);
32 chrome.test.assertEq(device_from_user.productId, device.productId);
33 chrome.test.sendMessage("added");
34 });
OLDNEW
« no previous file with comments | « extensions/common/api/hid.idl ('k') | extensions/test/data/api_test/hid/get_user_selected_devices/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698