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

Side by Side Diff: chrome/test/base/uma_histogram_helper.h

Issue 344513005: Revert "Improve the no-op reconcilor so that it doesn't "hang" after the first execution, but inste… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 #ifndef CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ 5 #ifndef CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_
6 #define CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ 6 #define CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_
7 7
8 #include "base/memory/linked_ptr.h"
9 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_base.h" 9 #include "base/metrics/histogram_base.h"
11 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
12 11
13 // UMAHistogramHelper provides a simple interface for examining UMA histograms. 12 // UMAHistogramHelper provides a simple interface for examining UMA histograms.
14 // Tests can use this interface to verify that UMA data is getting logged as 13 // Tests can use this interface to verify that UMA data is getting logged as
15 // intended. 14 // intended.
16 class UMAHistogramHelper { 15 class UMAHistogramHelper {
17 public: 16 public:
18 // UMAHistogramHelper should be created before the execution of the test case.
19 UMAHistogramHelper(); 17 UMAHistogramHelper();
20 18
21 ~UMAHistogramHelper();
22
23 // Parameters should be string literals of all histograms to snapshot.
24 // Call this before executing the test code. This method can be called
25 // multiple times. The existing snapshots are preserved, except when one of
26 // the |histogram_names| was previously passed as a parameter, then a new
27 // snapshot will replace the existing one.
28 void PrepareSnapshot(const char* const histogram_names[],
29 size_t num_histograms);
30
31 // Each child process may have its own histogram data, make sure this data 19 // Each child process may have its own histogram data, make sure this data
32 // gets accumulated into the browser process before we examine the histograms. 20 // gets accumulated into the browser process before we examine the histograms.
33 void Fetch(); 21 void Fetch();
34 22
35 // We know the exact number of samples in a bucket, and that no other bucket 23 // We know the exact number of samples in a bucket, and that no other bucket
36 // should have samples. If |PrepareSnapshot| was called for the histogram 24 // should have samples.
37 // named |name| then the |expected_count| is the diff from the snapshot.
38 void ExpectUniqueSample(const std::string& name, 25 void ExpectUniqueSample(const std::string& name,
39 base::HistogramBase::Sample sample, 26 base::HistogramBase::Sample sample,
40 base::HistogramBase::Count expected_count); 27 base::HistogramBase::Count expected_count);
41 28
42 // We know the exact number of samples in a bucket, but other buckets may 29 // We know the exact number of samples in a bucket, but other buckets may
43 // have samples as well. If |PrepareSnapshot| was called for histogram named 30 // have samples as well.
44 // |name| then the |expected_count| is the diff from the snapshot.
45 void ExpectBucketCount(const std::string& name, 31 void ExpectBucketCount(const std::string& name,
46 base::HistogramBase::Sample sample, 32 base::HistogramBase::Sample sample,
47 base::HistogramBase::Count expected_count); 33 base::HistogramBase::Count expected_count);
48 34
49 // We don't know the values of the samples, but we know how many there are. If 35 // We don't know the values of the samples, but we know how many there are.
50 // |PrepareSnapshot| was called for |name| histogram, then the
51 // |count| is the diff from the snapshot.
52 void ExpectTotalCount(const std::string& name, 36 void ExpectTotalCount(const std::string& name,
53 base::HistogramBase::Count count); 37 base::HistogramBase::Count count);
54 38
55 private: 39 private:
56 void FetchCallback(); 40 void FetchCallback();
57 41
58 void CheckBucketCount(const std::string& name, 42 void CheckBucketCount(const std::string& name,
59 base::HistogramBase::Sample sample, 43 base::HistogramBase::Sample sample,
60 base::Histogram::Count expected_count, 44 base::Histogram::Count expected_count,
61 base::HistogramSamples& samples); 45 base::HistogramSamples& samples);
62 46
63 void CheckTotalCount(const std::string& name, 47 void CheckTotalCount(const std::string& name,
64 base::Histogram::Count expected_count, 48 base::Histogram::Count expected_count,
65 base::HistogramSamples& samples); 49 base::HistogramSamples& samples);
66 50
67 DISALLOW_COPY_AND_ASSIGN(UMAHistogramHelper); 51 DISALLOW_COPY_AND_ASSIGN(UMAHistogramHelper);
68
69 // The map from histogram names to their snapshots
70 std::map<std::string, linked_ptr<base::HistogramSamples> >
71 histogram_snapshots;
72 }; 52 };
73 53
74 #endif // CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ 54 #endif // CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/signin/account_reconcilor_unittest.cc ('k') | chrome/test/base/uma_histogram_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698