Commit f90653e7 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Add plugin stub for print preview tests

Add a plugin stub to trigger the load callback needed for print preview
tests.

BUG=717296
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2973743002
Cr-Commit-Position: refs/heads/master@{#484964}
parent 43125819
...@@ -172,11 +172,6 @@ cr.define('print_preview', function() { ...@@ -172,11 +172,6 @@ cr.define('print_preview', function() {
*/ */
this.openSystemDialogButton_ = null; this.openSystemDialogButton_ = null;
/**
* If this is in a browser test (fake plugin).
* @private {boolean}
*/
this.isBrowserTest_ = false;
} }
/** /**
...@@ -605,8 +600,6 @@ cr.define('print_preview', function() { ...@@ -605,8 +600,6 @@ cr.define('print_preview', function() {
*/ */
onDocumentReady_: function(event) { onDocumentReady_: function(event) {
this.isDocumentReady_ = true; this.isDocumentReady_ = true;
if (this.isBrowserTest_)
this.isPluginReloaded_ = true;
this.dispatchPreviewGenerationDoneIfReady_(); this.dispatchPreviewGenerationDoneIfReady_();
}, },
...@@ -675,11 +668,6 @@ cr.define('print_preview', function() { ...@@ -675,11 +668,6 @@ cr.define('print_preview', function() {
// being draggable. // being draggable.
this.plugin_.style.pointerEvents = isDragging ? 'none' : 'auto'; this.plugin_.style.pointerEvents = isDragging ? 'none' : 'auto';
}, },
/** @param {boolean} isTest Whether this instance is in a browser test. */
setIsBrowserTest: function(isTest) {
this.isBrowserTest_ = isTest;
}
}; };
// Export // Export
......
// 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};
});
...@@ -302,7 +302,9 @@ cr.define('print_preview_test', function() { ...@@ -302,7 +302,9 @@ cr.define('print_preview_test', function() {
print_preview.NativeLayer.setInstance(nativeLayer); print_preview.NativeLayer.setInstance(nativeLayer);
printPreview = new print_preview.PrintPreview(); printPreview = new print_preview.PrintPreview();
previewArea = printPreview.getPreviewArea(); previewArea = printPreview.getPreviewArea();
previewArea.setIsBrowserTest(true); previewArea.plugin_ = new print_preview.PDFPluginStub(previewArea);
previewArea.plugin_.setLoadCallback(
previewArea.onPluginLoad_.bind(previewArea));
}); });
// Test some basic assumptions about the print preview WebUI. // Test some basic assumptions about the print preview WebUI.
......
...@@ -58,6 +58,7 @@ PrintPreviewUIBrowserTest.prototype = { ...@@ -58,6 +58,7 @@ PrintPreviewUIBrowserTest.prototype = {
ROOT_PATH + 'chrome/test/data/webui/test_browser_proxy.js', ROOT_PATH + 'chrome/test/data/webui/test_browser_proxy.js',
'print_preview_tests.js', 'print_preview_tests.js',
'native_layer_stub.js', 'native_layer_stub.js',
'plugin_stub.js',
], ],
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment