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

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

Issue 2918243002: Change getExtensionPrinters to cr.sendWithPromise (Closed)
Patch Set: Fix comment 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
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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', 'getPrinters', 'setupPrinter' ]); 13 'getInitialSettings',
14 'getPrinters',
15 'getExtensionPrinters',
16 'setupPrinter'
17 ]);
14 18
15 /** 19 /**
16 * @private {!cr.EventTarget} The event target used for dispatching and 20 * @private {!cr.EventTarget} The event target used for dispatching and
17 * receiving events. 21 * receiving events.
18 */ 22 */
19 this.eventTarget_ = new cr.EventTarget(); 23 this.eventTarget_ = new cr.EventTarget();
20 24
21 /** @private {boolean} Whether the native layer has sent a print message. */ 25 /** @private {boolean} Whether the native layer has sent a print message. */
22 this.printStarted_ = false; 26 this.printStarted_ = false;
23 27
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return Promise.resolve(this.initialSettings_); 77 return Promise.resolve(this.initialSettings_);
74 }, 78 },
75 79
76 /** @override */ 80 /** @override */
77 getPrinters: function() { 81 getPrinters: function() {
78 this.methodCalled('getPrinters'); 82 this.methodCalled('getPrinters');
79 return Promise.resolve(this.localDestinationInfos_); 83 return Promise.resolve(this.localDestinationInfos_);
80 }, 84 },
81 85
82 /** @override */ 86 /** @override */
87 getExtensionPrinters: function() {
88 this.methodCalled('getExtensionPrinters');
89 return Promise.resolve(true);
90 },
91
92 /** @override */
83 setupPrinter: function(printerId) { 93 setupPrinter: function(printerId) {
84 this.methodCalled('setupPrinter', printerId); 94 this.methodCalled('setupPrinter', printerId);
85 return this.shouldRejectPrinterSetup_ ? 95 return this.shouldRejectPrinterSetup_ ?
86 Promise.reject(this.setupPrinterResponse_) : 96 Promise.reject(this.setupPrinterResponse_) :
87 Promise.resolve(this.setupPrinterResponse_); 97 Promise.resolve(this.setupPrinterResponse_);
88 }, 98 },
89 99
90 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */ 100 /** Stubs for |print_preview.NativeLayer| methods that call C++ handlers. */
91 previewReadyForTest: function() {}, 101 previewReadyForTest: function() {},
92 startGetLocalDestinations: function() {}, 102 startGetLocalDestinations: function() {},
93 startGetPrivetDestinations: function() {}, 103 startGetPrivetDestinations: function() {},
94 startGetExtensionDestinations: function() {},
95 startGetLocalDestinationCapabilities: function(destinationId) { 104 startGetLocalDestinationCapabilities: function(destinationId) {
96 if (destinationId == this.destinationToWatch_) 105 if (destinationId == this.destinationToWatch_)
97 this.getLocalDestinationCapabilitiesCallCount_++; 106 this.getLocalDestinationCapabilitiesCallCount_++;
98 }, 107 },
99 startGetPreview: function(destination, printTicketStore, documentInfo, 108 startGetPreview: function(destination, printTicketStore, documentInfo,
100 generateDraft, requestId) { 109 generateDraft, requestId) {
101 this.generateDraft_ = generateDraft; 110 this.generateDraft_ = generateDraft;
102 }, 111 },
103 startPrint: function () { this.printStarted_ = true; }, 112 startPrint: function () { this.printStarted_ = true; },
104 startHideDialog: function () {}, 113 startHideDialog: function () {},
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 setSetupPrinterResponse: function(reject, response) { 169 setSetupPrinterResponse: function(reject, response) {
161 this.shouldRejectPrinterSetup_ = reject; 170 this.shouldRejectPrinterSetup_ = reject;
162 this.setupPrinterResponse_ = response; 171 this.setupPrinterResponse_ = response;
163 }, 172 },
164 }; 173 };
165 174
166 return { 175 return {
167 NativeLayerStub: NativeLayerStub, 176 NativeLayerStub: NativeLayerStub,
168 }; 177 };
169 }); 178 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698