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

New PDF Toolbar: Hook up zoom buttons

Hook up the +/- and fit to page/width buttons in the new PDF toolbar.

Note: This does not update or make use of the new zoom input field.

Bug: 1100428
Change-Id: I33a98f6ea2d065aae5a1557ae3a6c6edad619be0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277333
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786563}
parent e1c45006
...@@ -158,6 +158,7 @@ js_library("pdf_viewer") { ...@@ -158,6 +158,7 @@ js_library("pdf_viewer") {
"elements:viewer-error-screen", "elements:viewer-error-screen",
"elements:viewer-password-screen", "elements:viewer-password-screen",
"elements:viewer-pdf-toolbar", "elements:viewer-pdf-toolbar",
"elements:viewer-pdf-toolbar-new",
"elements:viewer-zoom-toolbar", "elements:viewer-zoom-toolbar",
"//ui/webui/resources/js:assert.m", "//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:event_tracker.m", "//ui/webui/resources/js:event_tracker.m",
......
...@@ -101,11 +101,20 @@ ...@@ -101,11 +101,20 @@
<viewer-page-selector doc-length="[[docLength]]" page-no="[[pageNo]]"> <viewer-page-selector doc-length="[[docLength]]" page-no="[[pageNo]]">
</viewer-page-selector> </viewer-page-selector>
<span id="zoom-controls"> <span id="zoom-controls">
<cr-icon-button iron-icon="pdf:remove"></cr-icon-button> <cr-icon-button iron-icon="pdf:remove" title="$i18n{tooltipZoomOut}"
on-click="onZoomOutClick_">
</cr-icon-button>
<input type="text" value="100%"></input> <input type="text" value="100%"></input>
<cr-icon-button iron-icon="pdf:add"></cr-icon-button> <cr-icon-button iron-icon="pdf:add" title="$i18n{tooltipZoomIn}"
on-click="onZoomInClick_">
</cr-icon-button>
</span> </span>
<cr-icon-button iron-icon="pdf:fit-to-height"></cr-icon-button> <cr-icon-button iron-icon="[[fitToButtonIcon_]]"
title="[[getFitToButtonTooltip_('$i18nPolymer{tooltipFitToPage}',
'$i18nPolymer{tooltipFitToWidth}',
fittingType_)]]"
on-click="onFitToButtonClick_">
</cr-icon-button>
<cr-icon-button iron-icon="pdf:rotate-left"></cr-icon-button> <cr-icon-button iron-icon="pdf:rotate-left"></cr-icon-button>
</div> </div>
<div id="end"> <div id="end">
......
...@@ -6,7 +6,6 @@ import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js'; ...@@ -6,7 +6,6 @@ import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js';
import 'chrome://resources/cr_elements/icons.m.js'; import 'chrome://resources/cr_elements/icons.m.js';
import 'chrome://resources/cr_elements/shared_vars_css.m.js'; import 'chrome://resources/cr_elements/shared_vars_css.m.js';
import 'chrome://resources/polymer/v3_0/paper-progress/paper-progress.js'; import 'chrome://resources/polymer/v3_0/paper-progress/paper-progress.js';
import './icons.js'; import './icons.js';
import './viewer-download-controls.js'; import './viewer-download-controls.js';
import './viewer-page-selector.js'; import './viewer-page-selector.js';
...@@ -14,7 +13,9 @@ import './shared-css.js'; ...@@ -14,7 +13,9 @@ import './shared-css.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
class ViewerPdfToolbarNewElement extends PolymerElement { import {FittingType} from '../constants.js';
export class ViewerPdfToolbarNewElement extends PolymerElement {
static get is() { static get is() {
return 'viewer-pdf-toolbar-new'; return 'viewer-pdf-toolbar-new';
} }
...@@ -45,16 +46,47 @@ class ViewerPdfToolbarNewElement extends PolymerElement { ...@@ -45,16 +46,47 @@ class ViewerPdfToolbarNewElement extends PolymerElement {
pdfAnnotationsEnabled: Boolean, pdfAnnotationsEnabled: Boolean,
pdfFormSaveEnabled: Boolean, pdfFormSaveEnabled: Boolean,
printingEnabled: Boolean, printingEnabled: Boolean,
fittingType_: Number,
/** @private {string} */
fitToButtonIcon_: {
type: String,
computed: 'computeFitToButtonIcon_(fittingType_)',
},
}; };
} }
constructor() { constructor() {
super(); super();
/** @private {!FittingType} */
this.fittingType_ = FittingType.FIT_TO_PAGE;
/** @private {boolean} */ /** @private {boolean} */
this.loading_ = true; this.loading_ = true;
} }
/**
* @return {string}
* @private
*/
computeFitToButtonIcon_() {
return this.fittingType_ === FittingType.FIT_TO_PAGE ? 'pdf:fit-to-height' :
'pdf:fit-to-width';
}
/**
* @param {string} fitToPageTooltip
* @param {string} fitToWidthTooltip
* @return {string} The appropriate tooltip for the current state
* @private
*/
getFitToButtonTooltip_(fitToPageTooltip, fitToWidthTooltip) {
return this.fittingType_ === FittingType.FIT_TO_PAGE ? fitToPageTooltip :
fitToWidthTooltip;
}
/** @private */ /** @private */
loadProgressChanged_() { loadProgressChanged_() {
this.loading_ = this.loadProgress < 100; this.loading_ = this.loadProgress < 100;
...@@ -64,6 +96,35 @@ class ViewerPdfToolbarNewElement extends PolymerElement { ...@@ -64,6 +96,35 @@ class ViewerPdfToolbarNewElement extends PolymerElement {
onPrintClick_() { onPrintClick_() {
this.dispatchEvent(new CustomEvent('print')); this.dispatchEvent(new CustomEvent('print'));
} }
/** @private */
onZoomInClick_() {
this.dispatchEvent(new CustomEvent('zoom-in'));
}
/** @private */
onZoomOutClick_() {
this.dispatchEvent(new CustomEvent('zoom-out'));
}
/** @param {!FittingType} fittingType */
forceFit(fittingType) {
this.fittingType_ = fittingType;
}
fitToggle() {
const newState = this.fittingType_ === FittingType.FIT_TO_PAGE ?
FittingType.FIT_TO_WIDTH :
FittingType.FIT_TO_PAGE;
this.dispatchEvent(
new CustomEvent('fit-to-changed', {detail: this.fittingType_}));
this.fittingType_ = newState;
}
/** @private */
onFitToButtonClick_() {
this.fitToggle();
}
} }
customElements.define( customElements.define(
......
...@@ -14,14 +14,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun ...@@ -14,14 +14,6 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
import {FittingType} from '../constants.js'; import {FittingType} from '../constants.js';
/**
* @typedef {{
* fittingType: !FittingType,
* userInitiated: boolean,
* }}
*/
export let FitToChangedEvent;
const FIT_TO_PAGE_BUTTON_STATE = 0; const FIT_TO_PAGE_BUTTON_STATE = 0;
const FIT_TO_WIDTH_BUTTON_STATE = 1; const FIT_TO_WIDTH_BUTTON_STATE = 1;
...@@ -92,8 +84,7 @@ Polymer({ ...@@ -92,8 +84,7 @@ Polymer({
this.fireFitToChangedEvent_( this.fireFitToChangedEvent_(
this.$['fit-button'].activeIndex === FIT_TO_WIDTH_BUTTON_STATE ? this.$['fit-button'].activeIndex === FIT_TO_WIDTH_BUTTON_STATE ?
FittingType.FIT_TO_WIDTH : FittingType.FIT_TO_WIDTH :
FittingType.FIT_TO_PAGE, FittingType.FIT_TO_PAGE);
true);
}, },
/** Handle the keyboard shortcut equivalent of fit-button clicks. */ /** Handle the keyboard shortcut equivalent of fit-button clicks. */
...@@ -113,8 +104,6 @@ Polymer({ ...@@ -113,8 +104,6 @@ Polymer({
* @param {!FittingType} fittingType Page fitting type to force. * @param {!FittingType} fittingType Page fitting type to force.
*/ */
forceFit(fittingType) { forceFit(fittingType) {
this.fireFitToChangedEvent_(fittingType, false);
// Set the button state since there was no mouse click. // Set the button state since there was no mouse click.
const nextButtonState = const nextButtonState =
(fittingType === FittingType.FIT_TO_WIDTH ? FIT_TO_PAGE_BUTTON_STATE : (fittingType === FittingType.FIT_TO_WIDTH ? FIT_TO_PAGE_BUTTON_STATE :
...@@ -125,14 +114,10 @@ Polymer({ ...@@ -125,14 +114,10 @@ Polymer({
/** /**
* Fire a 'fit-to-changed' {CustomEvent} with the given FittingType as detail. * Fire a 'fit-to-changed' {CustomEvent} with the given FittingType as detail.
* @param {!FittingType} fittingType to include as payload. * @param {!FittingType} fittingType to include as payload.
* @param {boolean} userInitiated whether the event was initiated by a user
* action.
* @private * @private
*/ */
fireFitToChangedEvent_(fittingType, userInitiated) { fireFitToChangedEvent_(fittingType) {
this.fire( this.fire('fit-to-changed', fittingType);
'fit-to-changed',
{fittingType: fittingType, userInitiated: userInitiated});
}, },
/** Handle clicks of the zoom-in-button. */ /** Handle clicks of the zoom-in-button. */
......
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
pdf-form-save-enabled="[[pdfFormSaveEnabled_]]" pdf-form-save-enabled="[[pdfFormSaveEnabled_]]"
printing-enabled="[[printingEnabled_]]" printing-enabled="[[printingEnabled_]]"
is-form-field-focused="[[isFormFieldFocused_]]" is-form-field-focused="[[isFormFieldFocused_]]"
on-fit-to-changed="onFitToChanged"
on-zoom-in="onZoomIn" on-zoom-out="onZoomOut"
on-print="onPrint_" on-save="onToolbarSave_" hidden> on-print="onPrint_" on-save="onToolbarSave_" hidden>
</viewer-pdf-toolbar-new> </viewer-pdf-toolbar-new>
</template> </template>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import './elements/viewer-error-screen.js'; import './elements/viewer-error-screen.js';
import './elements/viewer-password-screen.js'; import './elements/viewer-password-screen.js';
import './elements/viewer-pdf-toolbar.js'; import './elements/viewer-pdf-toolbar.js';
import './elements/viewer-pdf-toolbar-new.js'; import './elements/viewer-zoom-toolbar.js';
import './elements/shared-vars.js'; import './elements/shared-vars.js';
// <if expr="chromeos"> // <if expr="chromeos">
import './elements/viewer-ink-host.js'; import './elements/viewer-ink-host.js';
...@@ -21,6 +21,10 @@ import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min. ...@@ -21,6 +21,10 @@ import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.
import {Bookmark} from './bookmark_type.js'; import {Bookmark} from './bookmark_type.js';
import {BrowserApi} from './browser_api.js'; import {BrowserApi} from './browser_api.js';
import {FittingType, SaveRequestType, TwoUpViewAction} from './constants.js'; import {FittingType, SaveRequestType, TwoUpViewAction} from './constants.js';
import {ViewerPdfToolbarNewElement} from './elements/viewer-pdf-toolbar-new.js';
// <if expr="chromeos">
import {InkController} from './ink_controller.js';
//</if>
import {PDFMetrics} from './metrics.js'; import {PDFMetrics} from './metrics.js';
import {NavigatorDelegate, PdfNavigator} from './navigator.js'; import {NavigatorDelegate, PdfNavigator} from './navigator.js';
import {OpenPdfParamsParser} from './open_pdf_params_parser.js'; import {OpenPdfParamsParser} from './open_pdf_params_parser.js';
...@@ -30,10 +34,6 @@ import {DestinationMessageData, DocumentDimensionsMessageData, shouldIgnoreKeyEv ...@@ -30,10 +34,6 @@ import {DestinationMessageData, DocumentDimensionsMessageData, shouldIgnoreKeyEv
import {ToolbarManager} from './toolbar_manager.js'; import {ToolbarManager} from './toolbar_manager.js';
import {Point} from './viewport.js'; import {Point} from './viewport.js';
// <if expr="chromeos">
import {InkController} from './ink_controller.js';
// </if>
/** /**
* @typedef {{ * @typedef {{
...@@ -267,6 +267,15 @@ class PDFViewerElement extends PDFViewerBaseElement { ...@@ -267,6 +267,15 @@ class PDFViewerElement extends PDFViewerBaseElement {
return /** @type {!ViewerPdfToolbarElement} */ (this.$$('#toolbar')); return /** @type {!ViewerPdfToolbarElement} */ (this.$$('#toolbar'));
} }
/**
* @return {!ViewerPdfToolbarNewElement}
* @private
*/
getToolbarNew_() {
assert(this.pdfViewerUpdateEnabled_);
return /** @type {!ViewerPdfToolbarNewElement} */ (this.$$('#toolbar'));
}
/** /**
* @return {!ViewerZoomToolbarElement} * @return {!ViewerZoomToolbarElement}
* @private * @private
...@@ -356,7 +365,10 @@ class PDFViewerElement extends PDFViewerBaseElement { ...@@ -356,7 +365,10 @@ class PDFViewerElement extends PDFViewerBaseElement {
*/ */
handleToolbarKeyEvent_(e) { handleToolbarKeyEvent_(e) {
if (this.pdfViewerUpdateEnabled_) { if (this.pdfViewerUpdateEnabled_) {
// TODO: Add handling for any relevant hotkeys for the new unified if (e.key === '\\' && e.ctrlKey) {
this.getToolbarNew_().fitToggle();
}
// TODO: Add handling for additional relevant hotkeys for the new unified
// toolbar. // toolbar.
return; return;
} }
...@@ -515,8 +527,8 @@ class PDFViewerElement extends PDFViewerBaseElement { ...@@ -515,8 +527,8 @@ class PDFViewerElement extends PDFViewerBaseElement {
return; return;
} }
if (e.detail.fittingType === FittingType.FIT_TO_PAGE || if (e.detail === FittingType.FIT_TO_PAGE ||
e.detail.fittingType === FittingType.FIT_TO_HEIGHT) { e.detail === FittingType.FIT_TO_HEIGHT) {
this.toolbarManager_.forceHideTopToolbar(); this.toolbarManager_.forceHideTopToolbar();
} }
} }
...@@ -702,9 +714,14 @@ class PDFViewerElement extends PDFViewerBaseElement { ...@@ -702,9 +714,14 @@ class PDFViewerElement extends PDFViewerBaseElement {
/** @override */ /** @override */
forceFit(view) { forceFit(view) {
if (!this.pdfViewerUpdateEnabled_) { if (!this.pdfViewerUpdateEnabled_) {
if (view === FittingType.FIT_TO_PAGE ||
view === FittingType.FIT_TO_HEIGHT) {
this.toolbarManager_.forceHideTopToolbar();
}
this.getZoomToolbar_().forceFit(view); this.getZoomToolbar_().forceFit(view);
} else {
this.getToolbarNew_().forceFit(view);
} }
// TODO: Add handling for the case where the new toolbar is enabled.
} }
/** @override */ /** @override */
......
...@@ -11,7 +11,6 @@ import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/poly ...@@ -11,7 +11,6 @@ import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/poly
import {BrowserApi} from './browser_api.js'; import {BrowserApi} from './browser_api.js';
import {FittingType} from './constants.js'; import {FittingType} from './constants.js';
import {ContentController, MessageData, PluginController} from './controller.js'; import {ContentController, MessageData, PluginController} from './controller.js';
import {FitToChangedEvent} from './elements/viewer-zoom-toolbar.js';
import {PDFMetrics} from './metrics.js'; import {PDFMetrics} from './metrics.js';
import {OpenPdfParamsParser} from './open_pdf_params_parser.js'; import {OpenPdfParamsParser} from './open_pdf_params_parser.js';
import {LoadState} from './pdf_scripting_api.js'; import {LoadState} from './pdf_scripting_api.js';
...@@ -502,6 +501,7 @@ export class PDFViewerBaseElement extends PolymerElement { ...@@ -502,6 +501,7 @@ export class PDFViewerBaseElement extends PolymerElement {
if (params.view) { if (params.view) {
this.isUserInitiatedEvent = false; this.isUserInitiatedEvent = false;
this.updateViewportFit(params.view);
this.forceFit(params.view); this.forceFit(params.view);
if (params.viewPosition) { if (params.viewPosition) {
const zoomedPositionShift = const zoomedPositionShift =
...@@ -562,22 +562,27 @@ export class PDFViewerBaseElement extends PolymerElement { ...@@ -562,22 +562,27 @@ export class PDFViewerBaseElement extends PolymerElement {
} }
/** /**
* Request to change the viewport fitting type. * @param {!FittingType} fittingType
* @param {!CustomEvent<FitToChangedEvent>} e
* @protected * @protected
*/ */
onFitToChanged(e) { updateViewportFit(fittingType) {
if (e.detail.fittingType === FittingType.FIT_TO_PAGE) { if (fittingType === FittingType.FIT_TO_PAGE) {
this.viewport_.fitToPage(); this.viewport_.fitToPage();
} else if (e.detail.fittingType === FittingType.FIT_TO_WIDTH) { } else if (fittingType === FittingType.FIT_TO_WIDTH) {
this.viewport_.fitToWidth(); this.viewport_.fitToWidth();
} else if (e.detail.fittingType === FittingType.FIT_TO_HEIGHT) { } else if (fittingType === FittingType.FIT_TO_HEIGHT) {
this.viewport_.fitToHeight(); this.viewport_.fitToHeight();
} }
}
if (e.detail.userInitiated) { /**
PDFMetrics.recordFitTo(e.detail.fittingType); * Request to change the viewport fitting type.
} * @param {!CustomEvent<!FittingType>} e
* @protected
*/
onFitToChanged(e) {
this.updateViewportFit(e.detail);
PDFMetrics.recordFitTo(e.detail);
} }
/** @protected */ /** @protected */
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import './elements/viewer-error-screen.js'; import './elements/viewer-error-screen.js';
import './elements/viewer-page-indicator.js'; import './elements/viewer-page-indicator.js';
import './elements/viewer-zoom-toolbar.js';
import './elements/shared-vars.js'; import './elements/shared-vars.js';
import './pdf_viewer_shared_style.js'; import './pdf_viewer_shared_style.js';
...@@ -239,6 +240,7 @@ class PDFViewerPPElement extends PDFViewerBaseElement { ...@@ -239,6 +240,7 @@ class PDFViewerPPElement extends PDFViewerBaseElement {
this.inPrintPreviewMode_ = true; this.inPrintPreviewMode_ = true;
this.isUserInitiatedEvent = false; this.isUserInitiatedEvent = false;
this.forceFit(FittingType.FIT_TO_PAGE); this.forceFit(FittingType.FIT_TO_PAGE);
this.updateViewportFit(FittingType.FIT_TO_PAGE);
this.isUserInitiatedEvent = true; this.isUserInitiatedEvent = true;
} }
......
...@@ -20,12 +20,10 @@ class FitToEventChecker { ...@@ -20,12 +20,10 @@ class FitToEventChecker {
/** /**
* Asserts the last event has the expected payload. * Asserts the last event has the expected payload.
* @param {FittingType} fittingType Expected fitting type. * @param {FittingType} fittingType Expected fitting type.
* @param {boolean} userInitiated Expected "is user initiated" flag.
*/ */
assertEvent(fittingType, userInitiated) { assertEvent(fittingType) {
chrome.test.assertEq('fit-to-changed', this.lastEvent_.type); chrome.test.assertEq('fit-to-changed', this.lastEvent_.type);
chrome.test.assertEq(fittingType, this.lastEvent_.detail.fittingType); chrome.test.assertEq(fittingType, this.lastEvent_.detail);
chrome.test.assertEq(userInitiated, this.lastEvent_.detail.userInitiated);
this.lastEvent_ = null; this.lastEvent_ = null;
} }
} }
...@@ -240,27 +238,24 @@ const tests = [ ...@@ -240,27 +238,24 @@ const tests = [
// Test forceFit(FIT_TO_PAGE) from initial state. // Test forceFit(FIT_TO_PAGE) from initial state.
zoomToolbar.forceFit(FittingType.FIT_TO_PAGE); zoomToolbar.forceFit(FittingType.FIT_TO_PAGE);
fitToEventChecker.assertEvent(FittingType.FIT_TO_PAGE, false);
chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon));
// Tap 1: Fire fit-to-changed(FIT_TO_WIDTH). // Tap 1: Fire fit-to-changed(FIT_TO_WIDTH).
button.click(); button.click();
fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH, true); fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH);
chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon));
// Test forceFit(FIT_TO_PAGE) from fit-to-width mode. // Test forceFit(FIT_TO_PAGE) from fit-to-width mode.
zoomToolbar.forceFit(FittingType.FIT_TO_PAGE); zoomToolbar.forceFit(FittingType.FIT_TO_PAGE);
fitToEventChecker.assertEvent(FittingType.FIT_TO_PAGE, false);
chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon));
// Test forceFit(FIT_TO_PAGE) when already in fit-to-page mode. // Test forceFit(FIT_TO_PAGE) when already in fit-to-page mode.
zoomToolbar.forceFit(FittingType.FIT_TO_PAGE); zoomToolbar.forceFit(FittingType.FIT_TO_PAGE);
fitToEventChecker.assertEvent(FittingType.FIT_TO_PAGE, false);
chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon));
// Tap 2: Fire fit-to-changed(FIT_TO_WIDTH). // Tap 2: Fire fit-to-changed(FIT_TO_WIDTH).
button.click(); button.click();
fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH, true); fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH);
chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon));
chrome.test.succeed(); chrome.test.succeed();
...@@ -283,32 +278,29 @@ const tests = [ ...@@ -283,32 +278,29 @@ const tests = [
// Test forceFit(FIT_TO_WIDTH) from initial state. // Test forceFit(FIT_TO_WIDTH) from initial state.
zoomToolbar.forceFit(FittingType.FIT_TO_WIDTH); zoomToolbar.forceFit(FittingType.FIT_TO_WIDTH);
fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH, false);
chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon));
// Tap 1: Fire fit-to-changed(FIT_TO_PAGE). // Tap 1: Fire fit-to-changed(FIT_TO_PAGE).
button.click(); button.click();
fitToEventChecker.assertEvent(FittingType.FIT_TO_PAGE, true); fitToEventChecker.assertEvent(FittingType.FIT_TO_PAGE);
chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon));
// Tap 2: Fire fit-to-changed(FIT_TO_WIDTH). // Tap 2: Fire fit-to-changed(FIT_TO_WIDTH).
button.click(); button.click();
fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH, true); fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH);
chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon));
// Test forceFit(FIT_TO_WIDTH) from fit-to-width state. // Test forceFit(FIT_TO_WIDTH) from fit-to-width state.
zoomToolbar.forceFit(FittingType.FIT_TO_WIDTH); zoomToolbar.forceFit(FittingType.FIT_TO_WIDTH);
fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH, false);
chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon));
// Tap 3: Fire fit-to-changed(FIT_TO_PAGE). // Tap 3: Fire fit-to-changed(FIT_TO_PAGE).
button.click(); button.click();
fitToEventChecker.assertEvent(FittingType.FIT_TO_PAGE, true); fitToEventChecker.assertEvent(FittingType.FIT_TO_PAGE);
chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitWidthIcon));
// Test forceFit(FIT_TO_WIDTH) from fit-to-page state. // Test forceFit(FIT_TO_WIDTH) from fit-to-page state.
zoomToolbar.forceFit(FittingType.FIT_TO_WIDTH); zoomToolbar.forceFit(FittingType.FIT_TO_WIDTH);
fitToEventChecker.assertEvent(FittingType.FIT_TO_WIDTH, false);
chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon)); chrome.test.assertTrue(button.ironIcon.endsWith(fitPageIcon));
chrome.test.succeed(); chrome.test.succeed();
......
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