OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 @implementation TestRunner | 29 @implementation TestRunner |
30 - (id)init { | 30 - (id)init { |
31 self = [super init]; | 31 self = [super init]; |
32 if (self) { | 32 if (self) { |
33 running_ = YES; | 33 running_ = YES; |
34 } | 34 } |
35 return self; | 35 return self; |
36 } | 36 } |
37 | 37 |
38 - (void)runAllTests:(TestBlock)testBlock { | 38 - (void)runAllTests:(TestBlock)testBlock { |
39 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | 39 @autoreleasepool { |
40 testBlock(); | 40 testBlock(); |
41 running_ = NO; | 41 running_ = NO; |
42 [pool release]; | 42 } |
43 } | 43 } |
44 | 44 |
45 - (BOOL)running { | 45 - (BOOL)running { |
46 return running_; | 46 return running_; |
47 } | 47 } |
48 @end | 48 @end |
49 | 49 |
50 namespace webrtc { | 50 namespace webrtc { |
51 namespace test { | 51 namespace test { |
52 | 52 |
53 void RunTest(void(*test)()) { | 53 void RunTest(void(*test)()) { |
54 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | 54 @autoreleasepool { |
55 [NSApplication sharedApplication]; | 55 [NSApplication sharedApplication]; |
56 | 56 |
57 // Convert the function pointer to an Objective-C block and call on a | 57 // Convert the function pointer to an Objective-C block and call on a |
58 // separate thread, to avoid blocking the main thread. | 58 // separate thread, to avoid blocking the main thread. |
59 TestRunner *testRunner = [[TestRunner alloc] init]; | 59 TestRunner *testRunner = [[TestRunner alloc] init]; |
60 TestBlock testBlock = functionToBlock(test); | 60 TestBlock testBlock = functionToBlock(test); |
61 [NSThread detachNewThreadSelector:@selector(runAllTests:) | 61 [NSThread detachNewThreadSelector:@selector(runAllTests:) |
62 toTarget:testRunner | 62 toTarget:testRunner |
63 withObject:testBlock]; | 63 withObject:testBlock]; |
64 | 64 |
65 NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; | 65 NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; |
66 while ([testRunner running] && | 66 while ([testRunner running] && [runLoop runMode:NSDefaultRunLoopMode |
67 [runLoop runMode:NSDefaultRunLoopMode | 67 beforeDate:[NSDate dateWithTimeInterval
SinceNow:0.1]]) |
68 beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]); | 68 ; |
69 | 69 } |
70 [testRunner release]; | |
71 [pool release]; | |
72 } | 70 } |
73 | 71 |
74 } // namespace test | 72 } // namespace test |
75 } // namespace webrtc | 73 } // namespace webrtc |
OLD | NEW |