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/browser/translate_browser_metrics.h" | 5 #include "components/translate/core/browser/translate_browser_metrics.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
11 #include "base/metrics/statistics_recorder.h" | 11 #include "base/metrics/statistics_recorder.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
14 | 14 |
15 using base::HistogramBase; | 15 using base::HistogramBase; |
16 using base::HistogramSamples; | 16 using base::HistogramSamples; |
17 using base::StatisticsRecorder; | 17 using base::StatisticsRecorder; |
18 | 18 |
| 19 namespace translate { |
| 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 class MetricsRecorder { | 23 class MetricsRecorder { |
22 public: | 24 public: |
23 explicit MetricsRecorder(const char* key) : key_(key) { | 25 explicit MetricsRecorder(const char* key) : key_(key) { |
24 StatisticsRecorder::Initialize(); | 26 StatisticsRecorder::Initialize(); |
25 | 27 |
26 HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); | 28 HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); |
27 if (histogram) | 29 if (histogram) |
28 base_samples_ = histogram->SnapshotSamples(); | 30 base_samples_ = histogram->SnapshotSamples(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 180 |
179 TEST(TranslateBrowserMetricsTest, ReportedUnsupportedLanguageAtInitiation) { | 181 TEST(TranslateBrowserMetricsTest, ReportedUnsupportedLanguageAtInitiation) { |
180 const int ENGLISH = 25966; | 182 const int ENGLISH = 25966; |
181 | 183 |
182 MetricsRecorder recorder(TranslateBrowserMetrics::GetMetricsName( | 184 MetricsRecorder recorder(TranslateBrowserMetrics::GetMetricsName( |
183 TranslateBrowserMetrics::UMA_UNSUPPORTED_LANGUAGE_AT_INITIATION)); | 185 TranslateBrowserMetrics::UMA_UNSUPPORTED_LANGUAGE_AT_INITIATION)); |
184 EXPECT_EQ(0, recorder.GetTotalCount()); | 186 EXPECT_EQ(0, recorder.GetTotalCount()); |
185 TranslateBrowserMetrics::ReportUnsupportedLanguageAtInitiation("en"); | 187 TranslateBrowserMetrics::ReportUnsupportedLanguageAtInitiation("en"); |
186 EXPECT_EQ(1, recorder.GetCount(ENGLISH)); | 188 EXPECT_EQ(1, recorder.GetCount(ENGLISH)); |
187 } | 189 } |
| 190 |
| 191 } // namespace translate |
OLD | NEW |