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 chrome.test.sendMessage('loaded', function(test) {
6 chrome.test.runTests([function printTest() {
7 if (test == 'NO_LISTENER') {
8 chrome.test.sendMessage('ready');
13 chrome.printerProvider.onGetPrintersRequested.addListener(
15 chrome.test.assertFalse(!!chrome.printerProviderInternal);
16 chrome.test.assertTrue(!!callback);
18 if (test == 'ASYNC_RESPONSE') {
19 setTimeout(callback.bind(null, [{
22 description: 'Test printer',
24 chrome.test.succeed();
28 if (test == 'IGNORE_CALLBACK') {
29 chrome.test.succeed();
33 if (test == 'NOT_ARRAY') {
34 chrome.test.assertThrows(
37 'Invalid value for argument 1. ' +
38 'Expected \'array\' but got \'string\'.');
39 } else if (test == 'INVALID_PRINTER_TYPE') {
40 chrome.test.assertThrows(
45 description: 'Test printer'
47 'Invalid value for argument 1. ' +
48 'Property \'.1\': Expected \'object\' but got \'string\'.');
49 } else if (test == 'INVALID_PRINTER') {
50 chrome.test.assertThrows(
55 description: 'Test printer',
58 'Invalid value for argument 1. ' +
59 'Property \'.0.unsupported\': Unexpected property.');
61 chrome.test.assertEq('OK', test);
65 description: 'Test printer',
72 chrome.test.assertThrows(
75 'Event callback must not be called more than once.');
77 chrome.test.succeed();
80 chrome.test.sendMessage('ready');