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

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

Issue 2893003003: Print Preview: Merge NativeLayerStubs for tests (Closed)
Patch Set: Fix closure error 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
Index: chrome/test/data/webui/print_preview/print_preview.js
diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview/print_preview.js
similarity index 91%
rename from chrome/test/data/webui/print_preview.js
rename to chrome/test/data/webui/print_preview/print_preview.js
index 355a196fa613cfeb16b645b4066f8be4f0fc901a..6848b1197033e6f7a05b69ba14eaf12a2ec023ec 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview/print_preview.js
@@ -5,7 +5,7 @@
GEN('#include "base/feature_list.h"');
GEN('#include "chrome/common/chrome_features.h"');
-var ROOT_PATH = '../../../../';
+var ROOT_PATH = '../../../../../';
/**
* Test fixture for print preview WebUI testing.
@@ -50,7 +50,7 @@ PrintPreviewWebUITest.prototype = {
* @type {string}
* @override
*/
- browsePrintPreload: 'print_preview_hello_world_test.html',
+ browsePrintPreload: 'print_preview/print_preview_hello_world_test.html',
/** @override */
runAccessibilityChecks: true,
@@ -85,45 +85,6 @@ PrintPreviewWebUITest.prototype = {
preLoad: function() {
window.isTest = true;
window.addEventListener('DOMContentLoaded', function() {
- /**
- * Test version of the native layer.
- * @constructor
- * @extends {settings.TestBrowserProxy}
- */
- function NativeLayerStub() {
- settings.TestBrowserProxy.call(this, [ 'getInitialSettings' ]);
- this.eventTarget_ = new cr.EventTarget();
- this.printStarted_ = false;
- this.generateDraft_ = false;
- this.initialSettings_ = null;
- }
- NativeLayerStub.prototype = {
- __proto__: settings.TestBrowserProxy.prototype,
- getEventTarget: function() { return this.eventTarget_; },
- isPrintStarted: function() { return this.printStarted_; },
- generateDraft: function() { return this.generateDraft_; },
- getInitialSettings: function() {
- this.methodCalled('getInitialSettings');
- return Promise.resolve(this.initialSettings_);
- },
- previewReadyForTest: function() {},
- startGetLocalDestinations: function() {},
- startGetPrivetDestinations: function() {},
- startGetExtensionDestinations: function() {},
- startGetLocalDestinationCapabilities: function(destinationId) {},
- startGetPreview: function(destination, printTicketStore, documentInfo,
- generateDraft, requestId) {
- this.generateDraft_ = generateDraft;
- },
- startHideDialog: function () {},
- startPrint: function () { this.printStarted_ = true; }
- };
- var oldNativeLayerEventType = print_preview.NativeLayer.EventType;
- var oldDuplexMode = print_preview.NativeLayer.DuplexMode;
- print_preview.NativeLayer = NativeLayerStub;
- print_preview.NativeLayer.EventType = oldNativeLayerEventType;
- print_preview.NativeLayer.DuplexMode = oldDuplexMode;
-
function CloudPrintInterfaceStub() {
cr.EventTarget.call(this);
}
@@ -147,6 +108,7 @@ PrintPreviewWebUITest.prototype = {
ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js',
ROOT_PATH + 'ui/webui/resources/js/util.js',
ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js',
+ 'native_layer_stub.js',
],
/**
@@ -154,9 +116,10 @@ PrintPreviewWebUITest.prototype = {
* |nativeLayer_| and |previewArea_|.
*/
createPrintPreview: function() {
+ this.nativeLayer_ = new print_preview.NativeLayerStub();
+ print_preview.NativeLayer.setInstance(this.nativeLayer_);
this.printPreview_ = new print_preview.PrintPreview();
- this.nativeLayer_ = this.printPreview_.nativeLayer_;
- this.previewArea_ = this.printPreview_.previewArea_;
+ this.previewArea_ = this.printPreview_.getPreviewArea();
},
/**
@@ -165,12 +128,9 @@ PrintPreviewWebUITest.prototype = {
* already exist.
*/
setInitialSettings: function() {
- if (!this.printPreview_) {
- this.printPreview_ = new print_preview.PrintPreview();
- this.nativeLayer_ = this.printPreview_.nativeLayer_;
- this.previewArea_ = this.printPreview_.previewArea_;
- }
- this.nativeLayer_.initialSettings_ = this.initialSettings_;
+ if (!this.printPreview_)
+ this.createPrintPreview();
+ this.nativeLayer_.setInitialSettings(this.initialSettings_);
this.printPreview_.initialize();
testing.Test.disableAnimationsAndTransitions();
// Enable when failure is resolved.
@@ -313,12 +273,12 @@ PrintPreviewWebUITest.prototype = {
},
};
-GEN('#include "chrome/test/data/webui/print_preview.h"');
+GEN('#include "chrome/test/data/webui/print_preview/print_preview.h"');
// Test some basic assumptions about the print preview WebUI.
TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
var recentList =
@@ -350,7 +310,7 @@ TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() {
TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -480,7 +440,7 @@ TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination',
'"extensionName":""}]}';
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
testDone();
});
@@ -527,7 +487,7 @@ TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations',
this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState);
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
// Set capabilities for the three recently used destinations + 1 more
this.setCapabilities(getCddTemplate('ID1'));
@@ -569,7 +529,7 @@ TEST_F('PrintPreviewWebUITest',
this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ =
'{"namePattern":".*Bar.*"}';
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -587,7 +547,7 @@ TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode',
this.initialSettings_.isInAppKioskMode_ = true;
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
if (cr.isChromeOS)
assertEquals(null, $('system-dialog-link'));
@@ -605,7 +565,7 @@ TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() {
checkSectionVisible($('copies-settings'), false);
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
var device = getCddTemplate("FooDevice");
@@ -633,7 +593,7 @@ TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() {
this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF';
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
var device = {
printerId: 'Save as PDF',
@@ -687,7 +647,7 @@ TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() {
// media size option.
TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -726,7 +686,7 @@ TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() {
TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() {
this.initialSettings_.isDocumentModifiable_ = false;
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -765,7 +725,7 @@ TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() {
TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() {
this.initialSettings_.isDocumentModifiable_ = false;
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -806,7 +766,7 @@ TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() {
TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() {
this.initialSettings_.isDocumentModifiable_ = false;
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -838,7 +798,7 @@ TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() {
this.initialSettings_.isDocumentModifiable_ = false;
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -867,7 +827,7 @@ TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() {
// Make sure that custom margins controls are properly set up.
TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -891,7 +851,7 @@ TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() {
TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter',
function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -924,7 +884,7 @@ TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter',
TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter',
function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -958,7 +918,7 @@ TEST_F('PrintPreviewWebUITest',
'ZeroTopAndBottomMarginsHideHeaderFooter',
function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -993,7 +953,7 @@ TEST_F('PrintPreviewWebUITest',
'ZeroTopAndNonZeroBottomMarginShowHeaderFooter',
function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -1025,7 +985,7 @@ TEST_F('PrintPreviewWebUITest',
// Check header footer availability with small (label) page size.
TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
var device = getCddTemplate("FooDevice");
@@ -1070,7 +1030,7 @@ TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() {
// Test that the color settings, one option, standard monochrome.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1093,7 +1053,7 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1116,7 +1076,7 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
// Test that the color settings, one option, standard color.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1137,7 +1097,7 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
// Test that the color settings, one option, custom color.
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1159,7 +1119,7 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1186,7 +1146,7 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
TEST_F('PrintPreviewWebUITest',
'TestColorSettingsBothStandardDefaultMonochrome', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1212,7 +1172,7 @@ TEST_F('PrintPreviewWebUITest',
TEST_F('PrintPreviewWebUITest',
'TestColorSettingsBothCustomDefaultColor', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1238,7 +1198,7 @@ TEST_F('PrintPreviewWebUITest',
// capabilities.
TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -1257,7 +1217,7 @@ TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
// capabilities.
TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
var device = getCddTemplate("FooDevice");
@@ -1281,13 +1241,13 @@ TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
// Test that changing the selected printer updates the preview.
TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
var previewGenerator = mock(print_preview.PreviewGenerator);
- this.printPreview_.previewArea_.previewGenerator_ =
+ this.previewArea_.previewGenerator_ =
previewGenerator.proxy();
// The number of settings that can change due to a change in the
@@ -1317,7 +1277,7 @@ TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() {
// Test that error message is displayed when plugin doesn't exist.
TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
var previewAreaEl = $('preview-area');
@@ -1347,7 +1307,7 @@ TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() {
// Test custom localized paper names.
TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() {
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
@@ -1473,7 +1433,7 @@ TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() {
var device = getCddTemplateWithAdvancedSettings("FooDevice");
this.accessibilityIssuesAreErrors = false;
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setupAdvancedSettingsTest(device);
@@ -1511,7 +1471,7 @@ TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings2Options', function() {
});
this.accessibilityIssuesAreErrors = false;
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setupAdvancedSettingsTest(device);
@@ -1552,7 +1512,7 @@ TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
this.setCapabilities(getCddTemplate('ID3'));
// Use a real preview generator.
- this.printPreview_.previewArea_.previewGenerator_ =
+ this.previewArea_.previewGenerator_ =
new print_preview.PreviewGenerator(this.printPreview_.destinationStore_,
this.printPreview_.printTicketStore_, this.nativeLayer_,
this.printPreview_.documentInfo_);
@@ -1563,13 +1523,13 @@ TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
// crbug.com/666595
expectEquals(
-1,
- this.printPreview_.previewArea_.previewGenerator_.inFlightRequestId_);
+ this.previewArea_.previewGenerator_.inFlightRequestId_);
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
expectEquals(
0,
- this.printPreview_.previewArea_.previewGenerator_.
+ this.previewArea_.previewGenerator_.
inFlightRequestId_);
testDone();
}.bind(this));
@@ -1581,7 +1541,7 @@ TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() {
// Setup
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));
@@ -1646,13 +1606,13 @@ TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() {
this.createPrintPreview();
// Use a real preview generator.
- this.printPreview_.previewArea_.previewGenerator_ =
+ this.previewArea_.previewGenerator_ =
new print_preview.PreviewGenerator(this.printPreview_.destinationStore_,
this.printPreview_.printTicketStore_, this.nativeLayer_,
this.printPreview_.documentInfo_);
this.setInitialSettings();
- this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
+ this.nativeLayer_.whenCalled('getInitialSettings').then(
function() {
this.setLocalDestinations();
this.setCapabilities(getCddTemplate("FooDevice"));

Powered by Google App Engine
This is Rietveld 408576698