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

Unified Diff: chrome/test/data/webui/print_preview.js

Issue 2833993004: Print Preview: Make generate draft mode work again. (Closed)
Patch Set: Check NativeLayerStub Created 3 years, 7 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/print_preview.js
diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview.js
index 7d64f2e42b9a485728d405cba2aec18c546b4556..81e518968b94b1233c3e17e025522a6c888f14bd 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview.js
@@ -84,17 +84,22 @@ PrintPreviewWebUITest.prototype = {
function NativeLayerStub() {
cr.EventTarget.call(this);
this.printStarted_ = false;
+ this.generateDraft_ = false;
}
NativeLayerStub.prototype = {
__proto__: cr.EventTarget.prototype,
isPrintStarted: function() { return this.printStarted_; },
+ generateDraft: function() { return this.generateDraft_; },
previewReadyForTest: function() {},
startGetInitialSettings: function() {},
startGetLocalDestinations: function() {},
startGetPrivetDestinations: function() {},
startGetExtensionDestinations: function() {},
startGetLocalDestinationCapabilities: function(destinationId) {},
- startGetPreview: function() {},
+ startGetPreview: function(destination, printTicketStore, documentInfo,
+ generateDraft, requestId) {
+ this.generateDraft_ = generateDraft;
+ },
startHideDialog: function () {},
startPrint: function () { this.printStarted_ = true; }
};
@@ -177,14 +182,23 @@ PrintPreviewWebUITest.prototype = {
},
/**
- * @return {boolean} Whether the UI has/has not "printed" (called startPrint
- * on the native layer).
+ * @return {boolean} Whether the UI has "printed" or not. (called startPrint
+ * on the native layer)
*/
hasPrinted: function() {
return this.nativeLayer_.isPrintStarted();
},
/**
+ * @return {boolean} Whether the UI is "generating draft" in the most recent
+ * preview. (checking the result of the startGetPreview call in the native
+ * layer)
+ */
+ generateDraft: function() {
+ return this.nativeLayer_.generateDraft();
+ },
+
+ /**
* Even though animation duration and delay is set to zero, it is necessary to
* wait until the animation has finished.
*/
@@ -1449,3 +1463,32 @@ TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() {
expectTrue(this.hasPrinted());
testDone();
});
+
+// Test the preview generator to make sure the generate draft parameter is set
+// correctly. It should be false if the only change is the page range.
+TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() {
+ // Use a real preview generator.
+ printPreview.previewArea_.previewGenerator_ =
+ new print_preview.PreviewGenerator(printPreview.destinationStore_,
+ printPreview.printTicketStore_, this.nativeLayer_,
+ printPreview.documentInfo_);
+
+ this.setInitialSettings();
+ this.setLocalDestinations();
+ this.setCapabilities(getCddTemplate("FooDevice"));
+
+ // The first request should generate draft because there was no previous print
+ // preview draft.
+ expectTrue(this.generateDraft());
+
+ // Change the page range - no new draft needed.
+ printPreview.printTicketStore_.pageRange.updateValue("2");
+ expectFalse(this.generateDraft());
dpapad 2017/05/05 18:28:49 Thanks. This looks good for now. Eventually when w
+
+ // Change the margin type - need to regenerate again.
+ printPreview.printTicketStore_.marginsType.updateValue(
+ print_preview.ticket_items.MarginsTypeValue.NO_MARGINS);
+ expectTrue(this.generateDraft());
+
+ testDone();
+});
« 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