Chromium Code Reviews| Index: extensions/test/data/api_test/printer_provider/usb_printers/test.js |
| diff --git a/extensions/test/data/api_test/printer_provider/usb_printers/test.js b/extensions/test/data/api_test/printer_provider/usb_printers/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b91a14e6dc767a84ef224d3a5686a01dc44705be |
| --- /dev/null |
| +++ b/extensions/test/data/api_test/printer_provider/usb_printers/test.js |
| @@ -0,0 +1,46 @@ |
| +// 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. |
| + |
| +chrome.test.sendMessage('loaded', function(test) { |
| + chrome.test.runTests([function printTest() { |
| + chrome.printerProvider.onGetPrintersRequested.addListener( |
| + function(callback) { |
| + chrome.test.assertFalse(!!chrome.printerProviderInternal); |
| + chrome.test.assertTrue(!!callback); |
| + |
| + chrome.usb.getDevices({}, function(devices) { |
| + chrome.test.assertNoLastError(); |
| + var printers = []; |
| + for (var device of devices) { |
| + printers.push({ |
| + 'id': 'enumerated-' + device.device, |
| + 'name': 'Test Printer', |
| + 'description': 'This printer is a USB device.', |
| + }); |
| + } |
| + callback(printers); |
| + chrome.test.succeed(); |
| + }); |
| + }); |
| + |
| + chrome.printerProvider.onUsbAccessGranted.addListener( |
| + function(device, callback) { |
| + chrome.test.assertFalse(!!chrome.printerProviderInternal); |
| + chrome.test.assertTrue(!!callback); |
| + |
| + callback({ |
| + '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.
|
| + 'name': 'Test Printer', |
| + 'description': 'This printer is a USB device.', |
| + }); |
| + |
| + chrome.test.assertThrows( |
| + callback, |
| + [], |
| + 'Event callback must not be called more than once.'); |
| + }); |
| + |
| + chrome.test.sendMessage('ready'); |
| + }]); |
| +}); |