| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 histogram = | 60 histogram = |
| 61 StatisticsRecorder::FindHistogram("SpellCheck.Enabled"); | 61 StatisticsRecorder::FindHistogram("SpellCheck.Enabled"); |
| 62 ASSERT_TRUE(histogram != NULL); | 62 ASSERT_TRUE(histogram != NULL); |
| 63 samples = histogram->SnapshotSamples(); | 63 samples = histogram->SnapshotSamples(); |
| 64 samples->Subtract(*baseline); | 64 samples->Subtract(*baseline); |
| 65 EXPECT_EQ(0, samples->GetCount(0)); | 65 EXPECT_EQ(0, samples->GetCount(0)); |
| 66 EXPECT_EQ(1, samples->GetCount(1)); | 66 EXPECT_EQ(1, samples->GetCount(1)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 TEST_F(SpellcheckHostMetricsTest, CustomWordStats) { | 69 TEST_F(SpellcheckHostMetricsTest, CustomWordStats) { |
| 70 metrics()->RecordCustomWordCountStats(123); | 70 SpellCheckHostMetrics::RecordCustomWordCountStats(123); |
| 71 | 71 |
| 72 HistogramBase* histogram = | 72 HistogramBase* histogram = |
| 73 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); | 73 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); |
| 74 ASSERT_TRUE(histogram != NULL); | 74 ASSERT_TRUE(histogram != NULL); |
| 75 scoped_ptr<HistogramSamples> baseline = histogram->SnapshotSamples(); | 75 scoped_ptr<HistogramSamples> baseline = histogram->SnapshotSamples(); |
| 76 | 76 |
| 77 metrics()->RecordCustomWordCountStats(23); | 77 SpellCheckHostMetrics::RecordCustomWordCountStats(23); |
| 78 histogram = | 78 histogram = |
| 79 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); | 79 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); |
| 80 ASSERT_TRUE(histogram != NULL); | 80 ASSERT_TRUE(histogram != NULL); |
| 81 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | 81 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
| 82 | 82 |
| 83 samples->Subtract(*baseline); | 83 samples->Subtract(*baseline); |
| 84 EXPECT_EQ(23,samples->sum()); | 84 EXPECT_EQ(23,samples->sum()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) { | 87 TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 metrics()->RecordSpellingServiceStats(true); | 148 metrics()->RecordSpellingServiceStats(true); |
| 149 | 149 |
| 150 histogram = | 150 histogram = |
| 151 StatisticsRecorder::FindHistogram(kMetricName); | 151 StatisticsRecorder::FindHistogram(kMetricName); |
| 152 ASSERT_TRUE(histogram != NULL); | 152 ASSERT_TRUE(histogram != NULL); |
| 153 samples = histogram->SnapshotSamples(); | 153 samples = histogram->SnapshotSamples(); |
| 154 samples->Subtract(*baseline); | 154 samples->Subtract(*baseline); |
| 155 EXPECT_EQ(0, samples->GetCount(0)); | 155 EXPECT_EQ(0, samples->GetCount(0)); |
| 156 EXPECT_EQ(1, samples->GetCount(1)); | 156 EXPECT_EQ(1, samples->GetCount(1)); |
| 157 } | 157 } |
| OLD | NEW |