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

Side by Side Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 23054002: Added basic browser test for window.print() from Chrome apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added print preview auto-cancel to avoid test timeouts Created 7 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * An interface to the native Chromium printing system layer. 9 * An interface to the native Chromium printing system layer.
10 * @constructor 10 * @constructor
(...skipping 22 matching lines...) Expand all
33 global['onDidGetDefaultPageLayout'] = 33 global['onDidGetDefaultPageLayout'] =
34 this.onDidGetDefaultPageLayout_.bind(this); 34 this.onDidGetDefaultPageLayout_.bind(this);
35 global['onDidGetPreviewPageCount'] = 35 global['onDidGetPreviewPageCount'] =
36 this.onDidGetPreviewPageCount_.bind(this); 36 this.onDidGetPreviewPageCount_.bind(this);
37 global['reloadPreviewPages'] = this.onReloadPreviewPages_.bind(this); 37 global['reloadPreviewPages'] = this.onReloadPreviewPages_.bind(this);
38 global['onDidPreviewPage'] = this.onDidPreviewPage_.bind(this); 38 global['onDidPreviewPage'] = this.onDidPreviewPage_.bind(this);
39 global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this); 39 global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this);
40 global['printScalingDisabledForSourcePDF'] = 40 global['printScalingDisabledForSourcePDF'] =
41 this.onPrintScalingDisabledForSourcePDF_.bind(this); 41 this.onPrintScalingDisabledForSourcePDF_.bind(this);
42 global['onDidGetAccessToken'] = this.onDidGetAccessToken_.bind(this); 42 global['onDidGetAccessToken'] = this.onDidGetAccessToken_.bind(this);
43 global['autoCancelPrintPreviewForTesting'] =
44 this.autoCancelPrintPreviewForTesting_.bind(this);
43 }; 45 };
44 46
45 /** 47 /**
46 * Event types dispatched from the Chromium native layer. 48 * Event types dispatched from the Chromium native layer.
47 * @enum {string} 49 * @enum {string}
48 * @const 50 * @const
49 */ 51 */
50 NativeLayer.EventType = { 52 NativeLayer.EventType = {
51 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', 53 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY',
54 AUTO_CANCEL_FOR_TESTING:
55 'print_preview.NativeLayer.AUTO_CANCEL_FOR_TESTING',
52 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', 56 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET',
53 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', 57 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE',
54 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', 58 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD',
55 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', 59 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING',
56 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL', 60 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL',
57 FILE_SELECTION_COMPLETE: 61 FILE_SELECTION_COMPLETE:
58 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE', 62 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE',
59 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL', 63 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL',
60 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET', 64 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET',
61 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET', 65 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET',
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 /** 574 /**
571 * Updates the fit to page option state based on the print scaling option of 575 * Updates the fit to page option state based on the print scaling option of
572 * source pdf. PDF's have an option to enable/disable print scaling. When we 576 * source pdf. PDF's have an option to enable/disable print scaling. When we
573 * find out that the print scaling option is disabled for the source pdf, we 577 * find out that the print scaling option is disabled for the source pdf, we
574 * uncheck the fitToPage_ to page checkbox. This function is called from C++ 578 * uncheck the fitToPage_ to page checkbox. This function is called from C++
575 * code. 579 * code.
576 * @private 580 * @private
577 */ 581 */
578 onPrintScalingDisabledForSourcePDF_: function() { 582 onPrintScalingDisabledForSourcePDF_: function() {
579 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DISABLE_SCALING); 583 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DISABLE_SCALING);
584 },
585
586 /**
587 * Cancel the preview and close the preview dialog. This function is called
588 * from C++ testing code.
589 * @private
590 */
591 autoCancelPrintPreviewForTesting_: function() {
592 cr.dispatchSimpleEvent(
593 this, NativeLayer.EventType.AUTO_CANCEL_FOR_TESTING);
580 } 594 }
581 }; 595 };
582 596
583 /** 597 /**
584 * Initial settings retrieved from the native layer. 598 * Initial settings retrieved from the native layer.
585 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be 599 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be
586 * in auto-print mode. 600 * in auto-print mode.
587 * @param {string} thousandsDelimeter Character delimeter of thousands digits. 601 * @param {string} thousandsDelimeter Character delimeter of thousands digits.
588 * @param {string} decimalDelimeter Character delimeter of the decimal point. 602 * @param {string} decimalDelimeter Character delimeter of the decimal point.
589 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of 603 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 return this.serializedAppStateStr_; 753 return this.serializedAppStateStr_;
740 } 754 }
741 }; 755 };
742 756
743 // Export 757 // Export
744 return { 758 return {
745 NativeInitialSettings: NativeInitialSettings, 759 NativeInitialSettings: NativeInitialSettings,
746 NativeLayer: NativeLayer 760 NativeLayer: NativeLayer
747 }; 761 };
748 }); 762 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698