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

Side by Side Diff: chrome/browser/protector/default_search_provider_change_browsertest.cc

Issue 10829466: SampleSet -> HistogramSamples (will be reused by SparseHistogram) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 "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/sample_vector.h"
7 #include "base/metrics/statistics_recorder.h" 8 #include "base/metrics/statistics_recorder.h"
8 #include "base/message_loop.h" 9 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/protector/base_setting_change.h" 11 #include "chrome/browser/protector/base_setting_change.h"
11 #include "chrome/browser/protector/histograms.h" 12 #include "chrome/browser/protector/histograms.h"
12 #include "chrome/browser/protector/mock_protector_service.h" 13 #include "chrome/browser/protector/mock_protector_service.h"
13 #include "chrome/browser/protector/protector_service_factory.h" 14 #include "chrome/browser/protector/protector_service_factory.h"
14 #include "chrome/browser/search_engines/template_url.h" 15 #include "chrome/browser/search_engines/template_url.h"
15 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 16 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
16 #include "chrome/browser/search_engines/template_url_service.h" 17 #include "chrome/browser/search_engines/template_url_service.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void ExpectSettingsOpened(const std::string& subpage) { 124 void ExpectSettingsOpened(const std::string& subpage) {
124 GURL settings_url(chrome::kChromeUISettingsURL + subpage); 125 GURL settings_url(chrome::kChromeUISettingsURL + subpage);
125 EXPECT_CALL(*mock_protector_service_, OpenTab(settings_url, browser())); 126 EXPECT_CALL(*mock_protector_service_, OpenTab(settings_url, browser()));
126 } 127 }
127 128
128 void ExpectHistogramCount(const std::string& name, 129 void ExpectHistogramCount(const std::string& name,
129 size_t bucket, 130 size_t bucket,
130 base::Histogram::Count count) { 131 base::Histogram::Count count) {
131 base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name); 132 base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
132 EXPECT_TRUE(histogram != NULL); 133 EXPECT_TRUE(histogram != NULL);
133 base::Histogram::SampleSet sample; 134 scoped_ptr<base::SampleVector> samples = histogram->SnapshotSamples();
134 histogram->SnapshotSample(&sample); 135 EXPECT_EQ(count, samples->GetCountAtIndex(bucket))
135 EXPECT_EQ(count, sample.counts(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
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
OLDNEW
« no previous file with comments | « chrome/browser/net/http_pipelining_compatibility_client_unittest.cc ('k') | chrome/common/metrics/metrics_log_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698