OLD | NEW |
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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #import "chrome/browser/chrome_browser_application_mac.h" | 10 #import "chrome/browser/chrome_browser_application_mac.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // Random other exceptions map to |kUnknownNSException|. | 39 // Random other exceptions map to |kUnknownNSException|. |
40 EXPECT_EQ(BinForExceptionNamed(@"CustomName"), kUnknownNSException); | 40 EXPECT_EQ(BinForExceptionNamed(@"CustomName"), kUnknownNSException); |
41 EXPECT_EQ(BinForExceptionNamed(@"Custom Name"), kUnknownNSException); | 41 EXPECT_EQ(BinForExceptionNamed(@"Custom Name"), kUnknownNSException); |
42 EXPECT_EQ(BinForExceptionNamed(@""), kUnknownNSException); | 42 EXPECT_EQ(BinForExceptionNamed(@""), kUnknownNSException); |
43 EXPECT_EQ(BinForException(nil), kUnknownNSException); | 43 EXPECT_EQ(BinForException(nil), kUnknownNSException); |
44 } | 44 } |
45 | 45 |
46 TEST(ChromeApplicationMacTest, RecordException) { | 46 TEST(ChromeApplicationMacTest, RecordException) { |
47 // Start up a histogram recorder. | 47 // Start up a histogram recorder. |
48 StatisticsRecorder recorder; | 48 // TODO(rtenneti): Leaks StatisticsRecorder and will update suppressions. |
| 49 base::StatisticsRecorder::Initialize(); |
49 | 50 |
50 StatisticsRecorder::Histograms histograms; | 51 StatisticsRecorder::Histograms histograms; |
51 StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms); | 52 StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms); |
52 EXPECT_EQ(0U, histograms.size()); | 53 EXPECT_EQ(0U, histograms.size()); |
53 | 54 |
54 // Record some known exceptions. | 55 // Record some known exceptions. |
55 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); | 56 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); |
56 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); | 57 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); |
57 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); | 58 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); |
58 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); | 59 RecordExceptionWithUma(ExceptionNamed(NSGenericException)); |
(...skipping 20 matching lines...) Expand all Loading... |
79 EXPECT_EQ(1, sample.counts(1)); | 80 EXPECT_EQ(1, sample.counts(1)); |
80 EXPECT_EQ(3, sample.counts(2)); | 81 EXPECT_EQ(3, sample.counts(2)); |
81 EXPECT_EQ(2, sample.counts(3)); | 82 EXPECT_EQ(2, sample.counts(3)); |
82 | 83 |
83 // The unknown exceptions should end up in the overflow bucket. | 84 // The unknown exceptions should end up in the overflow bucket. |
84 EXPECT_EQ(kUnknownNSException + 1, histograms[0]->bucket_count()); | 85 EXPECT_EQ(kUnknownNSException + 1, histograms[0]->bucket_count()); |
85 EXPECT_EQ(4, sample.counts(kUnknownNSException)); | 86 EXPECT_EQ(4, sample.counts(kUnknownNSException)); |
86 } | 87 } |
87 | 88 |
88 } // chrome_browser_application_mac | 89 } // chrome_browser_application_mac |
OLD | NEW |