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

Side by Side Diff: chrome/browser/chrome_browser_application_mac_unittest.mm

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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "base/mac/scoped_nsexception_enabler.h" 7 #import "base/mac/scoped_nsexception_enabler.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
10 #import "chrome/browser/chrome_browser_application_mac.h" 12 #import "chrome/browser/chrome_browser_application_mac.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 using base::Histogram; 15 using base::Histogram;
16 using base::HistogramSamples;
14 using base::StatisticsRecorder; 17 using base::StatisticsRecorder;
15 18
16 namespace chrome_browser_application_mac { 19 namespace chrome_browser_application_mac {
17 20
18 // Generate an NSException with the given name. 21 // Generate an NSException with the given name.
19 NSException* ExceptionNamed(NSString* name) { 22 NSException* ExceptionNamed(NSString* name) {
20 base::mac::ScopedNSExceptionEnabler enabler; 23 base::mac::ScopedNSExceptionEnabler enabler;
21 24
22 return [NSException exceptionWithName:name 25 return [NSException exceptionWithName:name
23 reason:@"No reason given" 26 reason:@"No reason given"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Record some unknown exceptions. 70 // Record some unknown exceptions.
68 RecordExceptionWithUma(ExceptionNamed(@"CustomName")); 71 RecordExceptionWithUma(ExceptionNamed(@"CustomName"));
69 RecordExceptionWithUma(ExceptionNamed(@"Custom Name")); 72 RecordExceptionWithUma(ExceptionNamed(@"Custom Name"));
70 RecordExceptionWithUma(ExceptionNamed(@"")); 73 RecordExceptionWithUma(ExceptionNamed(@""));
71 RecordExceptionWithUma(nil); 74 RecordExceptionWithUma(nil);
72 75
73 // We should have exactly the right number of exceptions. 76 // We should have exactly the right number of exceptions.
74 StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms); 77 StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms);
75 EXPECT_EQ(1U, histograms.size()); 78 EXPECT_EQ(1U, histograms.size());
76 EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histograms[0]->flags()); 79 EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histograms[0]->flags());
77 Histogram::SampleSet sample; 80
78 histograms[0]->SnapshotSample(&sample); 81 scoped_ptr<HistogramSamples> samples(histograms[0]->SnapshotSamples());
79 EXPECT_EQ(4, sample.counts(0)); 82 EXPECT_EQ(4, samples->GetCount(0));
80 EXPECT_EQ(1, sample.counts(1)); 83 EXPECT_EQ(1, samples->GetCount(1));
81 EXPECT_EQ(3, sample.counts(2)); 84 EXPECT_EQ(3, samples->GetCount(2));
82 EXPECT_EQ(2, sample.counts(3)); 85 EXPECT_EQ(2, samples->GetCount(3));
83 86
84 // The unknown exceptions should end up in the overflow bucket. 87 // The unknown exceptions should end up in the overflow bucket.
85 EXPECT_EQ(kUnknownNSException + 1, histograms[0]->bucket_count()); 88 EXPECT_EQ(kUnknownNSException + 1, histograms[0]->bucket_count());
86 EXPECT_EQ(4, sample.counts(kUnknownNSException)); 89 EXPECT_EQ(4, samples->GetCount(kUnknownNSException));
87 } 90 }
88 91
89 } // chrome_browser_application_mac 92 } // chrome_browser_application_mac
OLDNEW
« no previous file with comments | « base/metrics/sample_vector_unittest.cc ('k') | chrome/browser/net/http_pipelining_compatibility_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698