OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
6 /** | 6 /** |
7 * Test version of the native layer. | 7 * Test version of the native layer. |
8 * @constructor | 8 * @constructor |
9 * @extends {settings.TestBrowserProxy} | 9 * @extends {settings.TestBrowserProxy} |
10 */ | 10 */ |
11 function NativeLayerStub() { | 11 function NativeLayerStub() { |
12 settings.TestBrowserProxy.call(this, [ | 12 settings.TestBrowserProxy.call(this, |
13 'getInitialSettings', 'getPrinters', 'setupPrinter' ]); | 13 [ |
| 14 'getInitialSettings', |
| 15 'getPrinters', |
| 16 'getExtensionPrinters', |
| 17 'setupPrinter' |
| 18 ]); |
14 | 19 |
15 /** | 20 /** |
16 * @private {!cr.EventTarget} The event target used for dispatching and | 21 * @private {!cr.EventTarget} The event target used for dispatching and |
17 * receiving events. | 22 * receiving events. |
18 */ | 23 */ |
19 this.eventTarget_ = new cr.EventTarget(); | 24 this.eventTarget_ = new cr.EventTarget(); |
20 | 25 |
21 /** @private {boolean} Whether the native layer has sent a print message. */ | 26 /** @private {boolean} Whether the native layer has sent a print message. */ |
22 this.printStarted_ = false; | 27 this.printStarted_ = false; |
23 | 28 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return Promise.resolve(this.initialSettings_); | 78 return Promise.resolve(this.initialSettings_); |
74 }, | 79 }, |
75 | 80 |
76 /** @override */ | 81 /** @override */ |
77 getPrinters: function() { | 82 getPrinters: function() { |
78 this.methodCalled('getPrinters'); | 83 this.methodCalled('getPrinters'); |
79 return Promise.resolve(this.localDestinationInfos_); | 84 return Promise.resolve(this.localDestinationInfos_); |
80 }, | 85 }, |
81 | 86 |
82 /** @override */ | 87 /** @override */ |
| 88 getExtensionPrinters: function() { |
| 89 this.methodCalled('getExtensionPrinters'); |
| 90 return Promise.resolve(true); |
| 91 }, |
| 92 |
| 93 /** @override */ |
83 setupPrinter: function(printerId) { | 94 setupPrinter: function(printerId) { |
84 this.methodCalled('setupPrinter', printerId); | 95 this.methodCalled('setupPrinter', printerId); |
85 return this.shouldRejectPrinterSetup_ ? | 96 return this.shouldRejectPrinterSetup_ ? |
86 Promise.reject(this.setupPrinterResponse_) : | 97 Promise.reject(this.setupPrinterResponse_) : |
87 Promise.resolve(this.setupPrinterResponse_); | 98 Promise.resolve(this.setupPrinterResponse_); |
88 }, | 99 }, |
89 | 100 |
90 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */ | 101 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */ |
91 previewReadyForTest: function() {}, | 102 previewReadyForTest: function() {}, |
92 startGetLocalDestinations: function() {}, | 103 startGetLocalDestinations: function() {}, |
93 startGetPrivetDestinations: function() {}, | 104 startGetPrivetDestinations: function() {}, |
94 startGetExtensionDestinations: function() {}, | |
95 startGetLocalDestinationCapabilities: function(destinationId) { | 105 startGetLocalDestinationCapabilities: function(destinationId) { |
96 if (destinationId == this.destinationToWatch_) | 106 if (destinationId == this.destinationToWatch_) |
97 this.getLocalDestinationCapabilitiesCallCount_++; | 107 this.getLocalDestinationCapabilitiesCallCount_++; |
98 }, | 108 }, |
99 startGetPreview: function(destination, printTicketStore, documentInfo, | 109 startGetPreview: function(destination, printTicketStore, documentInfo, |
100 generateDraft, requestId) { | 110 generateDraft, requestId) { |
101 this.generateDraft_ = generateDraft; | 111 this.generateDraft_ = generateDraft; |
102 }, | 112 }, |
103 startPrint: function () { this.printStarted_ = true; }, | 113 startPrint: function () { this.printStarted_ = true; }, |
104 startHideDialog: function () {}, | 114 startHideDialog: function () {}, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 setSetupPrinterResponse: function(reject, response) { | 170 setSetupPrinterResponse: function(reject, response) { |
161 this.shouldRejectPrinterSetup_ = reject; | 171 this.shouldRejectPrinterSetup_ = reject; |
162 this.setupPrinterResponse_ = response; | 172 this.setupPrinterResponse_ = response; |
163 }, | 173 }, |
164 }; | 174 }; |
165 | 175 |
166 return { | 176 return { |
167 NativeLayerStub: NativeLayerStub, | 177 NativeLayerStub: NativeLayerStub, |
168 }; | 178 }; |
169 }); | 179 }); |
OLD | NEW |