OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/translate/translate_manager_metrics.h" | 5 #include "chrome/browser/translate/translate_manager_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 { | 19 namespace { |
20 | 20 |
21 class MetricsRecorder { | 21 class MetricsRecorder { |
22 public: | 22 public: |
23 explicit MetricsRecorder(const char* key) | 23 explicit MetricsRecorder(const char* key) : key_(key) { |
24 : key_(key), | |
25 base_samples_(NULL), | |
26 samples_(NULL) { | |
27 StatisticsRecorder::Initialize(); | 24 StatisticsRecorder::Initialize(); |
28 | 25 |
29 HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); | 26 HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); |
30 if (histogram) | 27 if (histogram) |
31 base_samples_ = histogram->SnapshotSamples(); | 28 base_samples_ = histogram->SnapshotSamples(); |
32 } | 29 } |
33 | 30 |
34 void CheckInitiationStatus(int expected_disabled_by_prefs, | 31 void CheckInitiationStatus(int expected_disabled_by_prefs, |
35 int expected_disabled_by_switch, | 32 int expected_disabled_by_switch, |
36 int expected_disabled_by_config, | 33 int expected_disabled_by_config, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 169 |
173 TEST(TranslateManagerMetricsTest, ReportedLocalesOnDisabledByPrefs) { | 170 TEST(TranslateManagerMetricsTest, ReportedLocalesOnDisabledByPrefs) { |
174 const int ENGLISH = 25966; | 171 const int ENGLISH = 25966; |
175 | 172 |
176 MetricsRecorder recorder(TranslateManagerMetrics::GetMetricsName( | 173 MetricsRecorder recorder(TranslateManagerMetrics::GetMetricsName( |
177 TranslateManagerMetrics::UMA_LOCALES_ON_DISABLED_BY_PREFS)); | 174 TranslateManagerMetrics::UMA_LOCALES_ON_DISABLED_BY_PREFS)); |
178 EXPECT_EQ(0, recorder.GetTotalCount()); | 175 EXPECT_EQ(0, recorder.GetTotalCount()); |
179 TranslateManagerMetrics::ReportLocalesOnDisabledByPrefs("en"); | 176 TranslateManagerMetrics::ReportLocalesOnDisabledByPrefs("en"); |
180 EXPECT_EQ(1, recorder.GetCount(ENGLISH)); | 177 EXPECT_EQ(1, recorder.GetCount(ENGLISH)); |
181 } | 178 } |
OLD | NEW |