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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/metrics/histogram.h" | 6 #include "base/metrics/histogram.h" |
7 #include "base/metrics/statistics_recorder.h" | 7 #include "base/metrics/statistics_recorder.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/protector/base_setting_change.h" | 10 #include "chrome/browser/protector/base_setting_change.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 void ExpectSettingsOpened(const std::string& subpage) { | 123 void ExpectSettingsOpened(const std::string& subpage) { |
124 GURL settings_url(chrome::kChromeUISettingsURL + subpage); | 124 GURL settings_url(chrome::kChromeUISettingsURL + subpage); |
125 EXPECT_CALL(*mock_protector_service_, OpenTab(settings_url, browser())); | 125 EXPECT_CALL(*mock_protector_service_, OpenTab(settings_url, browser())); |
126 } | 126 } |
127 | 127 |
128 void ExpectHistogramCount(const std::string& name, | 128 void ExpectHistogramCount(const std::string& name, |
129 size_t bucket, | 129 size_t bucket, |
130 base::Histogram::Count count) { | 130 base::Histogram::Count count) { |
131 base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name); | 131 base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name); |
132 EXPECT_TRUE(histogram != NULL); | 132 EXPECT_TRUE(histogram != NULL); |
133 base::Histogram::SampleSet sample; | 133 scoped_ptr<base::BucketHistogramSamples> samples = |
134 histogram->SnapshotSample(&sample); | 134 histogram->SnapshotSamples(); |
135 EXPECT_EQ(count, sample.counts(bucket)) << | 135 EXPECT_EQ(count, samples->GetCountFromBucketIndex(bucket)) |
136 "Invalid " << name << " value for bucket " << bucket; | 136 << "Invalid " << name << " value for bucket " << bucket; |
137 } | 137 } |
138 | 138 |
139 protected: | 139 protected: |
140 MockProtectorService* mock_protector_service_; | 140 MockProtectorService* mock_protector_service_; |
141 TemplateURLService* turl_service_; | 141 TemplateURLService* turl_service_; |
142 scoped_ptr<TemplateURL> prepopulated_url_; | 142 scoped_ptr<TemplateURL> prepopulated_url_; |
143 }; | 143 }; |
144 | 144 |
145 // Tests below call both Apply and Discard on a single change instance. | 145 // Tests below call both Apply and Discard on a single change instance. |
146 // This is test-only and should not be happening in real code. | 146 // This is test-only and should not be happening in real code. |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 EXPECT_EQ(FindTemplateURL(http_example_info), | 668 EXPECT_EQ(FindTemplateURL(http_example_info), |
669 turl_service_->GetDefaultSearchProvider()); | 669 turl_service_->GetDefaultSearchProvider()); |
670 | 670 |
671 // Discard does nothing - backup was already active. | 671 // Discard does nothing - backup was already active. |
672 change->Discard(browser()); | 672 change->Discard(browser()); |
673 EXPECT_EQ(FindTemplateURL(http_example_info), | 673 EXPECT_EQ(FindTemplateURL(http_example_info), |
674 turl_service_->GetDefaultSearchProvider()); | 674 turl_service_->GetDefaultSearchProvider()); |
675 } | 675 } |
676 | 676 |
677 } // namespace protector | 677 } // namespace protector |
OLD | NEW |