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 #include <map> | 5 #include <map> |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/metrics/statistics_recorder.h" | 8 #include "base/metrics/statistics_recorder.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "content/public/browser/user_metrics.h" | 10 #include "content/public/browser/user_metrics.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 base::StatisticsRecorder::GetHistograms(&histograms); | 103 base::StatisticsRecorder::GetHistograms(&histograms); |
104 | 104 |
105 // Code other than the tests tun here will record some histogram values, but | 105 // Code other than the tests tun here will record some histogram values, but |
106 // we will ignore those. This function validates that all the histogram we | 106 // we will ignore those. This function validates that all the histogram we |
107 // expect to see are present in the list, and that their basic info is | 107 // expect to see are present in the list, and that their basic info is |
108 // correct. | 108 // correct. |
109 for (int i = 0; i < count; ++i) { | 109 for (int i = 0; i < count; ++i) { |
110 const RecordedHistogram& r = recorded[i]; | 110 const RecordedHistogram& r = recorded[i]; |
111 size_t j = 0; | 111 size_t j = 0; |
112 for (j = 0; j < histograms.size(); ++j) { | 112 for (j = 0; j < histograms.size(); ++j) { |
113 base::Histogram* histogram(histograms[j]); | 113 base::HistogramBase* histogram(histograms[j]); |
114 | 114 |
115 if (r.name == histogram->histogram_name()) { | 115 if (r.name == histogram->histogram_name()) { |
116 EXPECT_EQ(r.type, histogram->GetHistogramType()); | 116 EXPECT_EQ(r.type, histogram->GetHistogramType()); |
117 EXPECT_EQ(r.min, histogram->declared_min()); | 117 EXPECT_TRUE( |
118 EXPECT_EQ(r.max, histogram->declared_max()); | 118 histogram->HasConstructionArguments(r.min, r.max, r.buckets)); |
119 EXPECT_EQ(r.buckets, histogram->bucket_count()); | |
120 break; | 119 break; |
121 } | 120 } |
122 } | 121 } |
123 EXPECT_LT(j, histograms.size()); | 122 EXPECT_LT(j, histograms.size()); |
124 } | 123 } |
125 } | 124 } |
126 | 125 |
127 } // anonymous namespace | 126 } // anonymous namespace |
128 | 127 |
129 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) { | 128 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) { |
130 UserActionObserver observer; | 129 UserActionObserver observer; |
131 | 130 |
132 ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_; | 131 ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_; |
133 | 132 |
134 observer.ValidateUserActions(g_user_actions, arraysize(g_user_actions)); | 133 observer.ValidateUserActions(g_user_actions, arraysize(g_user_actions)); |
135 ValidateHistograms(g_histograms, arraysize(g_histograms)); | 134 ValidateHistograms(g_histograms, arraysize(g_histograms)); |
136 } | 135 } |
OLD | NEW |