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

Side by Side Diff: ios/chrome/app/safe_mode/safe_mode_view_controller_unittest.mm

Issue 2709513004: [ObjC ARC] Converts ios/chrome/app/safe_mode:unit_tests to ARC. (Closed)
Patch Set: include Created 3 years, 10 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
« no previous file with comments | « ios/chrome/app/safe_mode/safe_mode_coordinator_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/mac/scoped_nsobject.h"
6 #import "breakpad/src/client/ios/BreakpadController.h" 5 #import "breakpad/src/client/ios/BreakpadController.h"
7 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h" 6 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h"
8 #import "ios/chrome/browser/crash_report/breakpad_helper.h" 7 #import "ios/chrome/browser/crash_report/breakpad_helper.h"
9 #import "ios/chrome/test/base/scoped_block_swizzler.h" 8 #import "ios/chrome/test/base/scoped_block_swizzler.h"
10 #import "ios/chrome/test/ocmock/OCMockObject+BreakpadControllerTesting.h" 9 #import "ios/chrome/test/ocmock/OCMockObject+BreakpadControllerTesting.h"
11 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
13 #import "third_party/ocmock/OCMock/OCMock.h" 12 #import "third_party/ocmock/OCMock/OCMock.h"
14 #include "third_party/ocmock/gtest_support.h" 13 #include "third_party/ocmock/gtest_support.h"
15 14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
16 namespace { 19 namespace {
17 20
18 const int kCrashReportCount = 2; 21 const int kCrashReportCount = 2;
19 22
20 class SafeModeViewControllerTest : public PlatformTest { 23 class SafeModeViewControllerTest : public PlatformTest {
21 public: 24 public:
22 void SetUp() override { 25 void SetUp() override {
23 PlatformTest::SetUp(); 26 PlatformTest::SetUp();
24 27
25 mock_breakpad_controller_.reset( 28 mock_breakpad_controller_ =
26 [[OCMockObject mockForClass:[BreakpadController class]] retain]); 29 [OCMockObject mockForClass:[BreakpadController class]];
27 30
28 // Swizzle +[BreakpadController sharedInstance] to return 31 // Swizzle +[BreakpadController sharedInstance] to return
29 // |mock_breakpad_controller_| instead of the normal singleton instance. 32 // |mock_breakpad_controller_| instead of the normal singleton instance.
30 id implementation_block = ^BreakpadController*(id self) { 33 id implementation_block = ^BreakpadController*(id self) {
31 return mock_breakpad_controller_.get(); 34 return mock_breakpad_controller_;
32 }; 35 };
33 breakpad_controller_shared_instance_swizzler_.reset(new ScopedBlockSwizzler( 36 breakpad_controller_shared_instance_swizzler_.reset(new ScopedBlockSwizzler(
34 [BreakpadController class], @selector(sharedInstance), 37 [BreakpadController class], @selector(sharedInstance),
35 implementation_block)); 38 implementation_block));
36 } 39 }
37 40
38 void TearDown() override { 41 void TearDown() override {
39 [[mock_breakpad_controller_ stub] stop]; 42 [[mock_breakpad_controller_ stub] stop];
40 breakpad_helper::SetEnabled(false); 43 breakpad_helper::SetEnabled(false);
41 44
42 PlatformTest::TearDown(); 45 PlatformTest::TearDown();
43 } 46 }
44 47
45 protected: 48 protected:
46 base::scoped_nsobject<id> mock_breakpad_controller_; 49 id mock_breakpad_controller_;
47 std::unique_ptr<ScopedBlockSwizzler> 50 std::unique_ptr<ScopedBlockSwizzler>
48 breakpad_controller_shared_instance_swizzler_; 51 breakpad_controller_shared_instance_swizzler_;
49 }; 52 };
50 53
51 // Verify that +[SafeModeViewController hasSuggestions] returns YES if and only 54 // Verify that +[SafeModeViewController hasSuggestions] returns YES if and only
52 // if crash reporter and crash report uploading are enabled and there are 55 // if crash reporter and crash report uploading are enabled and there are
53 // multiple crash reports to upload. 56 // multiple crash reports to upload.
54 TEST_F(SafeModeViewControllerTest, HasSuggestions) { 57 TEST_F(SafeModeViewControllerTest, HasSuggestions) {
55 // Test when crash reporter is disabled. 58 // Test when crash reporter is disabled.
56 breakpad_helper::SetEnabled(false); 59 breakpad_helper::SetEnabled(false);
57 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 60 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
58 EXPECT_FALSE([SafeModeViewController hasSuggestions]); 61 EXPECT_FALSE([SafeModeViewController hasSuggestions]);
59 62
60 breakpad_helper::SetUploadingEnabled(false); 63 breakpad_helper::SetUploadingEnabled(false);
61 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 64 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
62 EXPECT_FALSE([SafeModeViewController hasSuggestions]); 65 EXPECT_FALSE([SafeModeViewController hasSuggestions]);
63 66
64 breakpad_helper::SetUploadingEnabled(true); 67 breakpad_helper::SetUploadingEnabled(true);
65 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 68 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
66 EXPECT_FALSE([SafeModeViewController hasSuggestions]); 69 EXPECT_FALSE([SafeModeViewController hasSuggestions]);
67 70
68 // Test when crash reporter is enabled. 71 // Test when crash reporter is enabled.
69 [[mock_breakpad_controller_ expect] start:NO]; 72 [[mock_breakpad_controller_ expect] start:NO];
70 breakpad_helper::SetEnabled(true); 73 breakpad_helper::SetEnabled(true);
71 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 74 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
72 EXPECT_FALSE([SafeModeViewController hasSuggestions]); 75 EXPECT_FALSE([SafeModeViewController hasSuggestions]);
73 76
74 [[mock_breakpad_controller_ expect] setUploadingEnabled:NO]; 77 [[mock_breakpad_controller_ expect] setUploadingEnabled:NO];
75 breakpad_helper::SetUploadingEnabled(false); 78 breakpad_helper::SetUploadingEnabled(false);
76 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 79 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
77 EXPECT_FALSE([SafeModeViewController hasSuggestions]); 80 EXPECT_FALSE([SafeModeViewController hasSuggestions]);
78 81
79 // Test when crash reporter and crash report uploading are enabled. 82 // Test when crash reporter and crash report uploading are enabled.
80 [[mock_breakpad_controller_ expect] setUploadingEnabled:YES]; 83 [[mock_breakpad_controller_ expect] setUploadingEnabled:YES];
81 breakpad_helper::SetUploadingEnabled(true); 84 breakpad_helper::SetUploadingEnabled(true);
82 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 85 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
83 86
84 [mock_breakpad_controller_ cr_expectGetCrashReportCount:0]; 87 [mock_breakpad_controller_ cr_expectGetCrashReportCount:0];
85 EXPECT_FALSE([SafeModeViewController hasSuggestions]); 88 EXPECT_FALSE([SafeModeViewController hasSuggestions]);
86 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 89 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
87 90
88 [mock_breakpad_controller_ cr_expectGetCrashReportCount:kCrashReportCount]; 91 [mock_breakpad_controller_ cr_expectGetCrashReportCount:kCrashReportCount];
89 EXPECT_TRUE([SafeModeViewController hasSuggestions]); 92 EXPECT_TRUE([SafeModeViewController hasSuggestions]);
90 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_.get()); 93 EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
91 } 94 }
92 95
93 } // namespace 96 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/app/safe_mode/safe_mode_coordinator_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698