| Index: chrome/test/data/webui/md_history/history_metrics_test.js
|
| diff --git a/chrome/test/data/webui/md_history/history_metrics_test.js b/chrome/test/data/webui/md_history/history_metrics_test.js
|
| index 9e272761035661b369c806f93cc7b390916f3d21..1f30a105bc9f22f4bc3e5a6f4aca548bb299c24c 100644
|
| --- a/chrome/test/data/webui/md_history/history_metrics_test.js
|
| +++ b/chrome/test/data/webui/md_history/history_metrics_test.js
|
| @@ -2,208 +2,195 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -cr.define('md_history.history_metrics_test', function() {
|
| - /**
|
| - * @constructor
|
| - * @extends {md_history.BrowserService}
|
| - */
|
| - var TestMetricsBrowserService = function() {
|
| - this.histogramMap = {};
|
| - this.actionMap = {};
|
| - };
|
| -
|
| - function registerTests() {
|
| - suite('Metrics', function() {
|
| - var service;
|
| - var app;
|
| - var histogramMap;
|
| - var actionMap;
|
| -
|
| - suiteSetup(function() {
|
| - disableLinkClicks();
|
| -
|
| - TestMetricsBrowserService.prototype = {
|
| - __proto__: md_history.BrowserService.prototype,
|
| -
|
| - /** @override */
|
| - recordHistogram: function(histogram, value, max) {
|
| - assertTrue(value < max);
|
| -
|
| - if (!(histogram in this.histogramMap))
|
| - this.histogramMap[histogram] = {};
|
| -
|
| - if (!(value in this.histogramMap[histogram]))
|
| - this.histogramMap[histogram][value] = 0;
|
| -
|
| - this.histogramMap[histogram][value]++;
|
| - },
|
| -
|
| - /** @override */
|
| - recordAction: function(action) {
|
| - if (!(action in this.actionMap))
|
| - this.actionMap[action] = 0
|
| -
|
| - this.actionMap[action]++;
|
| - },
|
| -
|
| - /** @override */
|
| - deleteItems: function() {
|
| - return PolymerTest.flushTasks();
|
| - }
|
| - };
|
| - });
|
| -
|
| - setup(function() {
|
| - md_history.BrowserService.instance_ = new TestMetricsBrowserService();
|
| - service = md_history.BrowserService.getInstance();
|
| -
|
| - actionMap = service.actionMap;
|
| - histogramMap = service.histogramMap;
|
| -
|
| - app = replaceApp();
|
| - updateSignInState(false);
|
| +/**
|
| + * @constructor
|
| + * @extends {md_history.BrowserService}
|
| + */
|
| +var TestMetricsBrowserService = function() {
|
| + this.histogramMap = {};
|
| + this.actionMap = {};
|
| +};
|
| +
|
| +suite('Metrics', function() {
|
| + var service;
|
| + var app;
|
| + var histogramMap;
|
| + var actionMap;
|
| +
|
| + suiteSetup(function() {
|
| + disableLinkClicks();
|
| +
|
| + TestMetricsBrowserService.prototype = {
|
| + __proto__: md_history.BrowserService.prototype,
|
| +
|
| + /** @override */
|
| + recordHistogram: function(histogram, value, max) {
|
| + assertTrue(value < max);
|
| +
|
| + if (!(histogram in this.histogramMap))
|
| + this.histogramMap[histogram] = {};
|
| +
|
| + if (!(value in this.histogramMap[histogram]))
|
| + this.histogramMap[histogram][value] = 0;
|
| +
|
| + this.histogramMap[histogram][value]++;
|
| + },
|
| +
|
| + /** @override */
|
| + recordAction: function(action) {
|
| + if (!(action in this.actionMap))
|
| + this.actionMap[action] = 0
|
| +
|
| + this.actionMap[action]++;
|
| + },
|
| +
|
| + /** @override */
|
| + deleteItems: function() {
|
| return PolymerTest.flushTasks();
|
| - });
|
| -
|
| - test('History.HistoryPageView', function() {
|
| - app.grouped_ = true;
|
| -
|
| - var histogram = histogramMap['History.HistoryPageView'];
|
| - assertEquals(1, histogram[HistoryPageViewHistogram.HISTORY]);
|
| -
|
| - app.selectedPage_ = 'syncedTabs';
|
| - assertEquals(1, histogram[HistoryPageViewHistogram.SIGNIN_PROMO]);
|
| - updateSignInState(true);
|
| - return PolymerTest.flushTasks().then(() => {
|
| - assertEquals(1, histogram[HistoryPageViewHistogram.SYNCED_TABS]);
|
| - app.selectedPage_ = 'history';
|
| - assertEquals(2, histogram[HistoryPageViewHistogram.HISTORY]);
|
| - app.set('queryState_.range', HistoryRange.WEEK);
|
| - assertEquals(1, histogram[HistoryPageViewHistogram.GROUPED_WEEK]);
|
| - app.set('queryState_.range', HistoryRange.MONTH);
|
| - assertEquals(1, histogram[HistoryPageViewHistogram.GROUPED_MONTH]);
|
| - });
|
| - });
|
| -
|
| - test('history-list', function() {
|
| - var historyEntry =
|
| - createHistoryEntry('2015-01-01', 'http://www.google.com');
|
| - historyEntry.starred = true;
|
| - app.historyResult(createHistoryInfo(), [
|
| - createHistoryEntry('2015-01-01', 'http://www.example.com'),
|
| - historyEntry
|
| - ]);
|
| -
|
| - return PolymerTest.flushTasks().then(() => {
|
| - var items = polymerSelectAll(
|
| - app.$.history.$['infinite-list'], 'history-item');
|
| - MockInteractions.tap(items[1].$$('#bookmark-star'));
|
| - assertEquals(1, actionMap['BookmarkStarClicked']);
|
| - MockInteractions.tap(items[1].$.title);
|
| - assertEquals(1, actionMap['EntryLinkClick']);
|
| - assertEquals(
|
| - 1, histogramMap['HistoryPage.ClickPosition'][1]);
|
| - assertEquals(
|
| - 1, histogramMap['HistoryPage.ClickPositionSubset'][1]);
|
| -
|
| - app.set('queryState_.searchTerm', 'goog');
|
| - assertEquals(1, actionMap['Search']);
|
| - app.set('queryState_.incremental', true);
|
| - app.historyResult(createHistoryInfo('goog'), [
|
| - createHistoryEntry('2015-01-01', 'http://www.google.com'),
|
| - createHistoryEntry('2015-01-01', 'http://www.google.com'),
|
| - createHistoryEntry('2015-01-01', 'http://www.google.com')
|
| - ]);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - items = polymerSelectAll(
|
| - app.$.history.$['infinite-list'], 'history-item');
|
| - MockInteractions.tap(items[0].$.title);
|
| - assertEquals(1, actionMap['SearchResultClick']);
|
| - assertEquals(1, histogramMap['HistoryPage.ClickPosition'][0]);
|
| - assertEquals(1, histogramMap['HistoryPage.ClickPositionSubset'][0]);
|
| - MockInteractions.tap(items[0].$.checkbox);
|
| - MockInteractions.tap(items[4].$.checkbox);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
|
| - assertEquals(1, actionMap['RemoveSelected']);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - MockInteractions.tap(app.$.history.$$('.cancel-button'));
|
| - assertEquals(1, actionMap['CancelRemoveSelected']);
|
| - MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - MockInteractions.tap(app.$.history.$$('.action-button'));
|
| - assertEquals(1, actionMap['ConfirmRemoveSelected']);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - items = polymerSelectAll(
|
| - app.$.history.$['infinite-list'], 'history-item');
|
| - MockInteractions.tap(items[0].$['menu-button']);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - MockInteractions.tap(app.$.history.$$('#menuRemoveButton'));
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - assertEquals(
|
| - 1, histogramMap['HistoryPage.RemoveEntryPosition'][0]);
|
| - assertEquals(
|
| - 1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][0]);
|
| - });
|
| - });
|
| -
|
| - test('synced-device-manager', function() {
|
| - app.selectedPage_ = 'syncedTabs';
|
| - var histogram;
|
| - return PolymerTest.flushTasks().then(() => {
|
| - histogram =
|
| - histogramMap[SYNCED_TABS_HISTOGRAM_NAME];
|
| - assertEquals(1, histogram[SyncedTabsHistogram.INITIALIZED]);
|
| -
|
| - var sessionList = [
|
| - createSession(
|
| - 'Nexus 5',
|
| - [createWindow(['http://www.google.com', 'http://example.com'])]
|
| - ),
|
| - createSession(
|
| - 'Nexus 6',
|
| - [
|
| - createWindow(['http://test.com']),
|
| - createWindow(['http://www.gmail.com', 'http://badssl.com'])
|
| - ]
|
| - ),
|
| - ];
|
| - setForeignSessions(sessionList, true);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - assertEquals(1, histogram[SyncedTabsHistogram.HAS_FOREIGN_DATA]);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - cards = polymerSelectAll(
|
| - app.$$('#synced-devices'), 'history-synced-device-card');
|
| - MockInteractions.tap(cards[0].$['card-heading']);
|
| - assertEquals(1, histogram[SyncedTabsHistogram.COLLAPSE_SESSION]);
|
| - MockInteractions.tap(cards[0].$['card-heading']);
|
| - assertEquals(1, histogram[SyncedTabsHistogram.EXPAND_SESSION]);
|
| - MockInteractions.tap(polymerSelectAll(cards[0], '.website-title')[0]);
|
| - assertEquals(1, histogram[SyncedTabsHistogram.LINK_CLICKED]);
|
| -
|
| - MockInteractions.tap(cards[0].$['menu-button']);
|
| - return PolymerTest.flushTasks();
|
| - }).then(() => {
|
| - MockInteractions.tap(app.$$('#synced-devices').$$('#menuOpenButton'));
|
| - assertEquals(1, histogram[SyncedTabsHistogram.OPEN_ALL]);
|
| -
|
| - MockInteractions.tap(
|
| - app.$$('#synced-devices').$$('#menuDeleteButton'));
|
| - assertEquals(1, histogram[SyncedTabsHistogram.HIDE_FOR_NOW]);
|
| - });
|
| - });
|
| + }
|
| + };
|
| + });
|
| +
|
| + setup(function() {
|
| + md_history.BrowserService.instance_ = new TestMetricsBrowserService();
|
| + service = md_history.BrowserService.getInstance();
|
| +
|
| + actionMap = service.actionMap;
|
| + histogramMap = service.histogramMap;
|
| +
|
| + app = replaceApp();
|
| + updateSignInState(false);
|
| + return PolymerTest.flushTasks();
|
| + });
|
| +
|
| + test('History.HistoryPageView', function() {
|
| + app.grouped_ = true;
|
| +
|
| + var histogram = histogramMap['History.HistoryPageView'];
|
| + assertEquals(1, histogram[HistoryPageViewHistogram.HISTORY]);
|
| +
|
| + app.selectedPage_ = 'syncedTabs';
|
| + assertEquals(1, histogram[HistoryPageViewHistogram.SIGNIN_PROMO]);
|
| + updateSignInState(true);
|
| + return PolymerTest.flushTasks().then(() => {
|
| + assertEquals(1, histogram[HistoryPageViewHistogram.SYNCED_TABS]);
|
| + app.selectedPage_ = 'history';
|
| + assertEquals(2, histogram[HistoryPageViewHistogram.HISTORY]);
|
| + app.set('queryState_.range', HistoryRange.WEEK);
|
| + assertEquals(1, histogram[HistoryPageViewHistogram.GROUPED_WEEK]);
|
| + app.set('queryState_.range', HistoryRange.MONTH);
|
| + assertEquals(1, histogram[HistoryPageViewHistogram.GROUPED_MONTH]);
|
| });
|
| - }
|
| - return {
|
| - registerTests: registerTests
|
| - };
|
| + });
|
| +
|
| + test('history-list', function() {
|
| + var historyEntry =
|
| + createHistoryEntry('2015-01-01', 'http://www.google.com');
|
| + historyEntry.starred = true;
|
| + app.historyResult(createHistoryInfo(), [
|
| + createHistoryEntry('2015-01-01', 'http://www.example.com'),
|
| + historyEntry
|
| + ]);
|
| +
|
| + return PolymerTest.flushTasks().then(() => {
|
| + var items = polymerSelectAll(
|
| + app.$.history.$['infinite-list'], 'history-item');
|
| + MockInteractions.tap(items[1].$$('#bookmark-star'));
|
| + assertEquals(1, actionMap['BookmarkStarClicked']);
|
| + MockInteractions.tap(items[1].$.title);
|
| + assertEquals(1, actionMap['EntryLinkClick']);
|
| + assertEquals(1, histogramMap['HistoryPage.ClickPosition'][1]);
|
| + assertEquals(1, histogramMap['HistoryPage.ClickPositionSubset'][1]);
|
| +
|
| + app.set('queryState_.searchTerm', 'goog');
|
| + assertEquals(1, actionMap['Search']);
|
| + app.set('queryState_.incremental', true);
|
| + app.historyResult(createHistoryInfo('goog'), [
|
| + createHistoryEntry('2015-01-01', 'http://www.google.com'),
|
| + createHistoryEntry('2015-01-01', 'http://www.google.com'),
|
| + createHistoryEntry('2015-01-01', 'http://www.google.com')
|
| + ]);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + items = polymerSelectAll(
|
| + app.$.history.$['infinite-list'], 'history-item');
|
| + MockInteractions.tap(items[0].$.title);
|
| + assertEquals(1, actionMap['SearchResultClick']);
|
| + assertEquals(1, histogramMap['HistoryPage.ClickPosition'][0]);
|
| + assertEquals(1, histogramMap['HistoryPage.ClickPositionSubset'][0]);
|
| + MockInteractions.tap(items[0].$.checkbox);
|
| + MockInteractions.tap(items[4].$.checkbox);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
|
| + assertEquals(1, actionMap['RemoveSelected']);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.history.$$('.cancel-button'));
|
| + assertEquals(1, actionMap['CancelRemoveSelected']);
|
| + MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.history.$$('.action-button'));
|
| + assertEquals(1, actionMap['ConfirmRemoveSelected']);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + items = polymerSelectAll(
|
| + app.$.history.$['infinite-list'], 'history-item');
|
| + MockInteractions.tap(items[0].$['menu-button']);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.history.$$('#menuRemoveButton'));
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + assertEquals(1, histogramMap['HistoryPage.RemoveEntryPosition'][0]);
|
| + assertEquals(1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][0]);
|
| + });
|
| + });
|
| +
|
| + test('synced-device-manager', function() {
|
| + app.selectedPage_ = 'syncedTabs';
|
| + var histogram;
|
| + return PolymerTest.flushTasks().then(() => {
|
| + histogram = histogramMap[SYNCED_TABS_HISTOGRAM_NAME];
|
| + assertEquals(1, histogram[SyncedTabsHistogram.INITIALIZED]);
|
| +
|
| + var sessionList = [
|
| + createSession(
|
| + 'Nexus 5',
|
| + [createWindow(['http://www.google.com', 'http://example.com'])]
|
| + ),
|
| + createSession(
|
| + 'Nexus 6',
|
| + [
|
| + createWindow(['http://test.com']),
|
| + createWindow(['http://www.gmail.com', 'http://badssl.com'])
|
| + ]
|
| + ),
|
| + ];
|
| + setForeignSessions(sessionList, true);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + assertEquals(1, histogram[SyncedTabsHistogram.HAS_FOREIGN_DATA]);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + cards = polymerSelectAll(
|
| + app.$$('#synced-devices'), 'history-synced-device-card');
|
| + MockInteractions.tap(cards[0].$['card-heading']);
|
| + assertEquals(1, histogram[SyncedTabsHistogram.COLLAPSE_SESSION]);
|
| + MockInteractions.tap(cards[0].$['card-heading']);
|
| + assertEquals(1, histogram[SyncedTabsHistogram.EXPAND_SESSION]);
|
| + MockInteractions.tap(polymerSelectAll(cards[0], '.website-title')[0]);
|
| + assertEquals(1, histogram[SyncedTabsHistogram.LINK_CLICKED]);
|
| +
|
| + MockInteractions.tap(cards[0].$['menu-button']);
|
| + return PolymerTest.flushTasks();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$$('#synced-devices').$$('#menuOpenButton'));
|
| + assertEquals(1, histogram[SyncedTabsHistogram.OPEN_ALL]);
|
| +
|
| + MockInteractions.tap(app.$$('#synced-devices').$$('#menuDeleteButton'));
|
| + assertEquals(1, histogram[SyncedTabsHistogram.HIDE_FOR_NOW]);
|
| + });
|
| + });
|
| });
|
|
|