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

Side by Side Diff: chrome/test/data/webui/print_preview/native_layer_stub.js

Issue 2962983002: Print Preview: change getPreview to cr.sendWithPromise (Closed)
Patch Set: Re-comment test Created 3 years, 5 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 unified diff | Download patch
OLDNEW
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 {TestBrowserProxy} 9 * @extends {TestBrowserProxy}
10 */ 10 */
11 function NativeLayerStub() { 11 function NativeLayerStub() {
12 TestBrowserProxy.call(this, [ 12 TestBrowserProxy.call(this, [
13 'getInitialSettings', 13 'getInitialSettings',
14 'getPrinters', 14 'getPrinters',
15 'getExtensionPrinters', 15 'getExtensionPrinters',
16 'getPreview',
16 'getPrivetPrinters', 17 'getPrivetPrinters',
17 'getPrinterCapabilities', 18 'getPrinterCapabilities',
18 'print', 19 'print',
19 'setupPrinter' 20 'setupPrinter'
20 ]); 21 ]);
21 22
22 /** 23 /**
23 * @private {!cr.EventTarget} The event target used for dispatching and 24 * @private {!cr.EventTarget} The event target used for dispatching and
24 * receiving events. 25 * receiving events.
25 */ 26 */
26 this.eventTarget_ = new cr.EventTarget(); 27 this.eventTarget_ = new cr.EventTarget();
27 28
28 /** 29 /**
29 * @private {boolean} Whether the native layer has set the generate draft
30 * parameter when requesting an updated preview.
31 */
32 this.generateDraft_ = false;
33
34 /**
35 * @private {!print_preview.NativeInitialSettings} The initial settings 30 * @private {!print_preview.NativeInitialSettings} The initial settings
36 * to be used for the response to a |getInitialSettings| call. 31 * to be used for the response to a |getInitialSettings| call.
37 */ 32 */
38 this.initialSettings_ = null; 33 this.initialSettings_ = null;
39 34
40 /** 35 /**
41 * 36 *
42 * @private {!Array<!print_preview.LocalDestinationInfo>} Local destination 37 * @private {!Array<!print_preview.LocalDestinationInfo>} Local destination
43 * list to be used for the response to |getPrinters|. 38 * list to be used for the response to |getPrinters|.
44 */ 39 */
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return Promise.resolve(this.localDestinationInfos_); 74 return Promise.resolve(this.localDestinationInfos_);
80 }, 75 },
81 76
82 /** @override */ 77 /** @override */
83 getExtensionPrinters: function() { 78 getExtensionPrinters: function() {
84 this.methodCalled('getExtensionPrinters'); 79 this.methodCalled('getExtensionPrinters');
85 return Promise.resolve(true); 80 return Promise.resolve(true);
86 }, 81 },
87 82
88 /** @override */ 83 /** @override */
84 getPreview: function(
85 destination, printTicketStore, documentInfo, generateDraft, requestId) {
86 this.methodCalled('getPreview', {
87 destination: destination,
88 printTicketStore: printTicketStore,
89 documentInfo: documentInfo,
90 generateDraft: generateDraft,
91 requestId: requestId,
92 });
93 return Promise.resolve(requestId);
94 },
95
96 /** @override */
89 getPrivetPrinters: function() { 97 getPrivetPrinters: function() {
90 this.methodCalled('getPrivetPrinters'); 98 this.methodCalled('getPrivetPrinters');
91 return Promise.resolve(true); 99 return Promise.resolve(true);
92 }, 100 },
93 101
94 /** @override */ 102 /** @override */
95 getPrinterCapabilities: function(printerId) { 103 getPrinterCapabilities: function(printerId) {
96 this.methodCalled('getPrinterCapabilities', printerId); 104 this.methodCalled('getPrinterCapabilities', printerId);
97 return this.localDestinationCapabilities_.get(printerId); 105 return this.localDestinationCapabilities_.get(printerId);
98 }, 106 },
99 107
100 /** @override */ 108 /** @override */
101 print: function() { 109 print: function() {
102 this.methodCalled('print'); 110 this.methodCalled('print');
103 return Promise.resolve(); 111 return Promise.resolve();
104 }, 112 },
105 113
106 /** @override */ 114 /** @override */
107 setupPrinter: function(printerId) { 115 setupPrinter: function(printerId) {
108 this.methodCalled('setupPrinter', printerId); 116 this.methodCalled('setupPrinter', printerId);
109 return this.shouldRejectPrinterSetup_ ? 117 return this.shouldRejectPrinterSetup_ ?
110 Promise.reject(this.setupPrinterResponse_) : 118 Promise.reject(this.setupPrinterResponse_) :
111 Promise.resolve(this.setupPrinterResponse_); 119 Promise.resolve(this.setupPrinterResponse_);
112 }, 120 },
113 121
114 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */ 122 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */
115 previewReadyForTest: function() {}, 123 previewReadyForTest: function() {},
116
117 startGetPreview: function(destination, printTicketStore, documentInfo,
118 generateDraft, requestId) {
119 this.generateDraft_ = generateDraft;
120 },
121 startHideDialog: function () {}, 124 startHideDialog: function () {},
122 125
123 /** @return {!cr.EventTarget} The native layer event target. */ 126 /** @return {!cr.EventTarget} The native layer event target. */
124 getEventTarget: function() { return this.eventTarget_; }, 127 getEventTarget: function() { return this.eventTarget_; },
125 128
126 /** @param {!cr.EventTarget} eventTarget The event target to use. */ 129 /** @param {!cr.EventTarget} eventTarget The event target to use. */
127 setEventTarget: function(eventTarget) { 130 setEventTarget: function(eventTarget) {
128 this.eventTarget_ = eventTarget; 131 this.eventTarget_ = eventTarget;
129 }, 132 },
130 133
131 /** @return {boolean} Whether a new draft was requested for preview. */
132 generateDraft: function() { return this.generateDraft_; },
133
134 /** 134 /**
135 * @param {!print_preview.NativeInitialSettings} settings The settings 135 * @param {!print_preview.NativeInitialSettings} settings The settings
136 * to return as a response to |getInitialSettings|. 136 * to return as a response to |getInitialSettings|.
137 */ 137 */
138 setInitialSettings: function(settings) { 138 setInitialSettings: function(settings) {
139 this.initialSettings_ = settings; 139 this.initialSettings_ = settings;
140 }, 140 },
141 141
142 /** 142 /**
143 * @param {!Array<!print_preview.LocalDestinationInfo>} localDestinations 143 * @param {!Array<!print_preview.LocalDestinationInfo>} localDestinations
(...skipping 23 matching lines...) Expand all
167 setSetupPrinterResponse: function(reject, response) { 167 setSetupPrinterResponse: function(reject, response) {
168 this.shouldRejectPrinterSetup_ = reject; 168 this.shouldRejectPrinterSetup_ = reject;
169 this.setupPrinterResponse_ = response; 169 this.setupPrinterResponse_ = response;
170 }, 170 },
171 }; 171 };
172 172
173 return { 173 return {
174 NativeLayerStub: NativeLayerStub, 174 NativeLayerStub: NativeLayerStub,
175 }; 175 };
176 }); 176 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698