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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Code other than the tests tun here will record some histogram values, but | 100 // Code other than the tests tun here will record some histogram values, but |
101 // we will ignore those. This function validates that all the histogram we | 101 // we will ignore those. This function validates that all the histogram we |
102 // expect to see are present in the list, and that their basic info is | 102 // expect to see are present in the list, and that their basic info is |
103 // correct. | 103 // correct. |
104 for (int i = 0; i < count; ++i) { | 104 for (int i = 0; i < count; ++i) { |
105 const RecordedHistogram& r = recorded[i]; | 105 const RecordedHistogram& r = recorded[i]; |
106 size_t j = 0; | 106 size_t j = 0; |
107 for (j = 0; j < histograms.size(); ++j) { | 107 for (j = 0; j < histograms.size(); ++j) { |
108 base::HistogramBase* histogram(histograms[j]); | 108 base::HistogramBase* histogram(histograms[j]); |
109 if (r.name == histogram->histogram_name()) { | 109 if (r.name == histogram->histogram_name()) { |
110 scoped_ptr<base::HistogramSamples> snapshot = | 110 std::unique_ptr<base::HistogramSamples> snapshot = |
111 histogram->SnapshotSamples(); | 111 histogram->SnapshotSamples(); |
112 base::HistogramBase::Count sample_count = snapshot->TotalCount(); | 112 base::HistogramBase::Count sample_count = snapshot->TotalCount(); |
113 EXPECT_EQ(r.count, sample_count); | 113 EXPECT_EQ(r.count, sample_count); |
114 | 114 |
115 EXPECT_EQ(r.type, histogram->GetHistogramType()); | 115 EXPECT_EQ(r.type, histogram->GetHistogramType()); |
116 if (r.type == base::SPARSE_HISTOGRAM) { | 116 if (r.type == base::SPARSE_HISTOGRAM) { |
117 ValidateSparseHistogramSamples(r.name, *snapshot); | 117 ValidateSparseHistogramSamples(r.name, *snapshot); |
118 } else { | 118 } else { |
119 EXPECT_TRUE( | 119 EXPECT_TRUE( |
120 histogram->HasConstructionArguments(r.min, r.max, r.buckets)); | 120 histogram->HasConstructionArguments(r.min, r.max, r.buckets)); |
(...skipping 17 matching lines...) Expand all Loading... |
138 params["b"] = "bb"; | 138 params["b"] = "bb"; |
139 ASSERT_TRUE(variations::AssociateVariationParams( | 139 ASSERT_TRUE(variations::AssociateVariationParams( |
140 "apitestfieldtrial2", "group1", params)); | 140 "apitestfieldtrial2", "group1", params)); |
141 | 141 |
142 ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_; | 142 ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_; |
143 | 143 |
144 ValidateUserActions(user_action_tester, g_user_actions, | 144 ValidateUserActions(user_action_tester, g_user_actions, |
145 arraysize(g_user_actions)); | 145 arraysize(g_user_actions)); |
146 ValidateHistograms(g_histograms, arraysize(g_histograms)); | 146 ValidateHistograms(g_histograms, arraysize(g_histograms)); |
147 } | 147 } |
OLD | NEW |