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

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

Issue 2918243002: Change getExtensionPrinters to cr.sendWithPromise (Closed)
Patch Set: Move add listener into init Created 3 years, 6 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 {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
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
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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698