| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 metrics_apitest.cc. | 10 // See metrics_apitest.cc. |
| 11 chrome.test.runTests([ | 11 chrome.test.runTests([ |
| 12 function recordUserAction() { | 12 function recordUserAction() { |
| 13 // Log a metric once. | 13 // Log a metric once. |
| 14 chrome.metricsPrivate.recordUserAction('test.ua.1'); | 14 chrome.metricsPrivate.recordUserAction('test.ua.1'); |
| 15 | 15 |
| 16 // Log a metric more than once. | 16 // Log a metric more than once. |
| 17 chrome.metricsPrivate.recordUserAction('test.ua.2'); | 17 chrome.metricsPrivate.recordUserAction('test.ua.2'); |
| 18 chrome.metricsPrivate.recordUserAction('test.ua.2'); | 18 chrome.metricsPrivate.recordUserAction('test.ua.2'); |
| 19 | 19 |
| 20 chrome.test.succeed(); | 20 chrome.test.succeed(); |
| 21 }, | 21 }, |
| 22 | 22 |
| 23 function recordValue() { | 23 function recordValue() { |
| 24 chrome.metricsPrivate.recordValue({ | 24 chrome.metricsPrivate.recordValue({ |
| 25 'metricName': 'test.h.1', | 25 'metricName': 'test.h.1', |
| 26 'type': 'histogram-log', | 26 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG, |
| 27 'min': 1, | 27 'min': 1, |
| 28 'max': 100, | 28 'max': 100, |
| 29 'buckets': 50 | 29 'buckets': 50 |
| 30 }, 42); | 30 }, 42); |
| 31 | 31 |
| 32 chrome.metricsPrivate.recordValue({ | 32 chrome.metricsPrivate.recordValue({ |
| 33 'metricName': 'test.h.2', | 33 'metricName': 'test.h.2', |
| 34 'type': 'histogram-linear', | 34 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, |
| 35 'min': 1, | 35 'min': 1, |
| 36 'max': 200, | 36 'max': 200, |
| 37 'buckets': 50 | 37 'buckets': 50 |
| 38 }, 42); | 38 }, 42); |
| 39 | 39 |
| 40 chrome.metricsPrivate.recordPercentage('test.h.3', 42); | 40 chrome.metricsPrivate.recordPercentage('test.h.3', 42); |
| 41 chrome.metricsPrivate.recordPercentage('test.h.3', 42); | 41 chrome.metricsPrivate.recordPercentage('test.h.3', 42); |
| 42 | 42 |
| 43 chrome.test.succeed(); | 43 chrome.test.succeed(); |
| 44 }, | 44 }, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 'apitestfieldtrial2', function(params) { | 101 'apitestfieldtrial2', function(params) { |
| 102 chrome.test.assertEq(undefined, chrome.runtime.lastError); | 102 chrome.test.assertEq(undefined, chrome.runtime.lastError); |
| 103 chrome.test.assertEq({a: 'aa', b: 'bb'}, params); | 103 chrome.test.assertEq({a: 'aa', b: 'bb'}, params); |
| 104 chrome.test.succeed(); | 104 chrome.test.succeed(); |
| 105 }); | 105 }); |
| 106 }, | 106 }, |
| 107 | 107 |
| 108 function testBucketSizeChanges() { | 108 function testBucketSizeChanges() { |
| 109 var linear1 = { | 109 var linear1 = { |
| 110 'metricName': 'test.bucketchange.linear', | 110 'metricName': 'test.bucketchange.linear', |
| 111 'type': 'histogram-linear', | 111 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, |
| 112 'min': 0, | 112 'min': 0, |
| 113 'max': 100, | 113 'max': 100, |
| 114 'buckets': 10 | 114 'buckets': 10 |
| 115 }; | 115 }; |
| 116 var linear2 = { | 116 var linear2 = { |
| 117 'metricName': 'test.bucketchange.linear', | 117 'metricName': 'test.bucketchange.linear', |
| 118 'type': 'histogram-linear', | 118 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, |
| 119 'min': 0, | 119 'min': 0, |
| 120 'max': 100, | 120 'max': 100, |
| 121 'buckets': 20 | 121 'buckets': 20 |
| 122 }; | 122 }; |
| 123 var log1 = { | 123 var log1 = { |
| 124 'metricName': 'test.bucketchange.log', | 124 'metricName': 'test.bucketchange.log', |
| 125 'type': 'histogram-log', | 125 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG, |
| 126 'min': 0, | 126 'min': 0, |
| 127 'max': 100, | 127 'max': 100, |
| 128 'buckets': 10 | 128 'buckets': 10 |
| 129 }; | 129 }; |
| 130 var log2 = { | 130 var log2 = { |
| 131 'metricName': 'test.bucketchange.log', | 131 'metricName': 'test.bucketchange.log', |
| 132 'type': 'histogram-log', | 132 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG, |
| 133 'min': 0, | 133 'min': 0, |
| 134 'max': 100, | 134 'max': 100, |
| 135 'buckets': 20 | 135 'buckets': 20 |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 chrome.metricsPrivate.recordValue(linear1, 42); | 138 chrome.metricsPrivate.recordValue(linear1, 42); |
| 139 // This one should be rejected because the bucket count is different. | 139 // This one should be rejected because the bucket count is different. |
| 140 // We check for sample count == 2 in metrics_apitest.cc | 140 // We check for sample count == 2 in metrics_apitest.cc |
| 141 chrome.metricsPrivate.recordValue(linear2, 42); | 141 chrome.metricsPrivate.recordValue(linear2, 42); |
| 142 chrome.metricsPrivate.recordValue(linear1, 42); | 142 chrome.metricsPrivate.recordValue(linear1, 42); |
| 143 | 143 |
| 144 chrome.metricsPrivate.recordValue(log1, 42); | 144 chrome.metricsPrivate.recordValue(log1, 42); |
| 145 // This one should be rejected because the bucket count is different. | 145 // This one should be rejected because the bucket count is different. |
| 146 // We check for sample count == 2 in metrics_apitest.cc | 146 // We check for sample count == 2 in metrics_apitest.cc |
| 147 chrome.metricsPrivate.recordValue(log2, 42); | 147 chrome.metricsPrivate.recordValue(log2, 42); |
| 148 chrome.metricsPrivate.recordValue(log1, 42); | 148 chrome.metricsPrivate.recordValue(log1, 42); |
| 149 | 149 |
| 150 chrome.test.succeed(); | 150 chrome.test.succeed(); |
| 151 }, | 151 }, |
| 152 | 152 |
| 153 ]); | 153 ]); |
| 154 | 154 |
| OLD | NEW |