Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: chrome/browser/translate/translate_manager_metrics_unittest.cc

Issue 15970002: Add the new UMA key 'Translate.LocalesOnDisabledByPrefs'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (Rebasing) Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/translate/translate_manager_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
Takashi Toyoshima 2013/05/27 07:39:03 [optional] this function name is vague. can you re
hajimehoshi 2013/05/27 08:24:21 Ok, I'll rename this at https://chromiumcodereview
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));
+}
« no previous file with comments | « chrome/browser/translate/translate_manager_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698