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

Side by Side Diff: extensions/test/data/api_test/printer_provider/usb_printers/test.js

Issue 1148383002: Add onGetUsbPrinterInfoRequested event to printerProvider API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only include the permission granting part in this patch. Created 5 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 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 chrome.test.sendMessage('loaded', function(test) {
6 chrome.test.runTests([function printTest() {
7 chrome.printerProvider.onGetPrintersRequested.addListener(
8 function(callback) {
9 chrome.test.assertFalse(!!chrome.printerProviderInternal);
10 chrome.test.assertTrue(!!callback);
11
12 chrome.usb.getDevices({}, function(devices) {
13 chrome.test.assertNoLastError();
14 var printers = [];
15 for (var device of devices) {
16 printers.push({
17 'id': 'enumerated-' + device.device,
18 'name': 'Test Printer',
19 'description': 'This printer is a USB device.',
20 });
21 }
22 callback(printers);
23 chrome.test.succeed();
24 });
25 });
26
27 chrome.printerProvider.onUsbAccessGranted.addListener(
28 function(device, callback) {
29 chrome.test.assertFalse(!!chrome.printerProviderInternal);
30 chrome.test.assertTrue(!!callback);
31
32 callback({
33 'id': 'granted-' + device.device,
tbarzic 2015/05/27 00:11:03 generally, destinations for a printer returned by
Reilly Grant (use Gerrit) 2015/05/28 21:04:10 Done.
34 'name': 'Test Printer',
35 'description': 'This printer is a USB device.',
36 });
37
38 chrome.test.assertThrows(
39 callback,
40 [],
41 'Event callback must not be called more than once.');
42 });
43
44 chrome.test.sendMessage('ready');
45 }]);
46 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698