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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc

Issue 12335019: [Spellcheck] Add UMA stat for SpellingService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spellchecker/spellcheck_host_metrics.h" 5 #include "chrome/browser/spellchecker/spellcheck_host_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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 Histogram* histogram = 117 Histogram* histogram =
118 StatisticsRecorder::FindHistogram(histogramName[i]); 118 StatisticsRecorder::FindHistogram(histogramName[i]);
119 ASSERT_TRUE(histogram != NULL); 119 ASSERT_TRUE(histogram != NULL);
120 samples[i] = histogram->SnapshotSamples(); 120 samples[i] = histogram->SnapshotSamples();
121 if (baselines[i].get()) 121 if (baselines[i].get())
122 samples[i]->Subtract(*baselines[i]); 122 samples[i]->Subtract(*baselines[i]);
123 123
124 EXPECT_EQ(0, samples[i]->TotalCount()); 124 EXPECT_EQ(0, samples[i]->TotalCount());
125 } 125 }
126 } 126 }
127
128 TEST_F(SpellcheckHostMetricsTest, RecordSpellingServiceStats) {
129 const char kMetricName[] = "SpellCheck.SpellingService.Enabled";
130 scoped_ptr<HistogramSamples> baseline;
131 Histogram* histogram =
132 StatisticsRecorder::FindHistogram(kMetricName);
133 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
134 baseline = histogram->SnapshotSamples();
135
136 metrics()->RecordSpellingServiceStats(false);
137
138 histogram =
139 StatisticsRecorder::FindHistogram(kMetricName);
140 ASSERT_TRUE(histogram != NULL);
141 scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
142 if (baseline.get())
143 samples->Subtract(*baseline);
144 EXPECT_EQ(1, samples->GetCount(0));
145 EXPECT_EQ(0, samples->GetCount(1));
146
147 baseline.reset(samples.release());
148
149 metrics()->RecordSpellingServiceStats(true);
150
151 histogram =
152 StatisticsRecorder::FindHistogram(kMetricName);
153 ASSERT_TRUE(histogram != NULL);
154 samples = histogram->SnapshotSamples();
155 samples->Subtract(*baseline);
156 EXPECT_EQ(0, samples->GetCount(0));
157 EXPECT_EQ(1, samples->GetCount(1));
158 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_host_metrics.cc ('k') | chrome/browser/spellchecker/spellcheck_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698