| 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 4cb9184162c479bc11974c565a03dcab2eff5392..8666d47d0c99f93ebb371ee5a539ca80b971c2c6 100644
|
| --- a/chrome/test/data/webui/md_history/history_metrics_test.js
|
| +++ b/chrome/test/data/webui/md_history/history_metrics_test.js
|
| @@ -7,14 +7,21 @@ cr.define('md_history.history_metrics_test', function() {
|
| * @constructor
|
| * @extends {md_history.BrowserService}
|
| */
|
| - var TestMetricsBrowserService = function() { this.histogramMap = {}; };
|
| + 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,
|
|
|
| @@ -29,6 +36,19 @@ cr.define('md_history.history_metrics_test', function() {
|
| 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 flush();
|
| }
|
| };
|
| });
|
| @@ -37,6 +57,9 @@ cr.define('md_history.history_metrics_test', function() {
|
| md_history.BrowserService.instance_ = new TestMetricsBrowserService();
|
| service = md_history.BrowserService.getInstance();
|
|
|
| + actionMap = service.actionMap;
|
| + histogramMap = service.histogramMap;
|
| +
|
| app = replaceApp();
|
| updateSignInState(false);
|
| return flush();
|
| @@ -45,7 +68,7 @@ cr.define('md_history.history_metrics_test', function() {
|
| test('History.HistoryPageView', function() {
|
| app.grouped_ = true;
|
|
|
| - var histogram = service.histogramMap['History.HistoryPageView'];
|
| + var histogram = histogramMap['History.HistoryPageView'];
|
| assertEquals(1, histogram[HistoryPageViewHistogram.HISTORY]);
|
|
|
| app.selectedPage_ = 'syncedTabs';
|
| @@ -61,6 +84,123 @@ cr.define('md_history.history_metrics_test', function() {
|
| 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 flush().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 flush();
|
| + }).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 flush();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
|
| + assertEquals(1, actionMap['RemoveSelected']);
|
| + return flush();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.history.$$('.cancel-button'));
|
| + assertEquals(1, actionMap['CancelRemoveSelected']);
|
| + MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
|
| + return flush();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.history.$$('.action-button'));
|
| + assertEquals(1, actionMap['ConfirmRemoveSelected']);
|
| + return flush();
|
| + }).then(() => {
|
| + items = polymerSelectAll(
|
| + app.$.history.$['infinite-list'], 'history-item');
|
| + MockInteractions.tap(items[0].$['menu-button']);
|
| + return flush();
|
| + }).then(() => {
|
| + MockInteractions.tap(app.$.history.$$('#menuRemoveButton'));
|
| + return flush();
|
| + }).then(() => {
|
| + assertEquals(
|
| + 1, histogramMap['HistoryPage.RemoveEntryPosition'][0]);
|
| + assertEquals(
|
| + 1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][0]);
|
| + });
|
| + });
|
| +
|
| + test('synced-device-manager', function() {
|
| + app.selectedPage_ = 'syncedTabs';
|
| + var histogram;
|
| + return flush().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 flush();
|
| + }).then(() => {
|
| + assertEquals(1, histogram[SyncedTabsHistogram.HAS_FOREIGN_DATA]);
|
| + return flush();
|
| + }).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 flush();
|
| + }).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]);
|
| + });
|
| + });
|
| });
|
| }
|
| return {
|
|
|