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

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: fix_test Created 4 years, 3 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 * @constructor
8 * @extends {md_history.BrowserService}
9 */
10 var TestMetricsBrowserService = function() { this.histogramMap = {}; };
11
12 function registerTests() {
13 suite('Metrics', function() {
14 var service;
15 var app;
16
17 suiteSetup(function() {
18 TestMetricsBrowserService.prototype = {
19 __proto__: md_history.BrowserService.prototype,
20
21 /** @override */
22 recordHistogram: function(histogram, value, max) {
23 assertTrue(value < max);
24
25 if (!(histogram in this.histogramMap))
26 this.histogramMap[histogram] = {};
27
28 if (!(value in this.histogramMap[histogram]))
29 this.histogramMap[histogram][value] = 0;
30
31 this.histogramMap[histogram][value]++;
32 }
33 };
34 });
35
36 setup(function() {
37 md_history.BrowserService.instance_ = new TestMetricsBrowserService();
38 service = md_history.BrowserService.getInstance();
39
40 app = replaceApp();
41 updateSignInState(false);
42 return flush();
43 });
44
45 test('History.HistoryPageView', function() {
46 app.grouped_ = true;
47
48 var histogram = service.histogramMap['History.HistoryPageView'];
49 assertEquals(1, histogram[HistoryPageViewHistogram.HISTORY]);
50
51 app.selectedPage_ = 'syncedTabs';
52 assertEquals(1, histogram[HistoryPageViewHistogram.SIGNIN_PROMO]);
53 updateSignInState(true);
54 return flush().then(() => {
55 assertEquals(1, histogram[HistoryPageViewHistogram.SYNCED_TABS]);
56 app.selectedPage_ = 'history';
57 assertEquals(2, histogram[HistoryPageViewHistogram.HISTORY]);
58 app.set('queryState_.range', HistoryRange.WEEK);
59 assertEquals(1, histogram[HistoryPageViewHistogram.GROUPED_WEEK]);
60 app.set('queryState_.range', HistoryRange.MONTH);
61 assertEquals(1, histogram[HistoryPageViewHistogram.GROUPED_MONTH]);
62 });
63 });
64 });
65 }
66 return {
67 registerTests: registerTests
68 };
69 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698