Index: chrome/browser/translate/translate_manager_metrics_unittest.cc |
diff --git a/chrome/browser/translate/translate_manager_metrics_unittest.cc b/chrome/browser/translate/translate_manager_metrics_unittest.cc |
index 91b66aecc2e3c3cbacd809b841c7dca1bba663b8..d5adc437aa70d0291d619a06a52469ca4ce9e723 100644 |
--- a/chrome/browser/translate/translate_manager_metrics_unittest.cc |
+++ b/chrome/browser/translate/translate_manager_metrics_unittest.cc |
@@ -43,25 +43,25 @@ class MetricsRecorder { |
int expected_show_infobar) { |
Snapshot(); |
- EXPECT_EQ(expected_disabled_by_prefs, GetCount( |
+ EXPECT_EQ(expected_disabled_by_prefs, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_DISABLED_BY_PREFS)); |
- EXPECT_EQ(expected_disabled_by_switch, GetCount( |
+ EXPECT_EQ(expected_disabled_by_switch, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_DISABLED_BY_SWITCH)); |
- EXPECT_EQ(expected_disabled_by_config, GetCount( |
+ EXPECT_EQ(expected_disabled_by_config, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_DISABLED_BY_CONFIG)); |
- EXPECT_EQ(expected_language_is_not_supported, GetCount( |
+ EXPECT_EQ(expected_language_is_not_supported, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_LANGUAGE_IS_NOT_SUPPORTED)); |
- EXPECT_EQ(expected_url_is_not_supported, GetCount( |
+ EXPECT_EQ(expected_url_is_not_supported, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_URL_IS_NOT_SUPPORTED)); |
- EXPECT_EQ(expected_similar_languages, GetCount( |
+ EXPECT_EQ(expected_similar_languages, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES)); |
- EXPECT_EQ(expected_accept_languages, GetCount( |
+ EXPECT_EQ(expected_accept_languages, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_ACCEPT_LANGUAGES)); |
- EXPECT_EQ(expected_auto_by_config, GetCount( |
+ EXPECT_EQ(expected_auto_by_config, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_AUTO_BY_CONFIG)); |
- EXPECT_EQ(expected_auto_by_link, GetCount( |
+ EXPECT_EQ(expected_auto_by_link, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_AUTO_BY_LINK)); |
- EXPECT_EQ(expected_show_infobar, GetCount( |
+ EXPECT_EQ(expected_show_infobar, GetCountInternal( |
TranslateManagerMetrics::INITIATION_STATUS_SHOW_INFOBAR)); |
} |
@@ -75,6 +75,11 @@ class MetricsRecorder { |
return count - base_samples_->TotalCount(); |
} |
+ HistogramBase::Count GetCount(HistogramBase::Sample value) { |
+ Snapshot(); |
+ return GetCountInternal(value); |
+ } |
+ |
private: |
void Snapshot() { |
HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); |
@@ -83,7 +88,7 @@ class MetricsRecorder { |
samples_ = histogram->SnapshotSamples(); |
} |
- HistogramBase::Count GetCount(HistogramBase::Sample value) { |
+ HistogramBase::Count GetCountInternal(HistogramBase::Sample value) { |
if (!samples_.get()) |
return 0; |
HistogramBase::Count count = samples_->GetCount(value); |
@@ -153,3 +158,13 @@ TEST(TranslateManagerMetricsTest, ReportedUnsupportedLanguage) { |
TranslateManagerMetrics::ReportUnsupportedLanguage(); |
EXPECT_EQ(1, recorder.GetTotalCount()); |
} |
+ |
+TEST(TranslateManagerMetricsTest, ReportedLocalesOnDisabledByPrefs) { |
+ const int ENGLISH = 25966; |
+ |
+ MetricsRecorder recorder(TranslateManagerMetrics::GetMetricsName( |
+ TranslateManagerMetrics::UMA_LOCALES_ON_DISABLED_BY_PREFS)); |
+ EXPECT_EQ(0, recorder.GetTotalCount()); |
+ TranslateManagerMetrics::ReportLocalesOnDisabledByPrefs("en"); |
+ EXPECT_EQ(1, recorder.GetCount(ENGLISH)); |
+} |