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 16 matching lines...) Expand all Loading... |
27 // run in a row, this provides an indication of which one is currently running. | 27 // run in a row, this provides an indication of which one is currently running. |
28 | 28 |
29 static base::TestSuite* g_test_suite = NULL; | 29 static base::TestSuite* g_test_suite = NULL; |
30 static int g_argc; | 30 static int g_argc; |
31 static char** g_argv; | 31 static char** g_argv; |
32 | 32 |
33 @interface UIApplication (Testing) | 33 @interface UIApplication (Testing) |
34 - (void) _terminateWithStatus:(int)status; | 34 - (void) _terminateWithStatus:(int)status; |
35 @end | 35 @end |
36 | 36 |
| 37 #ifdef TARGET_IPHONE_SIMULATOR |
| 38 // Xcode 6 introduced behavior in the iOS Simulator where the software |
| 39 // keyboard does not appear if a hardware keyboard is connected. The following |
| 40 // declaration allows this behavior to be overriden when the app starts up. |
| 41 @interface UIKeyboardImpl |
| 42 + (instancetype)sharedInstance; |
| 43 - (void)setAutomaticMinimizationEnabled:(BOOL)enabled; |
| 44 - (void)setSoftwareKeyboardShownByTouch:(BOOL)enabled; |
| 45 @end |
| 46 #endif // TARGET_IPHONE_SIMULATOR |
| 47 |
37 @interface ChromeUnitTestDelegate : NSObject { | 48 @interface ChromeUnitTestDelegate : NSObject { |
38 @private | 49 @private |
39 base::scoped_nsobject<UIWindow> window_; | 50 base::scoped_nsobject<UIWindow> window_; |
40 } | 51 } |
41 - (void)runTests; | 52 - (void)runTests; |
42 @end | 53 @end |
43 | 54 |
44 @implementation ChromeUnitTestDelegate | 55 @implementation ChromeUnitTestDelegate |
45 | 56 |
46 - (BOOL)application:(UIApplication *)application | 57 - (BOOL)application:(UIApplication *)application |
47 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | 58 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { |
48 | 59 |
| 60 #ifdef TARGET_IPHONE_SIMULATOR |
| 61 // Xcode 6 introduced behavior in the iOS Simulator where the software |
| 62 // keyboard does not appear if a hardware keyboard is connected. The following |
| 63 // calls override this behavior by ensuring that the software keyboard is |
| 64 // always shown. |
| 65 [[UIKeyboardImpl sharedInstance] setAutomaticMinimizationEnabled:NO]; |
| 66 [[UIKeyboardImpl sharedInstance] setSoftwareKeyboardShownByTouch:YES]; |
| 67 #endif // TARGET_IPHONE_SIMULATOR |
| 68 |
49 CGRect bounds = [[UIScreen mainScreen] bounds]; | 69 CGRect bounds = [[UIScreen mainScreen] bounds]; |
50 | 70 |
51 // Yes, this is leaked, it's just to make what's running visible. | 71 // Yes, this is leaked, it's just to make what's running visible. |
52 window_.reset([[UIWindow alloc] initWithFrame:bounds]); | 72 window_.reset([[UIWindow alloc] initWithFrame:bounds]); |
53 [window_ makeKeyAndVisible]; | 73 [window_ makeKeyAndVisible]; |
54 | 74 |
55 // Add a label with the app name. | 75 // Add a label with the app name. |
56 UILabel* label = [[[UILabel alloc] initWithFrame:bounds] autorelease]; | 76 UILabel* label = [[[UILabel alloc] initWithFrame:bounds] autorelease]; |
57 label.text = [[NSProcessInfo processInfo] processName]; | 77 label.text = [[NSProcessInfo processInfo] processName]; |
58 label.textAlignment = NSTextAlignmentCenter; | 78 label.textAlignment = NSTextAlignmentCenter; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if (!ran_hook) { | 203 if (!ran_hook) { |
184 ran_hook = true; | 204 ran_hook = true; |
185 mac::ScopedNSAutoreleasePool pool; | 205 mac::ScopedNSAutoreleasePool pool; |
186 int exit_status = UIApplicationMain(g_argc, g_argv, nil, | 206 int exit_status = UIApplicationMain(g_argc, g_argv, nil, |
187 @"ChromeUnitTestDelegate"); | 207 @"ChromeUnitTestDelegate"); |
188 exit(exit_status); | 208 exit(exit_status); |
189 } | 209 } |
190 } | 210 } |
191 | 211 |
192 } // namespace base | 212 } // namespace base |
OLD | NEW |