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

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

Issue 2973743002: Add plugin stub for print preview tests (Closed)
Patch Set: Update annotation 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/print_preview/plugin_stub.js
diff --git a/chrome/test/data/webui/print_preview/plugin_stub.js b/chrome/test/data/webui/print_preview/plugin_stub.js
new file mode 100644
index 0000000000000000000000000000000000000000..1c141b928627d7b020d6888aacc81c01a0a05fd3
--- /dev/null
+++ b/chrome/test/data/webui/print_preview/plugin_stub.js
@@ -0,0 +1,55 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('print_preview', function() {
+ /**
+ * Test version of the print preview PDF plugin
+ */
+ class PDFPluginStub {
+ /**
+ * @param {!print_preview.PreviewArea} The PreviewArea that owns this
+ * plugin.
+ */
+ constructor(area) {
+ /**
+ * @private {?Function} The callback to run when the plugin has loaded.
+ */
+ this.loadCallback_ = null;
+
+ /** @private {!EventTracker} The plugin stub's event tracker. */
+ this.tracker_ = new EventTracker();
+
+ // Call documentLoadComplete as soon as the preview area starts the
+ // preview.
+ this.tracker_.add(
+ area,
+ print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS,
+ this.documentLoadComplete.bind(this));
+ }
+
+ /**
+ * @param {!Function} callback The callback to run when the plugin has
+ * loaded.
+ */
+ setLoadCallback(callback) {
+ this.loadCallback_ = callback;
+ }
+
+ documentLoadComplete() {
+ if (this.loadCallback_)
+ this.loadCallback_();
+ }
+
+ /**
+ * Stubbed out since some tests result in a call.
+ * @param {string} url The url to initialize the plugin to.
+ * @param {boolean} color Whether the preview should be in color.
+ * @param {!Array<number>} pages The pages to preview.
+ * @param {boolean} modifiable Whether the source document is modifiable.
+ */
+ resetPrintPreviewMode(url, color, pages, modifiable) {}
+ }
+
+ return {PDFPluginStub: PDFPluginStub};
+});

Powered by Google App Engine
This is Rietveld 408576698