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

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

Issue 263683002: Set file tokens for NaCl main nexe if available to enable validation caching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clear tokens too Created 6 years, 7 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
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 "chrome/test/base/uma_histogram_helper.h" 5 #include "chrome/test/base/uma_histogram_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/statistics_recorder.h" 8 #include "base/metrics/statistics_recorder.h"
9 #include "base/test/test_timeouts.h" 9 #include "base/test/test_timeouts.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
(...skipping 26 matching lines...) Expand all
37 EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram) 37 EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram)
38 << "Histogram \"" << name << "\" does not exist."; 38 << "Histogram \"" << name << "\" does not exist.";
39 39
40 if (histogram) { 40 if (histogram) {
41 scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples()); 41 scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
42 CheckBucketCount(name, sample, expected_count, *samples); 42 CheckBucketCount(name, sample, expected_count, *samples);
43 CheckTotalCount(name, expected_count, *samples); 43 CheckTotalCount(name, expected_count, *samples);
44 } 44 }
45 } 45 }
46 46
47 void UMAHistogramHelper::ExpectBucketCount(
48 const std::string& name,
49 base::HistogramBase::Sample sample,
50 base::HistogramBase::Count expected_count) {
51 base::HistogramBase* histogram =
52 base::StatisticsRecorder::FindHistogram(name);
53 EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram)
54 << "Histogram \"" << name << "\" does not exist.";
55
56 if (histogram) {
57 scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
58 CheckBucketCount(name, sample, expected_count, *samples);
59 }
60 }
61
47 void UMAHistogramHelper::ExpectTotalCount( 62 void UMAHistogramHelper::ExpectTotalCount(
48 const std::string& name, 63 const std::string& name,
49 base::HistogramBase::Count count) { 64 base::HistogramBase::Count count) {
50 base::HistogramBase* histogram = 65 base::HistogramBase* histogram =
51 base::StatisticsRecorder::FindHistogram(name); 66 base::StatisticsRecorder::FindHistogram(name);
52 if (histogram) { 67 if (histogram) {
53 scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples()); 68 scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
54 CheckTotalCount(name, count, *samples); 69 CheckTotalCount(name, count, *samples);
55 } else { 70 } else {
56 // No histogram means there were zero samples. 71 // No histogram means there were zero samples.
(...skipping 18 matching lines...) Expand all
75 90
76 void UMAHistogramHelper::CheckTotalCount( 91 void UMAHistogramHelper::CheckTotalCount(
77 const std::string& name, 92 const std::string& name,
78 base::HistogramBase::Count expected_count, 93 base::HistogramBase::Count expected_count,
79 base::HistogramSamples& samples) { 94 base::HistogramSamples& samples) {
80 EXPECT_EQ(expected_count, samples.TotalCount()) 95 EXPECT_EQ(expected_count, samples.TotalCount())
81 << "Histogram \"" << name 96 << "Histogram \"" << name
82 << "\" does not have the right total number of samples (" 97 << "\" does not have the right total number of samples ("
83 << expected_count << ")."; 98 << expected_count << ").";
84 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698