Commit 39d0586b authored by dpapad's avatar dpapad Committed by Chromium LUCI CQ

PDF Viewer: Remove PDFMetrics namespace and static functions.

Namespaces made sense in a pre-JS Module world, as a way to group
related functionality together. In the context of a JS module, it
no longer adds any benefit, as the client of a module can either
import explicitly only what is needed, or import all exported
functions with a namespace of their choice like

import * as foo from './module.js';

Bug: None
Change-Id: I6938c6fead73a1ef138e26183e2a880b95345a3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628070
Commit-Queue: John Lee <johntlee@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843744}
parent d5991890
......@@ -4,7 +4,7 @@
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {PDFMetrics, UserAction} from '../metrics.js';
import {record, UserAction} from '../metrics.js';
import {PAGE_SHADOW, Viewport} from '../viewport.js';
/** @enum {string} */
......@@ -173,18 +173,18 @@ Polymer({
if (e.type === 'pointerup') {
this.dispatchEvent(new CustomEvent('stroke-added'));
if (e.pointerType === 'mouse') {
PDFMetrics.record(UserAction.ANNOTATE_STROKE_DEVICE_MOUSE);
record(UserAction.ANNOTATE_STROKE_DEVICE_MOUSE);
} else if (e.pointerType === 'pen') {
PDFMetrics.record(UserAction.ANNOTATE_STROKE_DEVICE_PEN);
record(UserAction.ANNOTATE_STROKE_DEVICE_PEN);
} else if (e.pointerType === 'touch') {
PDFMetrics.record(UserAction.ANNOTATE_STROKE_DEVICE_TOUCH);
record(UserAction.ANNOTATE_STROKE_DEVICE_TOUCH);
}
if (this.tool_.tool === 'eraser') {
PDFMetrics.record(UserAction.ANNOTATE_STROKE_TOOL_ERASER);
record(UserAction.ANNOTATE_STROKE_TOOL_ERASER);
} else if (this.tool_.tool === 'pen') {
PDFMetrics.record(UserAction.ANNOTATE_STROKE_TOOL_PEN);
record(UserAction.ANNOTATE_STROKE_TOOL_PEN);
} else if (this.tool_.tool === 'highlighter') {
PDFMetrics.record(UserAction.ANNOTATE_STROKE_TOOL_HIGHLIGHTER);
record(UserAction.ANNOTATE_STROKE_TOOL_HIGHLIGHTER);
}
}
}
......
......@@ -14,7 +14,7 @@ import 'chrome://resources/cr_elements/shared_style_css.m.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {Bookmark} from '../bookmark_type.js';
import {PDFMetrics, UserAction} from '../metrics.js';
import {record, UserAction} from '../metrics.js';
export class ViewerPdfSidenavElement extends PolymerElement {
static get is() {
......@@ -49,13 +49,13 @@ export class ViewerPdfSidenavElement extends PolymerElement {
/** @private */
onThumbnailClick_() {
PDFMetrics.record(UserAction.SELECT_SIDENAV_THUMBNAILS);
record(UserAction.SELECT_SIDENAV_THUMBNAILS);
this.thumbnailView_ = true;
}
/** @private */
onOutlineClick_() {
PDFMetrics.record(UserAction.SELECT_SIDENAV_OUTLINE);
record(UserAction.SELECT_SIDENAV_OUTLINE);
this.thumbnailView_ = false;
}
......
......@@ -21,7 +21,7 @@ import {assert} from 'chrome://resources/js/assert.m.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {FittingType} from '../constants.js';
import {PDFMetrics, UserAction} from '../metrics.js';
import {record, UserAction} from '../metrics.js';
// <if expr="chromeos">
import {ViewerAnnotationsModeDialogElement} from './viewer-annotations-mode-dialog.js';
// </if>
......@@ -142,7 +142,7 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
/** @private */
onSidenavToggleClick_() {
PDFMetrics.record(UserAction.TOGGLE_SIDENAV);
record(UserAction.TOGGLE_SIDENAV);
this.dispatchEvent(new CustomEvent('sidenav-toggle-click'));
}
......@@ -206,7 +206,7 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
/** @private */
toggleDisplayAnnotations_() {
PDFMetrics.record(UserAction.TOGGLE_DISPLAY_ANNOTATIONS);
record(UserAction.TOGGLE_DISPLAY_ANNOTATIONS);
this.displayAnnotations_ = !this.displayAnnotations_;
this.dispatchEvent(new CustomEvent(
'display-annotations-changed', {detail: this.displayAnnotations_}));
......@@ -222,7 +222,7 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
/** @private */
onPresentClick_() {
assert(this.presentationModeEnabled);
PDFMetrics.record(UserAction.PRESENT);
record(UserAction.PRESENT);
this.getMenu_().close();
this.dispatchEvent(new CustomEvent('present-click'));
}
......@@ -230,7 +230,7 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
/** @private */
onPropertiesClick_() {
assert(this.documentPropertiesEnabled);
PDFMetrics.record(UserAction.PROPERTIES);
record(UserAction.PROPERTIES);
this.getMenu_().close();
this.dispatchEvent(new CustomEvent('properties-click'));
}
......
......@@ -5,71 +5,69 @@
import {FittingType} from './constants.js';
// Handles events specific to the PDF viewer and logs the corresponding metrics.
export class PDFMetrics {
/**
* Records when the zoom mode is changed to fit a FittingType.
* @param {FittingType} fittingType the new FittingType.
*/
static recordFitTo(fittingType) {
if (fittingType === FittingType.FIT_TO_PAGE) {
PDFMetrics.record(UserAction.FIT_TO_PAGE);
} else if (fittingType === FittingType.FIT_TO_WIDTH) {
PDFMetrics.record(UserAction.FIT_TO_WIDTH);
}
// There is no user action to do a fit-to-height, this only happens with
// the open param "view=FitV".
}
/**
* Records when the two up view mode is enabled or disabled.
* @param {boolean} enabled True when two up view mode is enabled.
*/
static recordTwoUpViewEnabled(enabled) {
PDFMetrics.record(
enabled ? UserAction.TWO_UP_VIEW_ENABLE :
UserAction.TWO_UP_VIEW_DISABLE);
/**
* Records when the zoom mode is changed to fit a FittingType.
* @param {FittingType} fittingType the new FittingType.
*/
export function recordFitTo(fittingType) {
if (fittingType === FittingType.FIT_TO_PAGE) {
record(UserAction.FIT_TO_PAGE);
} else if (fittingType === FittingType.FIT_TO_WIDTH) {
record(UserAction.FIT_TO_WIDTH);
}
// There is no user action to do a fit-to-height, this only happens with
// the open param "view=FitV".
}
/**
* Records zoom in and zoom out actions.
* @param {boolean} isZoomIn True when the action is zooming in, false when
* the action is zooming out.
*/
static recordZoomAction(isZoomIn) {
PDFMetrics.record(isZoomIn ? UserAction.ZOOM_IN : UserAction.ZOOM_OUT);
}
/**
* Records when the two up view mode is enabled or disabled.
* @param {boolean} enabled True when two up view mode is enabled.
*/
export function recordTwoUpViewEnabled(enabled) {
record(
enabled ? UserAction.TWO_UP_VIEW_ENABLE : UserAction.TWO_UP_VIEW_DISABLE);
}
/**
* Records the given action to chrome.metricsPrivate.
* @param {UserAction} action
*/
static record(action) {
if (!chrome.metricsPrivate) {
return;
}
if (!actionsMetric) {
actionsMetric = {
'metricName': 'PDF.Actions',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 1,
'max': UserAction.NUMBER_OF_ACTIONS,
'buckets': UserAction.NUMBER_OF_ACTIONS + 1
};
}
chrome.metricsPrivate.recordValue(actionsMetric, action);
if (firstMap.has(action)) {
const firstAction = firstMap.get(action);
if (!firstActionRecorded.has(firstAction)) {
chrome.metricsPrivate.recordValue(actionsMetric, firstAction);
firstActionRecorded.add(firstAction);
}
/**
* Records zoom in and zoom out actions.
* @param {boolean} isZoomIn True when the action is zooming in, false when
* the action is zooming out.
*/
export function recordZoomAction(isZoomIn) {
record(isZoomIn ? UserAction.ZOOM_IN : UserAction.ZOOM_OUT);
}
/**
* Records the given action to chrome.metricsPrivate.
* @param {UserAction} action
*/
export function record(action) {
if (!chrome.metricsPrivate) {
return;
}
if (!actionsMetric) {
actionsMetric = {
'metricName': 'PDF.Actions',
'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
'min': 1,
'max': UserAction.NUMBER_OF_ACTIONS,
'buckets': UserAction.NUMBER_OF_ACTIONS + 1
};
}
chrome.metricsPrivate.recordValue(actionsMetric, action);
if (firstMap.has(action)) {
const firstAction = firstMap.get(action);
if (!firstActionRecorded.has(firstAction)) {
chrome.metricsPrivate.recordValue(actionsMetric, firstAction);
firstActionRecorded.add(firstAction);
}
}
}
static resetForTesting() {
firstActionRecorded.clear();
actionsMetric = null;
}
export function resetForTesting() {
firstActionRecorded.clear();
actionsMetric = null;
}
/** @type {?chrome.metricsPrivate.MetricType} */
......@@ -82,9 +80,9 @@ const firstActionRecorded = new Set();
// Do not change the numeric values or reuse them since these numbers are
// persisted to logs.
/**
* User Actions that can be recorded by calling PDFMetrics.record.
* User Actions that can be recorded by calling record.
* The *_FIRST values are recorded automaticlly,
* eg. PDFMetrics.record(...ROTATE) will also record ROTATE_FIRST
* eg. record(...ROTATE) will also record ROTATE_FIRST
* on the first instance.
* @enum {number}
*/
......
......@@ -32,7 +32,7 @@ import {ViewerPdfToolbarNewElement} from './elements/viewer-pdf-toolbar-new.js';
import {InkController, InkControllerEventType} from './ink_controller.js';
//</if>
import {LocalStorageProxyImpl} from './local_storage_proxy.js';
import {PDFMetrics, UserAction} from './metrics.js';
import {record, recordTwoUpViewEnabled, UserAction} from './metrics.js';
import {NavigatorDelegateImpl, PdfNavigator, WindowOpenDisposition} from './navigator.js';
import {OpenPdfParamsParser} from './open_pdf_params_parser.js';
import {DeserializeKeyEvent, LoadState, SerializeKeyEvent} from './pdf_scripting_api.js';
......@@ -626,7 +626,7 @@ export class PDFViewerElement extends PDFViewerBaseElement {
return;
}
}
PDFMetrics.record(UserAction.ENTER_ANNOTATION_MODE);
record(UserAction.ENTER_ANNOTATION_MODE);
this.annotationMode_ = true;
this.hasEnteredAnnotationMode_ = true;
// TODO(dstockwell): feed real progress data from the Ink component
......@@ -637,7 +637,7 @@ export class PDFViewerElement extends PDFViewerBaseElement {
this.updateProgress(100);
} else {
// Exit annotation mode.
PDFMetrics.record(UserAction.EXIT_ANNOTATION_MODE);
record(UserAction.EXIT_ANNOTATION_MODE);
assert(!this.pluginController_.isActive);
assert(this.inkController_.isActive);
assert(this.currentController === this.inkController_);
......@@ -780,7 +780,7 @@ export class PDFViewerElement extends PDFViewerBaseElement {
if (!this.pdfViewerUpdateEnabled_) {
this.toolbarManager_.forceHideTopToolbar();
}
PDFMetrics.recordTwoUpViewEnabled(this.twoUpViewEnabled_);
recordTwoUpViewEnabled(this.twoUpViewEnabled_);
}
/**
......@@ -795,7 +795,7 @@ export class PDFViewerElement extends PDFViewerBaseElement {
goToPageAndXY_(origin, page, message) {
this.viewport.goToPageAndXY(page, message.x, message.y);
if (origin === 'bookmark') {
PDFMetrics.record(UserAction.FOLLOW_BOOKMARK);
record(UserAction.FOLLOW_BOOKMARK);
}
}
......@@ -1170,11 +1170,11 @@ export class PDFViewerElement extends PDFViewerBaseElement {
onChangePage_(e) {
this.viewport.goToPage(e.detail.page);
if (e.detail.origin === 'bookmark') {
PDFMetrics.record(UserAction.FOLLOW_BOOKMARK);
record(UserAction.FOLLOW_BOOKMARK);
} else if (e.detail.origin === 'pageselector') {
PDFMetrics.record(UserAction.PAGE_SELECTOR_NAVIGATE);
record(UserAction.PAGE_SELECTOR_NAVIGATE);
} else if (e.detail.origin === 'thumbnail') {
PDFMetrics.record(UserAction.THUMBNAIL_NAVIGATE);
record(UserAction.THUMBNAIL_NAVIGATE);
}
}
......@@ -1194,7 +1194,7 @@ export class PDFViewerElement extends PDFViewerBaseElement {
*/
onDropdownOpened_(e) {
if (e.detail === 'bookmarks') {
PDFMetrics.record(UserAction.OPEN_BOOKMARKS_PANEL);
record(UserAction.OPEN_BOOKMARKS_PANEL);
}
}
......@@ -1292,25 +1292,25 @@ export class PDFViewerElement extends PDFViewerBaseElement {
* @private
*/
recordSaveMetrics_(requestType) {
PDFMetrics.record(UserAction.SAVE);
record(UserAction.SAVE);
switch (requestType) {
case SaveRequestType.ANNOTATION:
PDFMetrics.record(UserAction.SAVE_WITH_ANNOTATION);
record(UserAction.SAVE_WITH_ANNOTATION);
break;
case SaveRequestType.ORIGINAL:
PDFMetrics.record(
record(
this.hasEdits_ ? UserAction.SAVE_ORIGINAL :
UserAction.SAVE_ORIGINAL_ONLY);
break;
case SaveRequestType.EDITED:
PDFMetrics.record(UserAction.SAVE_EDITED);
record(UserAction.SAVE_EDITED);
break;
}
}
/** @private */
async onPrint_() {
PDFMetrics.record(UserAction.PRINT);
record(UserAction.PRINT);
// <if expr="chromeos">
await this.exitAnnotationMode_();
// </if>
......
......@@ -11,7 +11,7 @@ import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/poly
import {BrowserApi, ZoomBehavior} from './browser_api.js';
import {FittingType, Point} from './constants.js';
import {ContentController, MessageData, PluginController, PluginControllerEventType} from './controller.js';
import {PDFMetrics, UserAction} from './metrics.js';
import {record, recordFitTo, recordZoomAction, UserAction} from './metrics.js';
import {OpenPdfParams, OpenPdfParamsParser} from './open_pdf_params_parser.js';
import {LoadState} from './pdf_scripting_api.js';
import {DocumentDimensionsMessageData, MessageObject} from './pdf_viewer_utils.js';
......@@ -214,7 +214,7 @@ export class PDFViewerBaseElement extends PolymerElement {
this.browserApi = browserApi;
this.originalUrl = this.browserApi.getStreamInfo().originalUrl;
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
record(UserAction.DOCUMENT_OPENED);
// Parse open pdf parameters.
this.paramsParser = new OpenPdfParamsParser(destination => {
......@@ -595,13 +595,13 @@ export class PDFViewerBaseElement extends PolymerElement {
*/
onFitToChanged(e) {
this.updateViewportFit(e.detail);
PDFMetrics.recordFitTo(e.detail);
recordFitTo(e.detail);
}
/** @protected */
onZoomIn() {
this.viewport_.zoomIn();
PDFMetrics.recordZoomAction(/*isZoomIn=*/ true);
recordZoomAction(/*isZoomIn=*/ true);
}
/**
......@@ -610,13 +610,13 @@ export class PDFViewerBaseElement extends PolymerElement {
*/
onZoomChanged(e) {
this.viewport_.setZoom(e.detail / 100);
PDFMetrics.record(UserAction.ZOOM_CUSTOM);
record(UserAction.ZOOM_CUSTOM);
}
/** @protected */
onZoomOut() {
this.viewport_.zoomOut();
PDFMetrics.recordZoomAction(/*isZoomIn=*/ false);
recordZoomAction(/*isZoomIn=*/ false);
}
/**
......@@ -639,14 +639,14 @@ export class PDFViewerBaseElement extends PolymerElement {
/** @protected */
rotateClockwise() {
PDFMetrics.record(UserAction.ROTATE);
record(UserAction.ROTATE);
this.viewport_.rotateClockwise();
this.currentController.rotateClockwise();
}
/** @protected */
rotateCounterclockwise() {
PDFMetrics.record(UserAction.ROTATE);
record(UserAction.ROTATE);
this.viewport_.rotateCounterclockwise();
this.currentController.rotateCounterclockwise();
}
......
......@@ -13,7 +13,7 @@ export {ViewerPropertiesDialogElement} from './elements/viewer-properties-dialog
export {ViewerThumbnailBarElement} from './elements/viewer-thumbnail-bar.js';
export {PAINTED_ATTRIBUTE, ViewerThumbnailElement} from './elements/viewer-thumbnail.js';
export {GestureDetector, PinchEventDetail} from './gesture_detector.js';
export {PDFMetrics, UserAction} from './metrics.js';
export {record, recordFitTo, recordTwoUpViewEnabled, recordZoomAction, resetForTesting, UserAction} from './metrics.js';
export {NavigatorDelegate, PdfNavigator, WindowOpenDisposition} from './navigator.js';
export {OpenPdfParamsParser} from './open_pdf_params_parser.js';
export {PDFScriptingAPI} from './pdf_scripting_api.js';
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {FittingType, PDFMetrics, UserAction} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {FittingType, record, recordFitTo, recordTwoUpViewEnabled, recordZoomAction, resetForTesting, UserAction} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
chrome.test.runTests(function() {
'use strict';
......@@ -25,11 +25,11 @@ chrome.test.runTests(function() {
return [
function testMetricsDocumentOpened() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
record(UserAction.DOCUMENT_OPENED);
chrome.test.assertEq(
{[UserAction.DOCUMENT_OPENED]: 1},
......@@ -38,12 +38,12 @@ chrome.test.runTests(function() {
},
function testMetricsRotation() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
record(UserAction.DOCUMENT_OPENED);
for (let i = 0; i < 4; i++) {
PDFMetrics.record(UserAction.ROTATE);
record(UserAction.ROTATE);
}
chrome.test.assertEq(
......@@ -57,16 +57,16 @@ chrome.test.runTests(function() {
},
function testMetricsFitTo() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
PDFMetrics.recordFitTo(FittingType.FIT_TO_HEIGHT);
PDFMetrics.recordFitTo(FittingType.FIT_TO_PAGE);
PDFMetrics.recordFitTo(FittingType.FIT_TO_WIDTH);
PDFMetrics.recordFitTo(FittingType.FIT_TO_PAGE);
PDFMetrics.recordFitTo(FittingType.FIT_TO_WIDTH);
PDFMetrics.recordFitTo(FittingType.FIT_TO_PAGE);
record(UserAction.DOCUMENT_OPENED);
recordFitTo(FittingType.FIT_TO_HEIGHT);
recordFitTo(FittingType.FIT_TO_PAGE);
recordFitTo(FittingType.FIT_TO_WIDTH);
recordFitTo(FittingType.FIT_TO_PAGE);
recordFitTo(FittingType.FIT_TO_WIDTH);
recordFitTo(FittingType.FIT_TO_PAGE);
chrome.test.assertEq(
{
......@@ -81,15 +81,15 @@ chrome.test.runTests(function() {
},
function testMetricsTwoUpView() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
PDFMetrics.recordTwoUpViewEnabled(true);
PDFMetrics.recordTwoUpViewEnabled(false);
PDFMetrics.recordTwoUpViewEnabled(true);
PDFMetrics.recordTwoUpViewEnabled(false);
PDFMetrics.recordTwoUpViewEnabled(true);
record(UserAction.DOCUMENT_OPENED);
recordTwoUpViewEnabled(true);
recordTwoUpViewEnabled(false);
recordTwoUpViewEnabled(true);
recordTwoUpViewEnabled(false);
recordTwoUpViewEnabled(true);
chrome.test.assertEq(
{
......@@ -104,17 +104,17 @@ chrome.test.runTests(function() {
},
function testMetricsZoomAction() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
PDFMetrics.recordZoomAction(/*isZoomIn=*/ true);
PDFMetrics.recordZoomAction(/*isZoomIn=*/ false);
PDFMetrics.recordZoomAction(/*isZoomIn=*/ true);
PDFMetrics.recordZoomAction(/*isZoomIn=*/ false);
PDFMetrics.recordZoomAction(/*isZoomIn=*/ true);
PDFMetrics.record(UserAction.ZOOM_CUSTOM);
PDFMetrics.record(UserAction.ZOOM_CUSTOM);
record(UserAction.DOCUMENT_OPENED);
recordZoomAction(/*isZoomIn=*/ true);
recordZoomAction(/*isZoomIn=*/ false);
recordZoomAction(/*isZoomIn=*/ true);
recordZoomAction(/*isZoomIn=*/ false);
recordZoomAction(/*isZoomIn=*/ true);
record(UserAction.ZOOM_CUSTOM);
record(UserAction.ZOOM_CUSTOM);
chrome.test.assertEq(
{
......@@ -131,19 +131,19 @@ chrome.test.runTests(function() {
},
function testMetricsBookmarks() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
record(UserAction.DOCUMENT_OPENED);
PDFMetrics.record(UserAction.OPEN_BOOKMARKS_PANEL);
PDFMetrics.record(UserAction.FOLLOW_BOOKMARK);
PDFMetrics.record(UserAction.FOLLOW_BOOKMARK);
record(UserAction.OPEN_BOOKMARKS_PANEL);
record(UserAction.FOLLOW_BOOKMARK);
record(UserAction.FOLLOW_BOOKMARK);
PDFMetrics.record(UserAction.OPEN_BOOKMARKS_PANEL);
PDFMetrics.record(UserAction.FOLLOW_BOOKMARK);
PDFMetrics.record(UserAction.FOLLOW_BOOKMARK);
PDFMetrics.record(UserAction.FOLLOW_BOOKMARK);
record(UserAction.OPEN_BOOKMARKS_PANEL);
record(UserAction.FOLLOW_BOOKMARK);
record(UserAction.FOLLOW_BOOKMARK);
record(UserAction.FOLLOW_BOOKMARK);
chrome.test.assertEq(
{
......@@ -158,13 +158,13 @@ chrome.test.runTests(function() {
},
function testMetricsPageSelector() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
record(UserAction.DOCUMENT_OPENED);
PDFMetrics.record(UserAction.PAGE_SELECTOR_NAVIGATE);
PDFMetrics.record(UserAction.PAGE_SELECTOR_NAVIGATE);
record(UserAction.PAGE_SELECTOR_NAVIGATE);
record(UserAction.PAGE_SELECTOR_NAVIGATE);
chrome.test.assertEq(
{
......@@ -177,19 +177,19 @@ chrome.test.runTests(function() {
},
function testMetricsSideNav() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
record(UserAction.DOCUMENT_OPENED);
PDFMetrics.record(UserAction.TOGGLE_SIDENAV);
PDFMetrics.record(UserAction.TOGGLE_SIDENAV);
PDFMetrics.record(UserAction.TOGGLE_SIDENAV);
PDFMetrics.record(UserAction.SELECT_SIDENAV_OUTLINE);
PDFMetrics.record(UserAction.SELECT_SIDENAV_THUMBNAILS);
PDFMetrics.record(UserAction.SELECT_SIDENAV_THUMBNAILS);
PDFMetrics.record(UserAction.THUMBNAIL_NAVIGATE);
PDFMetrics.record(UserAction.THUMBNAIL_NAVIGATE);
record(UserAction.TOGGLE_SIDENAV);
record(UserAction.TOGGLE_SIDENAV);
record(UserAction.TOGGLE_SIDENAV);
record(UserAction.SELECT_SIDENAV_OUTLINE);
record(UserAction.SELECT_SIDENAV_THUMBNAILS);
record(UserAction.SELECT_SIDENAV_THUMBNAILS);
record(UserAction.THUMBNAIL_NAVIGATE);
record(UserAction.THUMBNAIL_NAVIGATE);
chrome.test.assertEq(
{
......@@ -208,29 +208,29 @@ chrome.test.runTests(function() {
},
function testMetricsSaving() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_ORIGINAL_ONLY);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_ORIGINAL_ONLY);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_ORIGINAL);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_EDITED);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_ORIGINAL);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_ORIGINAL);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_EDITED);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_WITH_ANNOTATION);
PDFMetrics.record(UserAction.SAVE);
PDFMetrics.record(UserAction.SAVE_WITH_ANNOTATION);
record(UserAction.DOCUMENT_OPENED);
record(UserAction.SAVE);
record(UserAction.SAVE_ORIGINAL_ONLY);
record(UserAction.SAVE);
record(UserAction.SAVE_ORIGINAL_ONLY);
record(UserAction.SAVE);
record(UserAction.SAVE_ORIGINAL);
record(UserAction.SAVE);
record(UserAction.SAVE_EDITED);
record(UserAction.SAVE);
record(UserAction.SAVE_ORIGINAL);
record(UserAction.SAVE);
record(UserAction.SAVE_ORIGINAL);
record(UserAction.SAVE);
record(UserAction.SAVE_EDITED);
record(UserAction.SAVE);
record(UserAction.SAVE_WITH_ANNOTATION);
record(UserAction.SAVE);
record(UserAction.SAVE_WITH_ANNOTATION);
chrome.test.assertEq(
{
......@@ -251,20 +251,20 @@ chrome.test.runTests(function() {
},
function testMetricsOverflowMenu() {
PDFMetrics.resetForTesting();
resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(UserAction.DOCUMENT_OPENED);
PDFMetrics.record(UserAction.TOGGLE_DISPLAY_ANNOTATIONS);
PDFMetrics.record(UserAction.PRESENT);
PDFMetrics.record(UserAction.PROPERTIES);
PDFMetrics.record(UserAction.PRESENT);
PDFMetrics.record(UserAction.PRESENT);
PDFMetrics.record(UserAction.PROPERTIES);
PDFMetrics.record(UserAction.TOGGLE_DISPLAY_ANNOTATIONS);
PDFMetrics.record(UserAction.PROPERTIES);
PDFMetrics.record(UserAction.PRESENT);
record(UserAction.DOCUMENT_OPENED);
record(UserAction.TOGGLE_DISPLAY_ANNOTATIONS);
record(UserAction.PRESENT);
record(UserAction.PROPERTIES);
record(UserAction.PRESENT);
record(UserAction.PRESENT);
record(UserAction.PROPERTIES);
record(UserAction.TOGGLE_DISPLAY_ANNOTATIONS);
record(UserAction.PROPERTIES);
record(UserAction.PRESENT);
chrome.test.assertEq(
{
......
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