| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 | 6 |
| 7 #include "ios/chrome/browser/crash_loop_detection_util.h" | 7 #include "ios/chrome/browser/crash_loop_detection_util.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
| 10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
| 11 namespace { | 15 namespace { |
| 12 // The key used to store the count in the implementation. | 16 // The key used to store the count in the implementation. |
| 13 NSString* const kAppStartupAttemptCountKey = @"AppStartupFailureCount"; | 17 NSString* const kAppStartupAttemptCountKey = @"AppStartupFailureCount"; |
| 14 | 18 |
| 15 typedef PlatformTest CrashLoopDetectionUtilTest; | 19 typedef PlatformTest CrashLoopDetectionUtilTest; |
| 16 | 20 |
| 17 TEST_F(CrashLoopDetectionUtilTest, FullCycle) { | 21 TEST_F(CrashLoopDetectionUtilTest, FullCycle) { |
| 18 crash_util::ResetFailedStartupAttemptCountForTests(); | 22 crash_util::ResetFailedStartupAttemptCountForTests(); |
| 19 | 23 |
| 20 // Simulate one prior crash. | 24 // Simulate one prior crash. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 crash_util::IncrementFailedStartupAttemptCount(false); | 39 crash_util::IncrementFailedStartupAttemptCount(false); |
| 36 EXPECT_EQ(2, [defaults integerForKey:kAppStartupAttemptCountKey]); | 40 EXPECT_EQ(2, [defaults integerForKey:kAppStartupAttemptCountKey]); |
| 37 | 41 |
| 38 // After a reset it should be 0 internally, but the same via the API. | 42 // After a reset it should be 0 internally, but the same via the API. |
| 39 crash_util::ResetFailedStartupAttemptCount(); | 43 crash_util::ResetFailedStartupAttemptCount(); |
| 40 EXPECT_EQ(1, crash_util::GetFailedStartupAttemptCount()); | 44 EXPECT_EQ(1, crash_util::GetFailedStartupAttemptCount()); |
| 41 EXPECT_EQ(0, [defaults integerForKey:kAppStartupAttemptCountKey]); | 45 EXPECT_EQ(0, [defaults integerForKey:kAppStartupAttemptCountKey]); |
| 42 } | 46 } |
| 43 | 47 |
| 44 } // namespace | 48 } // namespace |
| OLD | NEW |