OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/translate/core/common/translate_metrics.h" | 5 #include "components/translate/core/common/translate_metrics.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 Snapshot(); | 102 Snapshot(); |
103 EXPECT_EQ(count, GetTotalCount()); | 103 EXPECT_EQ(count, GetTotalCount()); |
104 } | 104 } |
105 | 105 |
106 void CheckValueInLogs(double value) { | 106 void CheckValueInLogs(double value) { |
107 Snapshot(); | 107 Snapshot(); |
108 ASSERT_TRUE(samples_.get()); | 108 ASSERT_TRUE(samples_.get()); |
109 for (std::unique_ptr<SampleCountIterator> i = samples_->Iterator(); | 109 for (std::unique_ptr<SampleCountIterator> i = samples_->Iterator(); |
110 !i->Done(); i->Next()) { | 110 !i->Done(); i->Next()) { |
111 HistogramBase::Sample min; | 111 HistogramBase::Sample min; |
112 HistogramBase::Sample max; | 112 int64_t max; |
113 HistogramBase::Count count; | 113 HistogramBase::Count count; |
114 i->Get(&min, &max, &count); | 114 i->Get(&min, &max, &count); |
115 if (min <= value && value <= max && count >= 1) | 115 if (min <= value && value <= max && count >= 1) |
116 return; | 116 return; |
117 } | 117 } |
118 EXPECT_FALSE(true); | 118 EXPECT_FALSE(true); |
119 } | 119 } |
120 | 120 |
121 HistogramBase::Count GetCount(HistogramBase::Sample value) { | 121 HistogramBase::Count GetCount(HistogramBase::Sample value) { |
122 Snapshot(); | 122 Snapshot(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 EXPECT_EQ(recorder.GetCount(base::HashMetricName("en-AU,ru-Latn")), 1); | 310 EXPECT_EQ(recorder.GetCount(base::HashMetricName("en-AU,ru-Latn")), 1); |
311 | 311 |
312 // We don't track "en-XX" or "en-YY" as page codes. | 312 // We don't track "en-XX" or "en-YY" as page codes. |
313 translate::ReportLanguageDetectionConflict("en-XX", "es"); | 313 translate::ReportLanguageDetectionConflict("en-XX", "es"); |
314 translate::ReportLanguageDetectionConflict("en-YY", "es"); | 314 translate::ReportLanguageDetectionConflict("en-YY", "es"); |
315 recorder.CheckTotalCount(5); | 315 recorder.CheckTotalCount(5); |
316 EXPECT_EQ(recorder.GetCount(base::HashMetricName("other,es")), 2); | 316 EXPECT_EQ(recorder.GetCount(base::HashMetricName("other,es")), 2); |
317 } | 317 } |
318 | 318 |
319 } // namespace translate | 319 } // namespace translate |
OLD | NEW |