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

Side by Side Diff: base/test/test_support_ios.mm

Issue 2231813002: Revert of Adds support for running unittests using XCTest on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « base/test/test_support_ios.h ('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 (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 #include "base/test/test_support_ios.h"
6
7 #import <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
8 6
9 #include "base/debug/debugger.h" 7 #include "base/debug/debugger.h"
10 #include "base/logging.h" 8 #include "base/logging.h"
11 #include "base/mac/scoped_nsautorelease_pool.h" 9 #include "base/mac/scoped_nsautorelease_pool.h"
12 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
13 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
14 #include "base/message_loop/message_pump_default.h" 12 #include "base/message_loop/message_pump_default.h"
15 #include "base/test/test_suite.h" 13 #include "base/test/test_suite.h"
16 #include "testing/coverage_util_ios.h" 14 #include "testing/coverage_util_ios.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 NSLog(@"Writing contents of %@ to NSLog", path); 148 NSLog(@"Writing contents of %@ to NSLog", path);
151 for (NSString* line in lines) { 149 for (NSString* line in lines) {
152 NSLog(@"%@", line); 150 NSLog(@"%@", line);
153 } 151 }
154 } 152 }
155 } 153 }
156 154
157 - (void)runTests { 155 - (void)runTests {
158 int exitStatus = g_test_suite->Run(); 156 int exitStatus = g_test_suite->Run();
159 157
160 if (base::IsRunningWithXCTest()) {
161 // Do not kill the app when running in XCTest mode. XCTest will shut down
162 // the app itself.
163 return;
164 }
165
166 if ([self shouldRedirectOutputToFile]) 158 if ([self shouldRedirectOutputToFile])
167 [self writeOutputToNSLog]; 159 [self writeOutputToNSLog];
168 160
169 // If a test app is too fast, it will exit before Instruments has has a 161 // If a test app is too fast, it will exit before Instruments has has a
170 // a chance to initialize and no test results will be seen. 162 // a chance to initialize and no test results will be seen.
171 // TODO(crbug.com/137010): Figure out how much time is actually needed, and 163 // TODO(crbug.com/137010): Figure out how much time is actually needed, and
172 // sleep only to make sure that much time has elapsed since launch. 164 // sleep only to make sure that much time has elapsed since launch.
173 [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]]; 165 [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
174 window_.reset(); 166 window_.reset();
175 167
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 static bool ran_hook = false; 210 static bool ran_hook = false;
219 if (!ran_hook) { 211 if (!ran_hook) {
220 ran_hook = true; 212 ran_hook = true;
221 mac::ScopedNSAutoreleasePool pool; 213 mac::ScopedNSAutoreleasePool pool;
222 int exit_status = UIApplicationMain(g_argc, g_argv, nil, 214 int exit_status = UIApplicationMain(g_argc, g_argv, nil,
223 @"ChromeUnitTestDelegate"); 215 @"ChromeUnitTestDelegate");
224 exit(exit_status); 216 exit(exit_status);
225 } 217 }
226 } 218 }
227 219
228 bool IsRunningWithXCTest() {
229 // Under Xcode 7.3 and 8.0, the "XCTestConfigurationFilePath" environment
230 // variable is set when running XCTests.
231 return getenv("XCTestConfigurationFilePath") != nullptr;
232 }
233
234 } // namespace base 220 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_support_ios.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698