| OLD | NEW |
| 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 #import <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 | 6 |
| 7 #include "base/debug/debugger.h" | 7 #include "base/debug/debugger.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/scoped_nsautorelease_pool.h" | 9 #include "base/mac/scoped_nsautorelease_pool.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 [NSCharacterSet newlineCharacterSet]]; | 145 [NSCharacterSet newlineCharacterSet]]; |
| 146 | 146 |
| 147 NSLog(@"Writing contents of %@ to NSLog", path); | 147 NSLog(@"Writing contents of %@ to NSLog", path); |
| 148 for (NSString* line in lines) { | 148 for (NSString* line in lines) { |
| 149 NSLog(@"%@", line); | 149 NSLog(@"%@", line); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 - (void)runTests { | 154 - (void)runTests { |
| 155 coverage_util::SetupIfNecessary(); |
| 156 |
| 155 int exitStatus = g_test_suite->Run(); | 157 int exitStatus = g_test_suite->Run(); |
| 156 | 158 |
| 157 if ([self shouldRedirectOutputToFile]) | 159 if ([self shouldRedirectOutputToFile]) |
| 158 [self writeOutputToNSLog]; | 160 [self writeOutputToNSLog]; |
| 159 | 161 |
| 160 // If a test app is too fast, it will exit before Instruments has has a | 162 // If a test app is too fast, it will exit before Instruments has has a |
| 161 // a chance to initialize and no test results will be seen. | 163 // a chance to initialize and no test results will be seen. |
| 162 // TODO(crbug.com/137010): Figure out how much time is actually needed, and | 164 // TODO(crbug.com/137010): Figure out how much time is actually needed, and |
| 163 // sleep only to make sure that much time has elapsed since launch. | 165 // sleep only to make sure that much time has elapsed since launch. |
| 164 [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]]; | 166 [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]]; |
| 165 _window.reset(); | 167 _window.reset(); |
| 166 | 168 |
| 167 // Use the hidden selector to try and cleanly take down the app (otherwise | 169 // Use the hidden selector to try and cleanly take down the app (otherwise |
| 168 // things can think the app crashed even on a zero exit status). | 170 // things can think the app crashed even on a zero exit status). |
| 169 UIApplication* application = [UIApplication sharedApplication]; | 171 UIApplication* application = [UIApplication sharedApplication]; |
| 170 [application _terminateWithStatus:exitStatus]; | 172 [application _terminateWithStatus:exitStatus]; |
| 171 | 173 |
| 172 coverage_util::FlushCoverageDataIfNecessary(); | |
| 173 | |
| 174 exit(exitStatus); | 174 exit(exitStatus); |
| 175 } | 175 } |
| 176 | 176 |
| 177 @end | 177 @end |
| 178 | 178 |
| 179 namespace { | 179 namespace { |
| 180 | 180 |
| 181 std::unique_ptr<base::MessagePump> CreateMessagePumpForUIForTests() { | 181 std::unique_ptr<base::MessagePump> CreateMessagePumpForUIForTests() { |
| 182 // A default MessagePump will do quite nicely in tests. | 182 // A default MessagePump will do quite nicely in tests. |
| 183 return std::unique_ptr<base::MessagePump>(new base::MessagePumpDefault()); | 183 return std::unique_ptr<base::MessagePump>(new base::MessagePumpDefault()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 210 if (!ran_hook) { | 210 if (!ran_hook) { |
| 211 ran_hook = true; | 211 ran_hook = true; |
| 212 mac::ScopedNSAutoreleasePool pool; | 212 mac::ScopedNSAutoreleasePool pool; |
| 213 int exit_status = UIApplicationMain(g_argc, g_argv, nil, | 213 int exit_status = UIApplicationMain(g_argc, g_argv, nil, |
| 214 @"ChromeUnitTestDelegate"); | 214 @"ChromeUnitTestDelegate"); |
| 215 exit(exit_status); | 215 exit(exit_status); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace base | 219 } // namespace base |
| OLD | NEW |