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

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: rebase, vulcanize 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
12 setup(function() {
13 PolymerTest.clearBody();
14
15 /**
16 * @constructor
17 * @extends {md_history.BrowserService}
18 */
19 var TestMetricsBrowserService = function() { this.histogramMap = {}; };
tsergeant 2016/08/17 06:03:09 Nit: Maybe move this declaration outside of the se
calamity 2016/08/18 03:11:15 Done.
tsergeant 2016/08/19 00:46:23 Sorry, I was unclear: I meant move the whole TestM
calamity 2016/08/19 06:26:07 Done.
20
21 TestMetricsBrowserService.prototype = {
22 __proto__: md_history.BrowserService.prototype,
23
24 /** @override */
25 recordHistogram: function(histogram, value, max) {
26 assertTrue(value < max);
27
28 if (!(histogram in this.histogramMap))
29 this.histogramMap[histogram] = {};
30
31 if (!(value in this.histogramMap[histogram]))
32 this.histogramMap[histogram][value] = 0;
33
34 this.histogramMap[histogram][value]++;
35 }
36 };
37
38 md_history.BrowserService.instance_ = new TestMetricsBrowserService();
39
40 browserService = md_history.BrowserService.getInstance();
41 app = document.createElement('history-app');
42 app.id = 'history-app';
43 document.body.appendChild(app);
44 return flush();
45 });
46
47 test('History.HistoryView', function() {
48 app.grouped_ = true;
49
50 var histogram = browserService.histogramMap['History.HistoryView'];
51 assertEquals(1, histogram[HistoryViewHistogram.HISTORY]);
52
53 app.selectedPage_ = 'syncedTabs';
54 return waitForAnimationFrame().then(() => {
55 assertEquals(1, histogram[HistoryViewHistogram.SIGNIN_PROMO]);
56 updateSignInState(true);
57 return waitForAnimationFrame();
58 }).then(() => {
59 assertEquals(1, histogram[HistoryViewHistogram.SYNCED_TABS]);
60 app.selectedPage_ = 'history';
61 return waitForAnimationFrame();
62 }).then(() => {
63 assertEquals(2, histogram[HistoryViewHistogram.HISTORY]);
64 app.set('queryState_.range', HistoryRange.WEEK);
65 return waitForAnimationFrame();
66 }).then(() => {
67 assertEquals(1, histogram[HistoryViewHistogram.GROUPED_WEEK]);
68 app.set('queryState_.range', HistoryRange.MONTH);
69 return waitForAnimationFrame();
70 }).then(() => {
71 assertEquals(1, histogram[HistoryViewHistogram.GROUPED_MONTH]);
72 });
73 });
74 });
75 }
76 return {
77 registerTests: registerTests
78 };
79 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698