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 [ | 13 [ |
14 'getInitialSettings', | 14 'getInitialSettings', |
15 'getPrinters', | 15 'getPrinters', |
16 'getExtensionPrinters', | 16 'getExtensionPrinters', |
| 17 'getPrivetPrinters', |
17 'setupPrinter' | 18 'setupPrinter' |
18 ]); | 19 ]); |
19 | 20 |
20 /** | 21 /** |
21 * @private {!cr.EventTarget} The event target used for dispatching and | 22 * @private {!cr.EventTarget} The event target used for dispatching and |
22 * receiving events. | 23 * receiving events. |
23 */ | 24 */ |
24 this.eventTarget_ = new cr.EventTarget(); | 25 this.eventTarget_ = new cr.EventTarget(); |
25 | 26 |
26 /** @private {boolean} Whether the native layer has sent a print message. */ | 27 /** @private {boolean} Whether the native layer has sent a print message. */ |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return Promise.resolve(this.localDestinationInfos_); | 85 return Promise.resolve(this.localDestinationInfos_); |
85 }, | 86 }, |
86 | 87 |
87 /** @override */ | 88 /** @override */ |
88 getExtensionPrinters: function() { | 89 getExtensionPrinters: function() { |
89 this.methodCalled('getExtensionPrinters'); | 90 this.methodCalled('getExtensionPrinters'); |
90 return Promise.resolve(true); | 91 return Promise.resolve(true); |
91 }, | 92 }, |
92 | 93 |
93 /** @override */ | 94 /** @override */ |
| 95 getPrivetPrinters: function() { |
| 96 this.methodCalled('getPrivetPrinters'); |
| 97 return Promise.resolve(true); |
| 98 }, |
| 99 |
| 100 /** @override */ |
94 setupPrinter: function(printerId) { | 101 setupPrinter: function(printerId) { |
95 this.methodCalled('setupPrinter', printerId); | 102 this.methodCalled('setupPrinter', printerId); |
96 return this.shouldRejectPrinterSetup_ ? | 103 return this.shouldRejectPrinterSetup_ ? |
97 Promise.reject(this.setupPrinterResponse_) : | 104 Promise.reject(this.setupPrinterResponse_) : |
98 Promise.resolve(this.setupPrinterResponse_); | 105 Promise.resolve(this.setupPrinterResponse_); |
99 }, | 106 }, |
100 | 107 |
101 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */ | 108 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */ |
102 previewReadyForTest: function() {}, | 109 previewReadyForTest: function() {}, |
103 startGetLocalDestinations: function() {}, | |
104 startGetPrivetDestinations: function() {}, | |
105 startGetLocalDestinationCapabilities: function(destinationId) { | 110 startGetLocalDestinationCapabilities: function(destinationId) { |
106 if (destinationId == this.destinationToWatch_) | 111 if (destinationId == this.destinationToWatch_) |
107 this.getLocalDestinationCapabilitiesCallCount_++; | 112 this.getLocalDestinationCapabilitiesCallCount_++; |
108 }, | 113 }, |
109 startGetPreview: function(destination, printTicketStore, documentInfo, | 114 startGetPreview: function(destination, printTicketStore, documentInfo, |
110 generateDraft, requestId) { | 115 generateDraft, requestId) { |
111 this.generateDraft_ = generateDraft; | 116 this.generateDraft_ = generateDraft; |
112 }, | 117 }, |
113 startPrint: function () { this.printStarted_ = true; }, | 118 startPrint: function () { this.printStarted_ = true; }, |
114 startHideDialog: function () {}, | 119 startHideDialog: function () {}, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 setSetupPrinterResponse: function(reject, response) { | 175 setSetupPrinterResponse: function(reject, response) { |
171 this.shouldRejectPrinterSetup_ = reject; | 176 this.shouldRejectPrinterSetup_ = reject; |
172 this.setupPrinterResponse_ = response; | 177 this.setupPrinterResponse_ = response; |
173 }, | 178 }, |
174 }; | 179 }; |
175 | 180 |
176 return { | 181 return { |
177 NativeLayerStub: NativeLayerStub, | 182 NativeLayerStub: NativeLayerStub, |
178 }; | 183 }; |
179 }); | 184 }); |
OLD | NEW |