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

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

Issue 12207058: Connect SparseHistogram with the rest of stats system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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/memory/scoped_ptr.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
11 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
12 #import "chrome/browser/chrome_browser_application_mac.h" 12 #import "chrome/browser/chrome_browser_application_mac.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using base::Histogram; 15 using base::HistogramBase;
16 using base::HistogramSamples; 16 using base::HistogramSamples;
17 using base::StatisticsRecorder; 17 using base::StatisticsRecorder;
18 18
19 namespace chrome_browser_application_mac { 19 namespace chrome_browser_application_mac {
20 20
21 // Generate an NSException with the given name. 21 // Generate an NSException with the given name.
22 NSException* ExceptionNamed(NSString* name) { 22 NSException* ExceptionNamed(NSString* name) {
23 base::mac::ScopedNSExceptionEnabler enabler; 23 base::mac::ScopedNSExceptionEnabler enabler;
24 24
25 return [NSException exceptionWithName:name 25 return [NSException exceptionWithName:name
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 // Record some unknown exceptions. 70 // Record some unknown exceptions.
71 RecordExceptionWithUma(ExceptionNamed(@"CustomName")); 71 RecordExceptionWithUma(ExceptionNamed(@"CustomName"));
72 RecordExceptionWithUma(ExceptionNamed(@"Custom Name")); 72 RecordExceptionWithUma(ExceptionNamed(@"Custom Name"));
73 RecordExceptionWithUma(ExceptionNamed(@"")); 73 RecordExceptionWithUma(ExceptionNamed(@""));
74 RecordExceptionWithUma(nil); 74 RecordExceptionWithUma(nil);
75 75
76 // We should have exactly the right number of exceptions. 76 // We should have exactly the right number of exceptions.
77 StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms); 77 StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms);
78 EXPECT_EQ(1U, histograms.size()); 78 EXPECT_EQ(1U, histograms.size());
79 EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histograms[0]->flags()); 79 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histograms[0]->flags());
80 80
81 scoped_ptr<HistogramSamples> samples(histograms[0]->SnapshotSamples()); 81 scoped_ptr<HistogramSamples> samples(histograms[0]->SnapshotSamples());
82 EXPECT_EQ(4, samples->GetCount(0)); 82 EXPECT_EQ(4, samples->GetCount(0));
83 EXPECT_EQ(1, samples->GetCount(1)); 83 EXPECT_EQ(1, samples->GetCount(1));
84 EXPECT_EQ(3, samples->GetCount(2)); 84 EXPECT_EQ(3, samples->GetCount(2));
85 EXPECT_EQ(2, samples->GetCount(3)); 85 EXPECT_EQ(2, samples->GetCount(3));
86 86
87 // The unknown exceptions should end up in the overflow bucket. 87 // The unknown exceptions should end up in the overflow bucket.
88 EXPECT_EQ(kUnknownNSException + 1, histograms[0]->bucket_count()); 88 EXPECT_TRUE(histograms[0]->HasConstructionArguments(1,
89 kUnknownNSException,
90 kUnknownNSException + 1));
89 EXPECT_EQ(4, samples->GetCount(kUnknownNSException)); 91 EXPECT_EQ(4, samples->GetCount(kUnknownNSException));
90 } 92 }
91 93
92 } // chrome_browser_application_mac 94 } // chrome_browser_application_mac
OLDNEW
« no previous file with comments | « base/metrics/statistics_recorder.cc ('k') | chrome/browser/extensions/api/metrics_private/metrics_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698