OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2017 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 |
11 #import <UIKit/UIKit.h> | 11 #import <UIKit/UIKit.h> |
12 | 12 |
13 #include "webrtc/test/ios/test_support.h" | 13 #include "webrtc/test/ios/test_support.h" |
14 | 14 |
15 #import "webrtc/sdk/objc/Framework/Classes/Common/RTCUIApplicationStatusObserver .h" | |
16 | |
15 // Springboard will kill any iOS app that fails to check in after launch within | 17 // Springboard will kill any iOS app that fails to check in after launch within |
16 // a given time. Starting a UIApplication before invoking TestSuite::Run | 18 // a given time. Starting a UIApplication before invoking TestSuite::Run |
17 // prevents this from happening. | 19 // prevents this from happening. |
18 | 20 |
19 // InitIOSRunHook saves the TestSuite and argc/argv, then invoking | 21 // InitIOSRunHook saves the TestSuite and argc/argv, then invoking |
20 // RunTestsFromIOSApp calls UIApplicationMain(), providing an application | 22 // RunTestsFromIOSApp calls UIApplicationMain(), providing an application |
21 // delegate class: WebRtcUnitTestDelegate. The delegate implements | 23 // delegate class: WebRtcUnitTestDelegate. The delegate implements |
22 // application:didFinishLaunchingWithOptions: to invoke the TestSuite's Run | 24 // application:didFinishLaunchingWithOptions: to invoke the TestSuite's Run |
23 // method. | 25 // method. |
24 | 26 |
(...skipping 28 matching lines...) Expand all Loading... | |
53 // Add a label with the app name. | 55 // Add a label with the app name. |
54 UILabel *label = [[UILabel alloc] initWithFrame:bounds]; | 56 UILabel *label = [[UILabel alloc] initWithFrame:bounds]; |
55 label.text = [[NSProcessInfo processInfo] processName]; | 57 label.text = [[NSProcessInfo processInfo] processName]; |
56 label.textAlignment = NSTextAlignmentCenter; | 58 label.textAlignment = NSTextAlignmentCenter; |
57 [_window addSubview:label]; | 59 [_window addSubview:label]; |
58 | 60 |
59 // An NSInternalInconsistencyException is thrown if the app doesn't have a | 61 // An NSInternalInconsistencyException is thrown if the app doesn't have a |
60 // root view controller. Set an empty one here. | 62 // root view controller. Set an empty one here. |
61 [_window setRootViewController:[[UIViewController alloc] init]]; | 63 [_window setRootViewController:[[UIViewController alloc] init]]; |
62 | 64 |
65 // We want to call `RTCUIApplicationStatusObserver sharedInstance` as erly as | |
andersc
2017/09/08 14:35:17
typo: erly
| |
66 // possible in the application lifecycle to set observation properly. | |
67 __unused RTCUIAplicationStatusObserver *observer = | |
68 [RTCUIApplicationStatusObserver sharedInstance]; | |
69 | |
63 // Queue up the test run. | 70 // Queue up the test run. |
64 [self performSelector:@selector(runTests) withObject:nil afterDelay:0.1]; | 71 [self performSelector:@selector(runTests) withObject:nil afterDelay:0.1]; |
65 return YES; | 72 return YES; |
66 } | 73 } |
67 | 74 |
68 - (void)runTests { | 75 - (void)runTests { |
69 int exitStatus = g_test_suite(); | 76 int exitStatus = g_test_suite(); |
70 | 77 |
71 // If a test app is too fast, it will exit before Instruments has has a | 78 // If a test app is too fast, it will exit before Instruments has has a |
72 // a chance to initialize and no test results will be seen. | 79 // a chance to initialize and no test results will be seen. |
(...skipping 19 matching lines...) Expand all Loading... | |
92 g_argv = argv; | 99 g_argv = argv; |
93 } | 100 } |
94 | 101 |
95 void RunTestsFromIOSApp() { | 102 void RunTestsFromIOSApp() { |
96 @autoreleasepool { | 103 @autoreleasepool { |
97 exit(UIApplicationMain(g_argc, g_argv, nil, @"WebRtcUnitTestDelegate")); | 104 exit(UIApplicationMain(g_argc, g_argv, nil, @"WebRtcUnitTestDelegate")); |
98 } | 105 } |
99 } | 106 } |
100 } // namespace test | 107 } // namespace test |
101 } // namespace rtc | 108 } // namespace rtc |
OLD | NEW |