| 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 a7d8bdfad1bfcb0c11a5d3e76bba722c24941c47..b0b7221b719e9b61792583ea1ace978417ee0df1 100644
|
| --- a/chrome/test/data/webui/print_preview.js
|
| +++ b/chrome/test/data/webui/print_preview.js
|
| @@ -87,6 +87,18 @@ PrintPreviewWebUITest.prototype = {
|
| }.bind(this));
|
| },
|
|
|
| + setUpPreview: function() {
|
| + var initialSettingsSetEvent =
|
| + new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
|
| + initialSettingsSetEvent.initialSettings = this.initialSettings_;
|
| + this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
|
| +
|
| + var localDestsSetEvent =
|
| + new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
|
| + localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
|
| + this.nativeLayer_.dispatchEvent(localDestsSetEvent);
|
| + },
|
| +
|
| /**
|
| * Generate a real C++ class; don't typedef.
|
| * @type {?string}
|
| @@ -584,59 +596,139 @@ TEST_F('PrintPreviewWebUITest',
|
| true);
|
| });
|
|
|
| -// Test that the color settings are set according to the printer capabilities.
|
| -TEST_F('PrintPreviewWebUITest', 'TestColorSettingsTrue', function() {
|
| - var initialSettingsSetEvent =
|
| - new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
|
| - initialSettingsSetEvent.initialSettings = this.initialSettings_;
|
| - this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
|
| +// Test that the color settings, one option, standard monochrome.
|
| +TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
|
| + this.setUpPreview();
|
|
|
| - var localDestsSetEvent =
|
| - new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
|
| - localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
|
| - this.nativeLayer_.dispatchEvent(localDestsSetEvent);
|
| + // Only one option, standard monochrome.
|
| + var capsSetEvent =
|
| + new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| + capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
|
| + capsSetEvent.settingsInfo.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_MONOCHROME"}
|
| + ]
|
| + };
|
| + this.nativeLayer_.dispatchEvent(capsSetEvent);
|
| +
|
| + checkSectionVisible($('color-settings'), false);
|
| +});
|
| +
|
| +// Test that the color settings, one option, custom monochrome.
|
| +TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
|
| + function() {
|
| + this.setUpPreview();
|
|
|
| + // Only one option, standard monochrome.
|
| var capsSetEvent =
|
| new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
|
| + capsSetEvent.settingsInfo.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "CUSTOM_MONOCHROME", "vendor_id": "42"}
|
| + ]
|
| + };
|
| this.nativeLayer_.dispatchEvent(capsSetEvent);
|
|
|
| - checkSectionVisible($('color-settings'), true);
|
| + checkSectionVisible($('color-settings'), false);
|
| +});
|
|
|
| - var colorOption = $('color-settings').querySelector('.color-option');
|
| - var bwOption = $('color-settings').querySelector('.bw-option');
|
| - expectTrue(colorOption.checked);
|
| - expectFalse(bwOption.checked);
|
| +// Test that the color settings, one option, standard color.
|
| +TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
|
| + this.setUpPreview();
|
| +
|
| + var capsSetEvent =
|
| + new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| + capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
|
| + capsSetEvent.settingsInfo.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_COLOR"}
|
| + ]
|
| + };
|
| + this.nativeLayer_.dispatchEvent(capsSetEvent);
|
| +
|
| + checkSectionVisible($('color-settings'), false);
|
| });
|
|
|
| -//Test that the color settings are set according to the printer capabilities.
|
| -TEST_F('PrintPreviewWebUITest', 'TestColorSettingsFalse', function() {
|
| - var initialSettingsSetEvent =
|
| - new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
|
| - initialSettingsSetEvent.initialSettings = this.initialSettings_;
|
| - this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
|
| +// Test that the color settings, one option, custom color.
|
| +TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
|
| + this.setUpPreview();
|
|
|
| - var localDestsSetEvent =
|
| - new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
|
| - localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
|
| - this.nativeLayer_.dispatchEvent(localDestsSetEvent);
|
| + var capsSetEvent =
|
| + new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| + capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
|
| + capsSetEvent.settingsInfo.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
|
| + ]
|
| + };
|
| + this.nativeLayer_.dispatchEvent(capsSetEvent);
|
| +
|
| + checkSectionVisible($('color-settings'), false);
|
| +});
|
| +
|
| +// Test that the color settings, two options, both standard, defaults to color.
|
| +TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
|
| + function() {
|
| + this.setUpPreview();
|
|
|
| var capsSetEvent =
|
| new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
|
| capsSetEvent.settingsInfo.capabilities.printer.color = {
|
| "option": [
|
| - {"is_default": true, "type": "STANDARD_MONOCHROME"}
|
| + {"type": "STANDARD_MONOCHROME"},
|
| + {"is_default": true, "type": "STANDARD_COLOR"}
|
| ]
|
| };
|
| this.nativeLayer_.dispatchEvent(capsSetEvent);
|
|
|
| - checkSectionVisible($('color-settings'), false);
|
| + checkSectionVisible($('color-settings'), true);
|
| + expectTrue($('color-settings').querySelector('.color-option').checked);
|
| + expectFalse($('color-settings').querySelector('.bw-option').checked);
|
| +});
|
| +
|
| +// Test that the color settings, two options, both standard, defaults to
|
| +// monochrome.
|
| +TEST_F('PrintPreviewWebUITest',
|
| + 'TestColorSettingsBothStandardDefaultMonochrome', function() {
|
| + this.setUpPreview();
|
|
|
| - var colorOption = $('color-settings').querySelector('.color-option');
|
| - var bwOption = $('color-settings').querySelector('.bw-option');
|
| - expectFalse(colorOption.checked);
|
| - expectTrue(bwOption.checked);
|
| + var capsSetEvent =
|
| + new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| + capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
|
| + capsSetEvent.settingsInfo.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_MONOCHROME"},
|
| + {"type": "STANDARD_COLOR"}
|
| + ]
|
| + };
|
| + this.nativeLayer_.dispatchEvent(capsSetEvent);
|
| +
|
| + checkSectionVisible($('color-settings'), true);
|
| + expectFalse($('color-settings').querySelector('.color-option').checked);
|
| + expectTrue($('color-settings').querySelector('.bw-option').checked);
|
| +});
|
| +
|
| +// Test that the color settings, two options, both custom, defaults to color.
|
| +TEST_F('PrintPreviewWebUITest',
|
| + 'TestColorSettingsBothCustomDefaultColor', function() {
|
| + this.setUpPreview();
|
| +
|
| + var capsSetEvent =
|
| + new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| + capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
|
| + capsSetEvent.settingsInfo.capabilities.printer.color = {
|
| + "option": [
|
| + {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
|
| + {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
|
| + ]
|
| + };
|
| + this.nativeLayer_.dispatchEvent(capsSetEvent);
|
| +
|
| + checkSectionVisible($('color-settings'), true);
|
| + expectTrue($('color-settings').querySelector('.color-option').checked);
|
| + expectFalse($('color-settings').querySelector('.bw-option').checked);
|
| });
|
|
|
| // Test to verify that duplex settings are set according to the printer
|
| @@ -666,8 +758,8 @@ TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
|
| expectFalse(duplexCheckbox.checked);
|
| });
|
|
|
| -//Test to verify that duplex settings are set according to the printer
|
| -//capabilities.
|
| +// Test to verify that duplex settings are set according to the printer
|
| +// capabilities.
|
| TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
|
| var initialSettingsSetEvent =
|
| new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
|
|
|