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

Unified Diff: chrome/test/data/webui/md_history/history_metrics_test.js

Issue 2255033002: [MD History] Copy stats from the old history page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sidebar_stats
Patch Set: add_stats Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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 ce06568a5717f27b6b2a787a1b3dd86da0c87e44..5cec3d39e4fabeeb6c21bf3ec75cf28290aa0ec0 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();
return flush();
});
@@ -44,7 +67,7 @@ cr.define('md_history.history_metrics_test', function() {
test('History.HistoryView', function() {
app.grouped_ = true;
- var histogram = service.histogramMap['History.HistoryView'];
+ var histogram = histogramMap['History.HistoryView'];
assertEquals(1, histogram[HistoryViewHistogram.HISTORY]);
app.selectedPage_ = 'syncedTabs';
@@ -60,6 +83,205 @@ cr.define('md_history.history_metrics_test', function() {
assertEquals(1, histogram[HistoryViewHistogram.GROUPED_MONTH]);
});
});
+
+ test('history-list', function() {
tsergeant 2016/08/22 00:23:40 Having these here is okay for now, but we should b
calamity 2016/08/23 04:52:25 My intuition is that there would be a larger maint
+ 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(() => {
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPosition'][0]);
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][0]);
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPosition'][4]);
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][4]);
+
+ items = polymerSelectAll(
+ app.$.history.$['infinite-list'], 'history-item');
+ MockInteractions.tap(items[0].$.checkbox);
+ MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
+ return flush();
+ }).then(() => {
+ MockInteractions.tap(app.$.history.$$('.action-button'));
+ assertEquals(2, actionMap['ConfirmRemoveSelected']);
+ return flush();
+ }).then(() => {
+ assertEquals(
+ 2, histogramMap['HistoryPage.RemoveEntryPosition'][0]);
+ assertEquals(
+ 2, histogramMap['HistoryPage.RemoveEntryPositionSubset'][0]);
+ });
+ });
+
+ test('grouped-list', function() {
+ app.grouped_ = true;
+ var groupedList;
+ var dropdowns;
+ return flush().then(() => {
+ groupedList = app.$.history.$$('#grouped-list');
+ app.set('queryState_.range', HistoryRange.WEEK);
+ app.historyResult(createHistoryInfo(), [
+ createHistoryEntry('2015-01-03', 'http://www.google.com'),
+ createHistoryEntry('2015-01-03', 'http://www.google.com'),
+ createHistoryEntry('2015-01-03', 'http://www.google.com'),
+ createHistoryEntry('2015-01-01', 'http://www.google.com'),
+ createHistoryEntry('2015-01-01', 'http://www.google.com'),
+ createHistoryEntry('2015-01-01', 'http://www.badssl.com'),
+ ]);
+
+ return waitForEvent(groupedList, 'dom-change', function() {
+ return polymerSelectAll(
+ groupedList, '.dropdown-indicator').length == 3;
+ });
+ }).then(function() {
+ dropdowns = polymerSelectAll(groupedList, '.dropdown-indicator');
+ // Open the first and last domains.
+ MockInteractions.tap(dropdowns[0]);
+ MockInteractions.tap(dropdowns[2]);
+ return flush();
+ }).then(function() {
+ var items = polymerSelectAll(groupedList, 'history-item');
+ // Select the 2nd item in the first domain and the only item in the
+ // last domain.
+ MockInteractions.tap(items[1].$.checkbox);
+ MockInteractions.tap(items[3].$.checkbox);
+ return flush();
+ }).then(() => {
+ MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
+ return flush();
+ }).then(() => {
+ MockInteractions.tap(app.$.history.$$('.action-button'));
+ return flush();
+ }).then(() => {
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPosition'][1]);
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][1]);
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPosition'][5]);
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][5]);
+ }).then(function() {
+ // Open the middle domain.
+ MockInteractions.tap(dropdowns[1]);
+ return flush();
+ }).then(function() {
+ var items = polymerSelectAll(groupedList, 'history-item');
+ // Select the first item in the middle domain.
+ MockInteractions.tap(items[2].$.checkbox);
+ return flush();
+ }).then(() => {
+ MockInteractions.tap(app.$.toolbar.$$('#delete-button'));
+ return flush();
+ }).then(() => {
+ MockInteractions.tap(app.$.history.$$('.action-button'));
+ return flush();
+ }).then(() => {
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPosition'][2]);
+ assertEquals(
+ 1, histogramMap['HistoryPage.RemoveEntryPositionSubset'][2]);
+ });
+ });
+
+ 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 {

Powered by Google App Engine
This is Rietveld 408576698