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

Unified 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 side-by-side diff with in-line comments
Download patch
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');
+ }]);
+});

Powered by Google App Engine
This is Rietveld 408576698