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

Side by Side Diff: chrome/test/data/extensions/api_test/metrics/test.js

Issue 8548013: Moving experimental.metrics API to metricsPrivate (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/extensions/api_test/metrics/manifest.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // metrics api test 5 // metrics api test
6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Metrics 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Metrics
7 7
8 // Any changes to the logging done in these functions should be matched 8 // Any changes to the logging done in these functions should be matched
9 // with the checks done in IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics). 9 // with the checks done in IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics).
10 // See extension_metrics_apitest.cc. 10 // See extension_metrics_apitest.cc.
11 chrome.test.runTests([ 11 chrome.test.runTests([
12 function getSetEnabled() {
13 var pass = chrome.test.callbackPass;
14 var metrics = chrome.experimental.metrics;
15 // Try to change the setting and put it back. We use callbacks to ensure
16 // all functions are called in order.
17 metrics.getEnabled(pass(function(old_enabled) {
18 // Verify that it is, indeed, a boolean.
19 chrome.test.assertEq(old_enabled, !!old_enabled);
20 metrics.setEnabled(!old_enabled, pass(function(new_enabled) {
21 chrome.test.assertEq(old_enabled, !new_enabled);
22 metrics.getEnabled(pass(function(n) {
23 chrome.test.assertEq(n, new_enabled);
24
25 metrics.setEnabled(old_enabled, pass(function(o) {
26 chrome.test.assertEq(o, old_enabled);
27 }));
28 }));
29 }));
30 }));
31 },
32
33 function recordUserAction() { 12 function recordUserAction() {
34 // Log a metric once. 13 // Log a metric once.
35 chrome.experimental.metrics.recordUserAction('test.ua.1'); 14 chrome.metricsPrivate.recordUserAction('test.ua.1');
36 15
37 // Log a metric more than once. 16 // Log a metric more than once.
38 chrome.experimental.metrics.recordUserAction('test.ua.2'); 17 chrome.metricsPrivate.recordUserAction('test.ua.2');
39 chrome.experimental.metrics.recordUserAction('test.ua.2'); 18 chrome.metricsPrivate.recordUserAction('test.ua.2');
40 19
41 chrome.test.succeed(); 20 chrome.test.succeed();
42 }, 21 },
43 22
44 function recordValue() { 23 function recordValue() {
45 chrome.experimental.metrics.recordValue({ 24 chrome.metricsPrivate.recordValue({
46 'metricName': 'test.h.1', 25 'metricName': 'test.h.1',
47 'type': 'histogram-log', 26 'type': 'histogram-log',
48 'min': 1, 27 'min': 1,
49 'max': 100, 28 'max': 100,
50 'buckets': 50 29 'buckets': 50
51 }, 42); 30 }, 42);
52 31
53 chrome.experimental.metrics.recordValue({ 32 chrome.metricsPrivate.recordValue({
54 'metricName': 'test.h.2', 33 'metricName': 'test.h.2',
55 'type': 'histogram-linear', 34 'type': 'histogram-linear',
56 'min': 1, 35 'min': 1,
57 'max': 200, 36 'max': 200,
58 'buckets': 50 37 'buckets': 50
59 }, 42); 38 }, 42);
60 39
61 chrome.experimental.metrics.recordPercentage('test.h.3', 42); 40 chrome.metricsPrivate.recordPercentage('test.h.3', 42);
62 chrome.experimental.metrics.recordPercentage('test.h.3', 42); 41 chrome.metricsPrivate.recordPercentage('test.h.3', 42);
63 42
64 chrome.test.succeed(); 43 chrome.test.succeed();
65 }, 44 },
66 45
67 function recordTimes() { 46 function recordTimes() {
68 chrome.experimental.metrics.recordTime('test.time', 42); 47 chrome.metricsPrivate.recordTime('test.time', 42);
69 chrome.experimental.metrics.recordMediumTime('test.medium.time', 42 * 1000); 48 chrome.metricsPrivate.recordMediumTime('test.medium.time', 42 * 1000);
70 chrome.experimental.metrics.recordLongTime('test.long.time', 49 chrome.metricsPrivate.recordLongTime('test.long.time', 42 * 1000 * 60);
71 42 * 1000 * 60);
72 50
73 chrome.test.succeed(); 51 chrome.test.succeed();
74 }, 52 },
75 53
76 function recordCounts() { 54 function recordCounts() {
77 chrome.experimental.metrics.recordCount('test.count', 420000); 55 chrome.metricsPrivate.recordCount('test.count', 420000);
78 chrome.experimental.metrics.recordMediumCount('test.medium.count', 4200); 56 chrome.metricsPrivate.recordMediumCount('test.medium.count', 4200);
79 chrome.experimental.metrics.recordSmallCount('test.small.count', 42); 57 chrome.metricsPrivate.recordSmallCount('test.small.count', 42);
80 58
81 chrome.test.succeed(); 59 chrome.test.succeed();
82 } 60 }
83 ]); 61 ]);
84 62
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/metrics/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698