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/message_loop.h" | 9 #include "base/message_loop/message_loop.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 "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 // For version specific disabled tests below (http://crbug.com/230534). | 17 // For version specific disabled tests below (http://crbug.com/230534). |
18 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
19 #endif | 19 #endif |
20 | 20 |
21 class SpellcheckHostMetricsTest : public testing::Test { | 21 class SpellcheckHostMetricsTest : public testing::Test { |
22 public: | 22 public: |
23 SpellcheckHostMetricsTest() { | 23 SpellcheckHostMetricsTest() { |
24 } | 24 } |
25 | 25 |
26 static void SetUpTestCase() { | 26 static void SetUpTestCase() { |
27 base::StatisticsRecorder::Initialize(); | 27 base::StatisticsRecorder::Initialize(); |
28 } | 28 } |
29 | 29 |
30 virtual void SetUp() OVERRIDE { | 30 virtual void SetUp() override { |
31 metrics_.reset(new SpellCheckHostMetrics); | 31 metrics_.reset(new SpellCheckHostMetrics); |
32 } | 32 } |
33 | 33 |
34 SpellCheckHostMetrics* metrics() { return metrics_.get(); } | 34 SpellCheckHostMetrics* metrics() { return metrics_.get(); } |
35 void RecordWordCountsForTesting() { metrics_->RecordWordCounts(); } | 35 void RecordWordCountsForTesting() { metrics_->RecordWordCounts(); } |
36 | 36 |
37 private: | 37 private: |
38 base::MessageLoop loop_; | 38 base::MessageLoop loop_; |
39 scoped_ptr<SpellCheckHostMetrics> metrics_; | 39 scoped_ptr<SpellCheckHostMetrics> metrics_; |
40 }; | 40 }; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 histogram_tester1.ExpectBucketCount(kMetricName, 0, 1); | 106 histogram_tester1.ExpectBucketCount(kMetricName, 0, 1); |
107 histogram_tester1.ExpectBucketCount(kMetricName, 1, 0); | 107 histogram_tester1.ExpectBucketCount(kMetricName, 1, 0); |
108 | 108 |
109 base::HistogramTester histogram_tester2; | 109 base::HistogramTester histogram_tester2; |
110 | 110 |
111 metrics()->RecordSpellingServiceStats(true); | 111 metrics()->RecordSpellingServiceStats(true); |
112 histogram_tester2.ExpectBucketCount(kMetricName, 0, 0); | 112 histogram_tester2.ExpectBucketCount(kMetricName, 0, 0); |
113 histogram_tester2.ExpectBucketCount(kMetricName, 1, 1); | 113 histogram_tester2.ExpectBucketCount(kMetricName, 1, 1); |
114 } | 114 } |
OLD | NEW |