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

Side by Side Diff: components/translate/common/translate_metrics_unittest.cc

Issue 25531002: Move language detection to a component (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Run translate unittests on iOS Created 7 years, 2 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 unified diff | Download patch
OLDNEW
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/common/translate/translate_common_metrics.h" 5 #include "components/translate/common/translate_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;
(...skipping 10 matching lines...) Expand all
26 class MetricsRecorder { 26 class MetricsRecorder {
27 public: 27 public:
28 explicit MetricsRecorder(const char* key) : key_(key) { 28 explicit MetricsRecorder(const char* key) : key_(key) {
29 StatisticsRecorder::Initialize(); 29 StatisticsRecorder::Initialize();
30 30
31 HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_); 31 HistogramBase* histogram = StatisticsRecorder::FindHistogram(key_);
32 if (histogram) 32 if (histogram)
33 base_samples_ = histogram->SnapshotSamples(); 33 base_samples_ = histogram->SnapshotSamples();
34 } 34 }
35 35
36 void CheckLanguage(TranslateCommonMetrics::MetricsNameIndex index, 36 void CheckLanguage(translate::MetricsNameIndex index,
37 int expected_not_provided, 37 int expected_not_provided,
38 int expected_valid, 38 int expected_valid,
39 int expected_invalid) { 39 int expected_invalid) {
40 ASSERT_EQ(TranslateCommonMetrics::GetMetricsName(index), key_); 40 ASSERT_EQ(translate::GetMetricsName(index), key_);
41 41
42 Snapshot(); 42 Snapshot();
43 43
44 EXPECT_EQ(expected_not_provided, 44 EXPECT_EQ(expected_not_provided,
45 GetCountWithoutSnapshot( 45 GetCountWithoutSnapshot(translate::LANGUAGE_NOT_PROVIDED));
46 TranslateCommonMetrics::LANGUAGE_NOT_PROVIDED));
47 EXPECT_EQ(expected_valid, 46 EXPECT_EQ(expected_valid,
48 GetCountWithoutSnapshot( 47 GetCountWithoutSnapshot(translate::LANGUAGE_VALID));
49 TranslateCommonMetrics::LANGUAGE_VALID));
50 EXPECT_EQ(expected_invalid, 48 EXPECT_EQ(expected_invalid,
51 GetCountWithoutSnapshot( 49 GetCountWithoutSnapshot(translate::LANGUAGE_INVALID));
52 TranslateCommonMetrics::LANGUAGE_INVALID));
53 } 50 }
54 51
55 void CheckLanguageVerification(int expected_cld_disabled, 52 void CheckLanguageVerification(int expected_cld_disabled,
56 int expected_cld_only, 53 int expected_cld_only,
57 int expected_unknown, 54 int expected_unknown,
58 int expected_cld_agree, 55 int expected_cld_agree,
59 int expected_cld_disagree, 56 int expected_cld_disagree,
60 int expected_trust_cld, 57 int expected_trust_cld,
61 int expected_cld_complement_sub_code) { 58 int expected_cld_complement_sub_code) {
62 ASSERT_EQ(TranslateCommonMetrics::GetMetricsName( 59 ASSERT_EQ(translate::GetMetricsName(translate::UMA_LANGUAGE_VERIFICATION),
63 TranslateCommonMetrics::UMA_LANGUAGE_VERIFICATION), key_); 60 key_);
64 61
65 Snapshot(); 62 Snapshot();
66 63
67 EXPECT_EQ( 64 EXPECT_EQ(
68 expected_cld_disabled, 65 expected_cld_disabled,
69 GetCountWithoutSnapshot( 66 GetCountWithoutSnapshot(translate::LANGUAGE_VERIFICATION_CLD_DISABLED));
70 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_DISABLED));
71 EXPECT_EQ( 67 EXPECT_EQ(
72 expected_cld_only, 68 expected_cld_only,
73 GetCountWithoutSnapshot( 69 GetCountWithoutSnapshot(translate::LANGUAGE_VERIFICATION_CLD_ONLY));
74 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_ONLY));
75 EXPECT_EQ( 70 EXPECT_EQ(
76 expected_unknown, 71 expected_unknown,
77 GetCountWithoutSnapshot( 72 GetCountWithoutSnapshot(translate::LANGUAGE_VERIFICATION_UNKNOWN));
78 TranslateCommonMetrics::LANGUAGE_VERIFICATION_UNKNOWN));
79 EXPECT_EQ( 73 EXPECT_EQ(
80 expected_cld_agree, 74 expected_cld_agree,
81 GetCountWithoutSnapshot( 75 GetCountWithoutSnapshot(translate::LANGUAGE_VERIFICATION_CLD_AGREE));
82 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_AGREE));
83 EXPECT_EQ( 76 EXPECT_EQ(
84 expected_cld_disagree, 77 expected_cld_disagree,
85 GetCountWithoutSnapshot( 78 GetCountWithoutSnapshot(translate::LANGUAGE_VERIFICATION_CLD_DISAGREE));
86 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_DISAGREE));
87 EXPECT_EQ( 79 EXPECT_EQ(
88 expected_trust_cld, 80 expected_trust_cld,
89 GetCountWithoutSnapshot( 81 GetCountWithoutSnapshot(translate::LANGUAGE_VERIFICATION_TRUST_CLD));
90 TranslateCommonMetrics::LANGUAGE_VERIFICATION_TRUST_CLD)); 82 EXPECT_EQ(expected_cld_complement_sub_code,
91 EXPECT_EQ( 83 GetCountWithoutSnapshot(
92 expected_cld_complement_sub_code, 84 translate::LANGUAGE_VERIFICATION_CLD_COMPLEMENT_SUB_CODE));
93 GetCountWithoutSnapshot(
94 TranslateCommonMetrics::
95 LANGUAGE_VERIFICATION_CLD_COMPLEMENT_SUB_CODE));
96 } 85 }
97 86
98 void CheckScheme(int expected_http, int expected_https, int expected_others) { 87 void CheckScheme(int expected_http, int expected_https, int expected_others) {
99 ASSERT_EQ(TranslateCommonMetrics::GetMetricsName( 88 ASSERT_EQ(translate::GetMetricsName(translate::UMA_PAGE_SCHEME), key_);
100 TranslateCommonMetrics::UMA_PAGE_SCHEME), key_);
101 89
102 Snapshot(); 90 Snapshot();
103 91
104 EXPECT_EQ(expected_http, 92 EXPECT_EQ(expected_http, GetCountWithoutSnapshot(translate::SCHEME_HTTP));
105 GetCountWithoutSnapshot(TranslateCommonMetrics::SCHEME_HTTP)); 93 EXPECT_EQ(expected_https, GetCountWithoutSnapshot(translate::SCHEME_HTTPS));
106 EXPECT_EQ(expected_https,
107 GetCountWithoutSnapshot(TranslateCommonMetrics::SCHEME_HTTPS));
108 EXPECT_EQ(expected_others, 94 EXPECT_EQ(expected_others,
109 GetCountWithoutSnapshot(TranslateCommonMetrics::SCHEME_OTHERS)); 95 GetCountWithoutSnapshot(translate::SCHEME_OTHERS));
110 } 96 }
111 97
112 void CheckTotalCount(int count) { 98 void CheckTotalCount(int count) {
113 Snapshot(); 99 Snapshot();
114 EXPECT_EQ(count, GetTotalCount()); 100 EXPECT_EQ(count, GetTotalCount());
115 } 101 }
116 102
117 void CheckValueInLogs(double value) { 103 void CheckValueInLogs(double value) {
118 Snapshot(); 104 Snapshot();
119 ASSERT_TRUE(samples_.get()); 105 ASSERT_TRUE(samples_.get());
120 for (scoped_ptr<SampleCountIterator> i = samples_->Iterator(); 106 for (scoped_ptr<SampleCountIterator> i = samples_->Iterator(); !i->Done();
121 !i->Done();
122 i->Next()) { 107 i->Next()) {
123 HistogramBase::Sample min; 108 HistogramBase::Sample min;
124 HistogramBase::Sample max; 109 HistogramBase::Sample max;
125 HistogramBase::Count count; 110 HistogramBase::Count count;
126 i->Get(&min, &max, &count); 111 i->Get(&min, &max, &count);
127 if (min <= value && value <= max && count >= 1) 112 if (min <= value && value <= max && count >= 1)
128 return; 113 return;
129 } 114 }
130 EXPECT_FALSE(true); 115 EXPECT_FALSE(true);
131 } 116 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 148
164 std::string key_; 149 std::string key_;
165 scoped_ptr<HistogramSamples> base_samples_; 150 scoped_ptr<HistogramSamples> base_samples_;
166 scoped_ptr<HistogramSamples> samples_; 151 scoped_ptr<HistogramSamples> samples_;
167 152
168 DISALLOW_COPY_AND_ASSIGN(MetricsRecorder); 153 DISALLOW_COPY_AND_ASSIGN(MetricsRecorder);
169 }; 154 };
170 155
171 } // namespace 156 } // namespace
172 157
173 TEST(TranslateCommonMetricsTest, ReportContentLanguage) { 158 TEST(TranslateMetricsTest, ReportContentLanguage) {
174 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 159 MetricsRecorder recorder(
175 TranslateCommonMetrics::UMA_CONTENT_LANGUAGE)); 160 translate::GetMetricsName(translate::UMA_CONTENT_LANGUAGE));
176 161
177 recorder.CheckLanguage(TranslateCommonMetrics::UMA_CONTENT_LANGUAGE, 0, 0, 0); 162 recorder.CheckLanguage(translate::UMA_CONTENT_LANGUAGE, 0, 0, 0);
178 TranslateCommonMetrics::ReportContentLanguage(std::string(), std::string()); 163 translate::ReportContentLanguage(std::string(), std::string());
179 recorder.CheckLanguage(TranslateCommonMetrics::UMA_CONTENT_LANGUAGE, 1, 0, 0); 164 recorder.CheckLanguage(translate::UMA_CONTENT_LANGUAGE, 1, 0, 0);
180 TranslateCommonMetrics::ReportContentLanguage("ja_JP", "ja-JP"); 165 translate::ReportContentLanguage("ja_JP", "ja-JP");
181 recorder.CheckLanguage(TranslateCommonMetrics::UMA_CONTENT_LANGUAGE, 1, 0, 1); 166 recorder.CheckLanguage(translate::UMA_CONTENT_LANGUAGE, 1, 0, 1);
182 TranslateCommonMetrics::ReportContentLanguage("en", "en"); 167 translate::ReportContentLanguage("en", "en");
183 recorder.CheckLanguage(TranslateCommonMetrics::UMA_CONTENT_LANGUAGE, 1, 1, 1); 168 recorder.CheckLanguage(translate::UMA_CONTENT_LANGUAGE, 1, 1, 1);
184 } 169 }
185 170
186 TEST(TranslateCommonMetricsTest, ReportHtmlLang) { 171 TEST(TranslateMetricsTest, ReportHtmlLang) {
187 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 172 MetricsRecorder recorder(translate::GetMetricsName(translate::UMA_HTML_LANG));
188 TranslateCommonMetrics::UMA_HTML_LANG));
189 173
190 recorder.CheckLanguage(TranslateCommonMetrics::UMA_HTML_LANG, 0, 0, 0); 174 recorder.CheckLanguage(translate::UMA_HTML_LANG, 0, 0, 0);
191 TranslateCommonMetrics::ReportHtmlLang(std::string(), std::string()); 175 translate::ReportHtmlLang(std::string(), std::string());
192 recorder.CheckLanguage(TranslateCommonMetrics::UMA_HTML_LANG, 1, 0, 0); 176 recorder.CheckLanguage(translate::UMA_HTML_LANG, 1, 0, 0);
193 TranslateCommonMetrics::ReportHtmlLang("ja_JP", "ja-JP"); 177 translate::ReportHtmlLang("ja_JP", "ja-JP");
194 recorder.CheckLanguage(TranslateCommonMetrics::UMA_HTML_LANG, 1, 0, 1); 178 recorder.CheckLanguage(translate::UMA_HTML_LANG, 1, 0, 1);
195 TranslateCommonMetrics::ReportHtmlLang("en", "en"); 179 translate::ReportHtmlLang("en", "en");
196 recorder.CheckLanguage(TranslateCommonMetrics::UMA_HTML_LANG, 1, 1, 1); 180 recorder.CheckLanguage(translate::UMA_HTML_LANG, 1, 1, 1);
197 } 181 }
198 182
199 TEST(TranslateCommonMetricsTest, ReportLanguageVerification) { 183 TEST(TranslateMetricsTest, ReportLanguageVerification) {
200 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 184 MetricsRecorder recorder(
201 TranslateCommonMetrics::UMA_LANGUAGE_VERIFICATION)); 185 translate::GetMetricsName(translate::UMA_LANGUAGE_VERIFICATION));
202 186
203 recorder.CheckLanguageVerification(0, 0, 0, 0, 0, 0, 0); 187 recorder.CheckLanguageVerification(0, 0, 0, 0, 0, 0, 0);
204 TranslateCommonMetrics::ReportLanguageVerification( 188 translate::ReportLanguageVerification(
205 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_DISABLED); 189 translate::LANGUAGE_VERIFICATION_CLD_DISABLED);
206 recorder.CheckLanguageVerification(1, 0, 0, 0, 0, 0, 0); 190 recorder.CheckLanguageVerification(1, 0, 0, 0, 0, 0, 0);
207 TranslateCommonMetrics::ReportLanguageVerification( 191 translate::ReportLanguageVerification(
208 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_ONLY); 192 translate::LANGUAGE_VERIFICATION_CLD_ONLY);
209 recorder.CheckLanguageVerification(1, 1, 0, 0, 0, 0, 0); 193 recorder.CheckLanguageVerification(1, 1, 0, 0, 0, 0, 0);
210 TranslateCommonMetrics::ReportLanguageVerification( 194 translate::ReportLanguageVerification(
211 TranslateCommonMetrics::LANGUAGE_VERIFICATION_UNKNOWN); 195 translate::LANGUAGE_VERIFICATION_UNKNOWN);
212 recorder.CheckLanguageVerification(1, 1, 1, 0, 0, 0, 0); 196 recorder.CheckLanguageVerification(1, 1, 1, 0, 0, 0, 0);
213 TranslateCommonMetrics::ReportLanguageVerification( 197 translate::ReportLanguageVerification(
214 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_AGREE); 198 translate::LANGUAGE_VERIFICATION_CLD_AGREE);
215 recorder.CheckLanguageVerification(1, 1, 1, 1, 0, 0, 0); 199 recorder.CheckLanguageVerification(1, 1, 1, 1, 0, 0, 0);
216 TranslateCommonMetrics::ReportLanguageVerification( 200 translate::ReportLanguageVerification(
217 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_DISAGREE); 201 translate::LANGUAGE_VERIFICATION_CLD_DISAGREE);
218 recorder.CheckLanguageVerification(1, 1, 1, 1, 1, 0, 0); 202 recorder.CheckLanguageVerification(1, 1, 1, 1, 1, 0, 0);
219 TranslateCommonMetrics::ReportLanguageVerification( 203 translate::ReportLanguageVerification(
220 TranslateCommonMetrics::LANGUAGE_VERIFICATION_TRUST_CLD); 204 translate::LANGUAGE_VERIFICATION_TRUST_CLD);
221 recorder.CheckLanguageVerification(1, 1, 1, 1, 1, 1, 0); 205 recorder.CheckLanguageVerification(1, 1, 1, 1, 1, 1, 0);
222 TranslateCommonMetrics::ReportLanguageVerification( 206 translate::ReportLanguageVerification(
223 TranslateCommonMetrics::LANGUAGE_VERIFICATION_CLD_COMPLEMENT_SUB_CODE); 207 translate::LANGUAGE_VERIFICATION_CLD_COMPLEMENT_SUB_CODE);
224 recorder.CheckLanguageVerification(1, 1, 1, 1, 1, 1, 1); 208 recorder.CheckLanguageVerification(1, 1, 1, 1, 1, 1, 1);
225 } 209 }
226 210
227 TEST(TranslateCommonMetricsTest, ReportTimeToBeReady) { 211 TEST(TranslateMetricsTest, ReportTimeToBeReady) {
228 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 212 MetricsRecorder recorder(
229 TranslateCommonMetrics::UMA_TIME_TO_BE_READY)); 213 translate::GetMetricsName(translate::UMA_TIME_TO_BE_READY));
230 recorder.CheckTotalCount(0); 214 recorder.CheckTotalCount(0);
231 TranslateCommonMetrics::ReportTimeToBeReady(3.14); 215 translate::ReportTimeToBeReady(3.14);
232 recorder.CheckValueInLogs(3.14); 216 recorder.CheckValueInLogs(3.14);
233 recorder.CheckTotalCount(1); 217 recorder.CheckTotalCount(1);
234 } 218 }
235 219
236 TEST(TranslateCommonMetricsTest, ReportTimeToLoad) { 220 TEST(TranslateMetricsTest, ReportTimeToLoad) {
237 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 221 MetricsRecorder recorder(
238 TranslateCommonMetrics::UMA_TIME_TO_LOAD)); 222 translate::GetMetricsName(translate::UMA_TIME_TO_LOAD));
239 recorder.CheckTotalCount(0); 223 recorder.CheckTotalCount(0);
240 TranslateCommonMetrics::ReportTimeToLoad(573.0); 224 translate::ReportTimeToLoad(573.0);
241 recorder.CheckValueInLogs(573.0); 225 recorder.CheckValueInLogs(573.0);
242 recorder.CheckTotalCount(1); 226 recorder.CheckTotalCount(1);
243 } 227 }
244 228
245 TEST(TranslateCommonMetricsTest, ReportTimeToTranslate) { 229 TEST(TranslateMetricsTest, ReportTimeToTranslate) {
246 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 230 MetricsRecorder recorder(
247 TranslateCommonMetrics::UMA_TIME_TO_TRANSLATE)); 231 translate::GetMetricsName(translate::UMA_TIME_TO_TRANSLATE));
248 recorder.CheckTotalCount(0); 232 recorder.CheckTotalCount(0);
249 TranslateCommonMetrics::ReportTimeToTranslate(4649.0); 233 translate::ReportTimeToTranslate(4649.0);
250 recorder.CheckValueInLogs(4649.0); 234 recorder.CheckValueInLogs(4649.0);
251 recorder.CheckTotalCount(1); 235 recorder.CheckTotalCount(1);
252 } 236 }
253 237
254 TEST(TranslateCommonMetricsTest, ReportUserActionDuration) { 238 TEST(TranslateMetricsTest, ReportUserActionDuration) {
255 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 239 MetricsRecorder recorder(
256 TranslateCommonMetrics::UMA_USER_ACTION_DURATION)); 240 translate::GetMetricsName(translate::UMA_USER_ACTION_DURATION));
257 recorder.CheckTotalCount(0); 241 recorder.CheckTotalCount(0);
258 TimeTicks begin = TimeTicks::Now(); 242 TimeTicks begin = TimeTicks::Now();
259 TimeTicks end = begin + base::TimeDelta::FromSeconds(3776); 243 TimeTicks end = begin + base::TimeDelta::FromSeconds(3776);
260 TranslateCommonMetrics::ReportUserActionDuration(begin, end); 244 translate::ReportUserActionDuration(begin, end);
261 recorder.CheckValueInLogs(3776000.0); 245 recorder.CheckValueInLogs(3776000.0);
262 recorder.CheckTotalCount(1); 246 recorder.CheckTotalCount(1);
263 } 247 }
264 248
265 TEST(TranslateCommonMetricsTest, ReportPageScheme) { 249 TEST(TranslateMetricsTest, ReportPageScheme) {
266 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 250 MetricsRecorder recorder(
267 TranslateCommonMetrics::UMA_PAGE_SCHEME)); 251 translate::GetMetricsName(translate::UMA_PAGE_SCHEME));
268 recorder.CheckScheme(0, 0, 0); 252 recorder.CheckScheme(0, 0, 0);
269 TranslateCommonMetrics::ReportPageScheme("http"); 253 translate::ReportPageScheme("http");
270 recorder.CheckScheme(1, 0, 0); 254 recorder.CheckScheme(1, 0, 0);
271 TranslateCommonMetrics::ReportPageScheme("https"); 255 translate::ReportPageScheme("https");
272 recorder.CheckScheme(1, 1, 0); 256 recorder.CheckScheme(1, 1, 0);
273 TranslateCommonMetrics::ReportPageScheme("ftp"); 257 translate::ReportPageScheme("ftp");
274 recorder.CheckScheme(1, 1, 1); 258 recorder.CheckScheme(1, 1, 1);
275 } 259 }
276 260
277 TEST(TranslateCommonMetricsTest, ReportSimilarLanguageMatch) { 261 TEST(TranslateMetricsTest, ReportSimilarLanguageMatch) {
278 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 262 MetricsRecorder recorder(
279 TranslateCommonMetrics::UMA_SIMILAR_LANGUAGE_MATCH)); 263 translate::GetMetricsName(translate::UMA_SIMILAR_LANGUAGE_MATCH));
280 recorder.CheckTotalCount(0); 264 recorder.CheckTotalCount(0);
281 EXPECT_EQ(0, recorder.GetCount(kTrue)); 265 EXPECT_EQ(0, recorder.GetCount(kTrue));
282 EXPECT_EQ(0, recorder.GetCount(kFalse)); 266 EXPECT_EQ(0, recorder.GetCount(kFalse));
283 TranslateCommonMetrics::ReportSimilarLanguageMatch(true); 267 translate::ReportSimilarLanguageMatch(true);
284 EXPECT_EQ(1, recorder.GetCount(kTrue)); 268 EXPECT_EQ(1, recorder.GetCount(kTrue));
285 EXPECT_EQ(0, recorder.GetCount(kFalse)); 269 EXPECT_EQ(0, recorder.GetCount(kFalse));
286 TranslateCommonMetrics::ReportSimilarLanguageMatch(false); 270 translate::ReportSimilarLanguageMatch(false);
287 EXPECT_EQ(1, recorder.GetCount(kTrue)); 271 EXPECT_EQ(1, recorder.GetCount(kTrue));
288 EXPECT_EQ(1, recorder.GetCount(kFalse)); 272 EXPECT_EQ(1, recorder.GetCount(kFalse));
289 } 273 }
290 274
291 TEST(TranslateCommonMetricsTest, ReportLanguageDetectionTime) { 275 TEST(TranslateMetricsTest, ReportLanguageDetectionTime) {
292 MetricsRecorder recorder(TranslateCommonMetrics::GetMetricsName( 276 MetricsRecorder recorder(
293 TranslateCommonMetrics::UMA_LANGUAGE_DETECTION)); 277 translate::GetMetricsName(translate::UMA_LANGUAGE_DETECTION));
294 recorder.CheckTotalCount(0); 278 recorder.CheckTotalCount(0);
295 TimeTicks begin = TimeTicks::Now(); 279 TimeTicks begin = TimeTicks::Now();
296 TimeTicks end = begin + base::TimeDelta::FromMicroseconds(9009); 280 TimeTicks end = begin + base::TimeDelta::FromMicroseconds(9009);
297 TranslateCommonMetrics::ReportLanguageDetectionTime(begin, end); 281 translate::ReportLanguageDetectionTime(begin, end);
298 recorder.CheckValueInLogs(9.009); 282 recorder.CheckValueInLogs(9.009);
299 recorder.CheckTotalCount(1); 283 recorder.CheckTotalCount(1);
300 } 284 }
OLDNEW
« no previous file with comments | « components/translate/common/translate_metrics.cc ('k') | components/translate/common/translate_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698