Chromium Code Reviews| Index: chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc |
| diff --git a/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc b/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc |
| index a2b9bb3c2c2a77d2c78ea76f2d490011a5b20365..8614d53f203bd6555002839873b517a3aa8ca04f 100644 |
| --- a/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc |
| +++ b/chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc |
| @@ -124,3 +124,35 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) { |
| EXPECT_EQ(0, samples[i]->TotalCount()); |
| } |
| } |
| + |
| +TEST_F(SpellcheckHostMetricsTest, RecordSpellingServiceStats) { |
| + const char kMetricName[] = "SpellCheck.SpellingService.Enabled"; |
| + scoped_ptr<HistogramSamples> baseline; |
| + Histogram* histogram = |
| + StatisticsRecorder::FindHistogram(kMetricName); |
| + if (histogram) |
|
rpetterson
2013/02/21 22:01:06
When would this not be here? Or rather, why use "i
groby-ooo-7-16
2013/02/22 04:32:29
If no counts for this histogram have been recorded
|
| + baseline = histogram->SnapshotSamples(); |
| + |
| + metrics()->RecordSpellingServiceStats(false); |
| + |
| + histogram = |
| + StatisticsRecorder::FindHistogram(kMetricName); |
| + ASSERT_TRUE(histogram != NULL); |
| + scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples()); |
| + if (baseline.get()) |
| + samples->Subtract(*baseline); |
| + EXPECT_EQ(1, samples->GetCount(0)); |
| + EXPECT_EQ(0, samples->GetCount(1)); |
| + |
| + baseline.reset(samples.release()); |
| + |
| + metrics()->RecordSpellingServiceStats(true); |
| + |
| + histogram = |
| + StatisticsRecorder::FindHistogram(kMetricName); |
| + ASSERT_TRUE(histogram != NULL); |
| + samples = histogram->SnapshotSamples(); |
| + samples->Subtract(*baseline); |
| + EXPECT_EQ(0, samples->GetCount(0)); |
| + EXPECT_EQ(1, samples->GetCount(1)); |
| +} |