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

Side by Side Diff: chrome/test/data/webui/md_history/history_metrics_test.js

Issue 2238163002: [MD History] Add UMA stats for switching views and the CBD button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@start_focus_in_search_bar
Patch Set: address comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('md_history.history_metrics_test', function() {
6
7 function registerTests() {
8 suite('Metrics', function() {
9 var browserService;
10 var app;
11 var histogramMap;
12
13 setup(function() {
14 PolymerTest.clearBody();
15 histogramMap = {};
16
17 /**
18 * @constructor
19 * @extends {md_history.BrowserService}
20 */
21 var TestMetricsBrowserService = function() {};
22
23 TestMetricsBrowserService.prototype = {
24 __proto__: md_history.BrowserService.prototype,
25
26 /** @override */
27 recordHistogram: function(histogram, value, max) {
28 assertTrue(value < max);
29
30 if (!(histogram in histogramMap))
31 histogramMap[histogram] = {};
32
33 if (!(value in histogramMap[histogram]))
34 histogramMap[histogram][value] = 0;
35
36 histogramMap[histogram][value]++;
37 }
38 };
39
40 md_history.BrowserService.instance_ = new TestMetricsBrowserService();
41
42 app = document.createElement('history-app');
43 app.id = 'history-app';
44 document.body.appendChild(app);
45 return flush();
46 });
47
48 test('History.HistoryView', function() {
49 app.grouped_ = true;
50
51 var histogram = histogramMap['History.HistoryView'];
52 assertEquals(1, histogram[HistoryViewHistogram.HISTORY]);
53
54 app.selectedPage_ = 'syncedTabs';
55 assertEquals(1, histogram[HistoryViewHistogram.SIGNIN_PROMO]);
56 updateSignInState(true);
57 return flush().then(() => {
58 assertEquals(1, histogram[HistoryViewHistogram.SYNCED_TABS]);
59 app.selectedPage_ = 'history';
60 assertEquals(2, histogram[HistoryViewHistogram.HISTORY]);
61 app.set('queryState_.range', HistoryRange.WEEK);
62 assertEquals(1, histogram[HistoryViewHistogram.GROUPED_WEEK]);
63 app.set('queryState_.range', HistoryRange.MONTH);
64 assertEquals(1, histogram[HistoryViewHistogram.GROUPED_MONTH]);
65 });
66 });
67 });
68 }
69 return {
70 registerTests: registerTests
71 };
72 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698