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

Unified Diff: chrome/browser/chrome_browser_application_mac_unittest.mm

Issue 2543813003: [Mac] Modify the ObjC exception preprocessor to make some exceptions fatal. (Closed)
Patch Set: Address comments Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | chrome/browser/mac/exception_processor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_application_mac_unittest.mm
diff --git a/chrome/browser/chrome_browser_application_mac_unittest.mm b/chrome/browser/chrome_browser_application_mac_unittest.mm
deleted file mode 100644
index 4252a7597133aba8edd39fb15b313ca364dd98c8..0000000000000000000000000000000000000000
--- a/chrome/browser/chrome_browser_application_mac_unittest.mm
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "chrome/browser/chrome_browser_application_mac.h"
-
-#import <Cocoa/Cocoa.h>
-#include <stddef.h>
-
-#include <memory>
-
-#include "base/metrics/histogram_macros.h"
-#include "base/metrics/histogram_samples.h"
-#include "base/metrics/statistics_recorder.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using base::HistogramBase;
-using base::HistogramSamples;
-using base::StatisticsRecorder;
-
-namespace chrome_browser_application_mac {
-
-// Generate an NSException with the given name.
-NSException* ExceptionNamed(NSString* name) {
- return [NSException exceptionWithName:name
- reason:@"No reason given"
- userInfo:nil];
-}
-
-// Helper to keep binning expectations readible.
-size_t BinForExceptionNamed(NSString* name) {
- return BinForException(ExceptionNamed(name));
-}
-
-TEST(ChromeApplicationMacTest, ExceptionBinning) {
- // These exceptions must be in this order.
- EXPECT_EQ(BinForExceptionNamed(NSGenericException), 0U);
- EXPECT_EQ(BinForExceptionNamed(NSRangeException), 1U);
- EXPECT_EQ(BinForExceptionNamed(NSInvalidArgumentException), 2U);
- EXPECT_EQ(BinForExceptionNamed(NSMallocException), 3U);
-
- // Random other exceptions map to |kUnknownNSException|.
- EXPECT_EQ(BinForExceptionNamed(@"CustomName"), kUnknownNSException);
- EXPECT_EQ(BinForExceptionNamed(@"Custom Name"), kUnknownNSException);
- EXPECT_EQ(BinForExceptionNamed(@""), kUnknownNSException);
- EXPECT_EQ(BinForException(nil), kUnknownNSException);
-}
-
-TEST(ChromeApplicationMacTest, RecordException) {
- // Start up a histogram recorder.
- // TODO(rtenneti): Leaks StatisticsRecorder and will update suppressions.
- base::StatisticsRecorder::Initialize();
-
- StatisticsRecorder::Histograms histograms;
- StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms);
- EXPECT_EQ(0U, histograms.size());
-
- // Record some known exceptions.
- RecordExceptionWithUma(ExceptionNamed(NSGenericException));
- RecordExceptionWithUma(ExceptionNamed(NSGenericException));
- RecordExceptionWithUma(ExceptionNamed(NSGenericException));
- RecordExceptionWithUma(ExceptionNamed(NSGenericException));
- RecordExceptionWithUma(ExceptionNamed(NSRangeException));
- RecordExceptionWithUma(ExceptionNamed(NSInvalidArgumentException));
- RecordExceptionWithUma(ExceptionNamed(NSInvalidArgumentException));
- RecordExceptionWithUma(ExceptionNamed(NSInvalidArgumentException));
- RecordExceptionWithUma(ExceptionNamed(NSMallocException));
- RecordExceptionWithUma(ExceptionNamed(NSMallocException));
-
- // Record some unknown exceptions.
- RecordExceptionWithUma(ExceptionNamed(@"CustomName"));
- RecordExceptionWithUma(ExceptionNamed(@"Custom Name"));
- RecordExceptionWithUma(ExceptionNamed(@""));
- RecordExceptionWithUma(nil);
-
- // We should have exactly the right number of exceptions.
- StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms);
- EXPECT_EQ(1U, histograms.size());
- EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histograms[0]->flags());
-
- std::unique_ptr<HistogramSamples> samples(histograms[0]->SnapshotSamples());
- EXPECT_EQ(4, samples->GetCount(0));
- EXPECT_EQ(1, samples->GetCount(1));
- EXPECT_EQ(3, samples->GetCount(2));
- EXPECT_EQ(2, samples->GetCount(3));
-
- // The unknown exceptions should end up in the overflow bucket.
- EXPECT_TRUE(histograms[0]->HasConstructionArguments(1,
- kUnknownNSException,
- kUnknownNSException + 1));
- EXPECT_EQ(4, samples->GetCount(kUnknownNSException));
-}
-
-} // chrome_browser_application_mac
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | chrome/browser/mac/exception_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698