Commit 400d7711 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview Componentization: Migrate custom media name test

Bug: 814860
Change-Id: I53c9de7111efb35e73317245647e3659e3bc4a6d
Reviewed-on: https://chromium-review.googlesource.com/1040271
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555793}
parent 1fa1cc40
...@@ -81,6 +81,10 @@ TEST_F('PrintPreviewSettingsSectionsTest', 'MediaSize', function() { ...@@ -81,6 +81,10 @@ TEST_F('PrintPreviewSettingsSectionsTest', 'MediaSize', function() {
this.runMochaTest(settings_sections_tests.TestNames.MediaSize); this.runMochaTest(settings_sections_tests.TestNames.MediaSize);
}); });
TEST_F('PrintPreviewSettingsSectionsTest', 'MediaSizeCustomNames', function() {
this.runMochaTest(settings_sections_tests.TestNames.MediaSizeCustomNames);
});
TEST_F('PrintPreviewSettingsSectionsTest', 'Margins', function() { TEST_F('PrintPreviewSettingsSectionsTest', 'Margins', function() {
this.runMochaTest(settings_sections_tests.TestNames.Margins); this.runMochaTest(settings_sections_tests.TestNames.Margins);
}); });
...@@ -137,6 +141,31 @@ TEST_F('PrintPreviewSettingsSectionsTest', 'SetOther', function() { ...@@ -137,6 +141,31 @@ TEST_F('PrintPreviewSettingsSectionsTest', 'SetOther', function() {
this.runMochaTest(settings_sections_tests.TestNames.SetOther); this.runMochaTest(settings_sections_tests.TestNames.SetOther);
}); });
PrintPreviewSettingsSelectTest = class extends NewPrintPreviewTest {
/** @override */
get browsePreload() {
return 'chrome://print/new/settings_select.html';
}
/** @override */
get extraLibraries() {
return super.extraLibraries.concat([
'print_preview_test_utils.js',
'settings_select_test.js',
]);
}
/** @override */
get suiteName() {
return settings_select_test.suiteName;
}
};
TEST_F('PrintPreviewSettingsSelectTest', 'CustomMediaNames',
function() {
this.runMochaTest(settings_select_test.TestNames.CustomMediaNames);
});
PrintPreviewRestoreStateTest = class extends NewPrintPreviewTest { PrintPreviewRestoreStateTest = class extends NewPrintPreviewTest {
/** @override */ /** @override */
get browsePreload() { get browsePreload() {
......
...@@ -157,6 +157,35 @@ cr.define('print_preview_test_utils', function() { ...@@ -157,6 +157,35 @@ cr.define('print_preview_test_utils', function() {
return destinations; return destinations;
} }
/**
* Returns a media size capability with custom and localized names.
* @return {!{ option: Array<!print_preview_new.SelectOption> }}
*/
function getMediaSizeCapabilityWithCustomNames() {
const customLocalizedMediaName = 'Vendor defined localized media name';
const customMediaName = 'Vendor defined media name';
return {
option: [
{ name: 'CUSTOM',
width_microns: 15900,
height_microns: 79400,
is_default: true,
custom_display_name_localized: [
{ locale: navigator.language,
value: customLocalizedMediaName
}
]
},
{ name: 'CUSTOM',
width_microns: 15900,
height_microns: 79400,
custom_display_name: customMediaName
}
]
};
}
return { return {
getDefaultInitialSettings: getDefaultInitialSettings, getDefaultInitialSettings: getDefaultInitialSettings,
getCddTemplate: getCddTemplate, getCddTemplate: getCddTemplate,
...@@ -165,5 +194,7 @@ cr.define('print_preview_test_utils', function() { ...@@ -165,5 +194,7 @@ cr.define('print_preview_test_utils', function() {
createDestinationWithCertificateStatus: createDestinationWithCertificateStatus:
createDestinationWithCertificateStatus, createDestinationWithCertificateStatus,
getDestinations: getDestinations, getDestinations: getDestinations,
getMediaSizeCapabilityWithCustomNames:
getMediaSizeCapabilityWithCustomNames,
}; };
}); });
...@@ -9,6 +9,7 @@ cr.define('settings_sections_tests', function() { ...@@ -9,6 +9,7 @@ cr.define('settings_sections_tests', function() {
Layout: 'layout', Layout: 'layout',
Color: 'color', Color: 'color',
MediaSize: 'media size', MediaSize: 'media size',
MediaSizeCustomNames: 'media size custom names',
Margins: 'margins', Margins: 'margins',
Dpi: 'dpi', Dpi: 'dpi',
Scaling: 'scaling', Scaling: 'scaling',
...@@ -273,6 +274,31 @@ cr.define('settings_sections_tests', function() { ...@@ -273,6 +274,31 @@ cr.define('settings_sections_tests', function() {
assertFalse(mediaSizeElement.hidden); assertFalse(mediaSizeElement.hidden);
}); });
test(assert(TestNames.MediaSizeCustomNames), function() {
const customLocalizedMediaName = 'Vendor defined localized media name';
const customMediaName = 'Vendor defined media name';
const mediaSizeElement = page.$$('print-preview-media-size-settings');
// Expand more settings to reveal the element.
toggleMoreSettings();
assertFalse(mediaSizeElement.hidden);
// Change capability to have custom paper sizes.
let capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
capabilities.printer.media_size =
print_preview_test_utils.getMediaSizeCapabilityWithCustomNames();
page.set('destination_.capabilities', capabilities);
Polymer.dom.flush();
const settingsSelect =
mediaSizeElement.$$('print-preview-settings-select');
assertEquals(capabilities.printer.media_size, settingsSelect.capability);
assertFalse(settingsSelect.disabled);
assertEquals('mediaSize', settingsSelect.settingName);
});
test(assert(TestNames.Margins), function() { test(assert(TestNames.Margins), function() {
const marginsElement = page.$$('print-preview-margins-settings'); const marginsElement = page.$$('print-preview-margins-settings');
......
// Copyright 2018 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('settings_select_test', function() {
/** @enum {string} */
const TestNames = {
CustomMediaNames: 'custom media names',
};
const suiteName = 'SettingsSelectTest';
suite(suiteName, function() {
let settingsSelect = null;
/** @override */
setup(function() {
PolymerTest.clearBody();
settingsSelect = document.createElement('print-preview-settings-select');
settingsSelect.disabled = false;
document.body.appendChild(settingsSelect);
});
// Test that destinations are correctly displayed in the lists.
test(assert(TestNames.CustomMediaNames), function() {
// Set a capability with custom paper sizes.
settingsSelect.settingName = 'mediaSize';
settingsSelect.capability =
print_preview_test_utils.getMediaSizeCapabilityWithCustomNames();
const customLocalizedMediaName =
settingsSelect.capability.option[0].custom_display_name_localized[0]
.value;
const customMediaName =
settingsSelect.capability.option[1].custom_display_name;
Polymer.dom.flush();
const select = settingsSelect.$$('select');
// Verify that the selected option and names are as expected.
assertEquals(0, select.selectedIndex);
assertEquals(2, select.options.length);
assertEquals(customLocalizedMediaName,
select.options[0].textContent.trim());
assertEquals(customMediaName,
select.options[1].textContent.trim());
});
});
return {
suiteName: suiteName,
TestNames: TestNames,
};
});
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