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

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

Issue 2627623002: [ObjC ARC] Converts ios/chrome/app/safe_mode:eg_tests to ARC. (Closed)
Patch Set: Created 3 years, 11 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/BUILD.gn ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <EarlGrey/EarlGrey.h> 5 #import <EarlGrey/EarlGrey.h>
6 #import <XCTest/XCTest.h> 6 #import <XCTest/XCTest.h>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/mac/scoped_nsobject.h"
11 #import "ios/chrome/app/chrome_overlay_window.h" 10 #import "ios/chrome/app/chrome_overlay_window.h"
12 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h" 11 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h"
13 #import "ios/chrome/browser/ui/main/main_view_controller.h" 12 #import "ios/chrome/browser/ui/main/main_view_controller.h"
14 #include "ios/chrome/grit/ios_chromium_strings.h" 13 #include "ios/chrome/grit/ios_chromium_strings.h"
15 #import "ios/chrome/test/base/scoped_block_swizzler.h" 14 #import "ios/chrome/test/base/scoped_block_swizzler.h"
16 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 15 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
17 16
17 #if !defined(__has_feature) || !__has_feature(objc_arc)
18 #error "This file requires ARC support."
19 #endif
20
18 namespace { 21 namespace {
19 22
20 // Returns the top view controller for rendering the Safe Mode Controller. 23 // Returns the top view controller for rendering the Safe Mode Controller.
21 UIViewController* GetActiveViewController() { 24 UIViewController* GetActiveViewController() {
22 UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow]; 25 UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
23 DCHECK([mainWindow isKindOfClass:[ChromeOverlayWindow class]]); 26 DCHECK([mainWindow isKindOfClass:[ChromeOverlayWindow class]]);
24 MainViewController* main_view_controller = 27 MainViewController* main_view_controller =
25 base::mac::ObjCCast<MainViewController>([mainWindow rootViewController]); 28 base::mac::ObjCCast<MainViewController>([mainWindow rootViewController]);
26 return main_view_controller.activeViewController; 29 return main_view_controller.activeViewController;
27 } 30 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // reports to upload. 76 // reports to upload.
74 - (void)testSafeModeSendingCrashReport { 77 - (void)testSafeModeSendingCrashReport {
75 // Mocks the +hasReportToUpload method by swizzling to return positively that 78 // Mocks the +hasReportToUpload method by swizzling to return positively that
76 // there are crash reports to upload. 79 // there are crash reports to upload.
77 ScopedBlockSwizzler hasReport([SafeModeViewController class], 80 ScopedBlockSwizzler hasReport([SafeModeViewController class],
78 @selector(hasReportToUpload), ^{ 81 @selector(hasReportToUpload), ^{
79 return YES; 82 return YES;
80 }); 83 });
81 84
82 // Instantiates a Safe Mode controller and displays it. 85 // Instantiates a Safe Mode controller and displays it.
83 base::scoped_nsobject<SafeModeViewController> safeModeController( 86 SafeModeViewController* safeModeController =
84 [[SafeModeViewController alloc] initWithDelegate:nil]); 87 [[SafeModeViewController alloc] initWithDelegate:nil];
85 [GetActiveViewController() presentViewController:safeModeController 88 [GetActiveViewController() presentViewController:safeModeController
86 animated:NO 89 animated:NO
87 completion:nil]; 90 completion:nil];
88 // Verifies screen content that shows that crash report is being uploaded. 91 // Verifies screen content that shows that crash report is being uploaded.
89 AssertMessageOnPage(NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @"")); 92 AssertMessageOnPage(NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @""));
90 AssertMessageOnPage( 93 AssertMessageOnPage(
91 NSLocalizedString(@"IDS_IOS_SAFE_MODE_UNKNOWN_CAUSE", @"")); 94 NSLocalizedString(@"IDS_IOS_SAFE_MODE_UNKNOWN_CAUSE", @""));
92 AssertTryAgainButtonOnPage(); 95 AssertTryAgainButtonOnPage();
93 AssertMessageOnPage( 96 AssertMessageOnPage(
94 NSLocalizedString(@"IDS_IOS_SAFE_MODE_SENDING_CRASH_REPORT", @"")); 97 NSLocalizedString(@"IDS_IOS_SAFE_MODE_SENDING_CRASH_REPORT", @""));
95 } 98 }
96 99
97 // Tests that Safe Mode screen is displayed with a message that there are 100 // Tests that Safe Mode screen is displayed with a message that there are
98 // jailbroken mods that caused a crash. Crash reports are not sent. 101 // jailbroken mods that caused a crash. Crash reports are not sent.
99 - (void)testSafeModeDetectedThirdPartyMods { 102 - (void)testSafeModeDetectedThirdPartyMods {
100 // Mocks the +detectedThirdPartyMods method by swizzling to return positively 103 // Mocks the +detectedThirdPartyMods method by swizzling to return positively
101 // that device appears to be jailbroken and contains third party mods. 104 // that device appears to be jailbroken and contains third party mods.
102 ScopedBlockSwizzler thirdParty([SafeModeViewController class], 105 ScopedBlockSwizzler thirdParty([SafeModeViewController class],
103 @selector(detectedThirdPartyMods), ^{ 106 @selector(detectedThirdPartyMods), ^{
104 return YES; 107 return YES;
105 }); 108 });
106 // Returns an empty list to simulate no known mods detected. 109 // Returns an empty list to simulate no known mods detected.
107 ScopedBlockSwizzler badModules([SafeModeViewController class], 110 ScopedBlockSwizzler badModules([SafeModeViewController class],
108 @selector(startupCrashModules), ^{ 111 @selector(startupCrashModules), ^{
109 return @[]; 112 return @[];
110 }); 113 });
111 114
112 // Instantiates a Safe Mode controller and displays it. 115 // Instantiates a Safe Mode controller and displays it.
113 base::scoped_nsobject<SafeModeViewController> safeModeController( 116 SafeModeViewController* safeModeController =
114 [[SafeModeViewController alloc] initWithDelegate:nil]); 117 [[SafeModeViewController alloc] initWithDelegate:nil];
115 [GetActiveViewController() presentViewController:safeModeController 118 [GetActiveViewController() presentViewController:safeModeController
116 animated:NO 119 animated:NO
117 completion:nil]; 120 completion:nil];
118 // Verifies screen content that does not show crash report being uploaded. 121 // Verifies screen content that does not show crash report being uploaded.
119 // When devices are jailbroken, the crash reports are not very useful. 122 // When devices are jailbroken, the crash reports are not very useful.
120 AssertMessageOnPage(NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @"")); 123 AssertMessageOnPage(NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @""));
121 AssertMessageOnPage( 124 AssertMessageOnPage(
122 NSLocalizedString(@"IDS_IOS_SAFE_MODE_TWEAKS_FOUND", @"")); 125 NSLocalizedString(@"IDS_IOS_SAFE_MODE_TWEAKS_FOUND", @""));
123 AssertTryAgainButtonOnPage(); 126 AssertTryAgainButtonOnPage();
124 AssertMessageNotOnPage( 127 AssertMessageNotOnPage(
(...skipping 14 matching lines...) Expand all
139 NSArray* badModulesList = @[ @"iAmBad", @"MJackson" ]; 142 NSArray* badModulesList = @[ @"iAmBad", @"MJackson" ];
140 ScopedBlockSwizzler badModules([SafeModeViewController class], 143 ScopedBlockSwizzler badModules([SafeModeViewController class],
141 @selector(startupCrashModules), ^{ 144 @selector(startupCrashModules), ^{
142 return badModulesList; 145 return badModulesList;
143 }); 146 });
144 ScopedBlockSwizzler hasReport([SafeModeViewController class], 147 ScopedBlockSwizzler hasReport([SafeModeViewController class],
145 @selector(hasReportToUpload), ^{ 148 @selector(hasReportToUpload), ^{
146 return YES; 149 return YES;
147 }); 150 });
148 // Instantiates a Safe Mode controller and displays it. 151 // Instantiates a Safe Mode controller and displays it.
149 base::scoped_nsobject<SafeModeViewController> safeModeController( 152 SafeModeViewController* safeModeController =
150 [[SafeModeViewController alloc] initWithDelegate:nil]); 153 [[SafeModeViewController alloc] initWithDelegate:nil];
151 [GetActiveViewController() presentViewController:safeModeController 154 [GetActiveViewController() presentViewController:safeModeController
152 animated:NO 155 animated:NO
153 completion:nil]; 156 completion:nil];
154 // Verifies screen content that does not show crash report being uploaded. 157 // Verifies screen content that does not show crash report being uploaded.
155 // When devices are jailbroken, the crash reports are not very useful. 158 // When devices are jailbroken, the crash reports are not very useful.
156 AssertMessageOnPage(NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @"")); 159 AssertMessageOnPage(NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @""));
157 // Constructs the list of bad mods based on |badModulesList| above. 160 // Constructs the list of bad mods based on |badModulesList| above.
158 NSString* message = 161 NSString* message =
159 [NSLocalizedString(@"IDS_IOS_SAFE_MODE_NAMED_TWEAKS_FOUND", @"") 162 [NSLocalizedString(@"IDS_IOS_SAFE_MODE_NAMED_TWEAKS_FOUND", @"")
160 stringByAppendingString:@"\n\n iAmBad\n MJackson"]; 163 stringByAppendingString:@"\n\n iAmBad\n MJackson"];
161 AssertMessageOnPage(message); 164 AssertMessageOnPage(message);
162 AssertTryAgainButtonOnPage(); 165 AssertTryAgainButtonOnPage();
163 AssertMessageNotOnPage( 166 AssertMessageNotOnPage(
164 NSLocalizedString(@"IDS_IOS_SAFE_MODE_SENDING_CRASH_REPORT", @"")); 167 NSLocalizedString(@"IDS_IOS_SAFE_MODE_SENDING_CRASH_REPORT", @""));
165 } 168 }
166 169
167 @end 170 @end
OLDNEW
« no previous file with comments | « ios/chrome/app/safe_mode/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698