15
15
*/
16
16
17
17
#import < XCTest/XCTest.h>
18
+ #import < UIKit/UIKit.h>
18
19
19
20
#import < objc/runtime.h>
20
21
@@ -161,6 +162,11 @@ @implementation FIRAuthAppDelegateProxyTests {
161
162
@brief The fake URL for testing.
162
163
*/
163
164
NSURL *_url;
165
+
166
+ /* * @var _isIOS9orLater
167
+ @brief Whether the OS version is iOS 9 or later.
168
+ */
169
+ BOOL _isIOS9orLater;
164
170
}
165
171
166
172
- (void )setUp {
@@ -169,6 +175,7 @@ - (void)setUp {
169
175
_deviceToken = [@" asdf" dataUsingEncoding: NSUTF8StringEncoding];
170
176
_notification = @{ @" zxcv" : @1234 };
171
177
_url = [NSURL URLWithString: @" https://abc.def/ghi" ];
178
+ _isIOS9orLater = [[[UIDevice currentDevice ] systemVersion ] doubleValue ] >= 9.0 ;
172
179
}
173
180
174
181
- (void )tearDown {
@@ -235,6 +242,10 @@ - (void)testDisabledByBundleEntry {
235
242
imp_removeBlock (method_setImplementation (method, originalImplementation));
236
243
}
237
244
245
+ // Deprecated methods are call intentionally in tests to verify behaviors on older iOS systems.
246
+ #pragma clang diagnostic push
247
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
248
+
238
249
/* * @fn testEmptyDelegateOneHandler
239
250
@brief Tests that the proxy works against an empty @c UIApplicationDelegate for one handler.
240
251
*/
@@ -254,7 +265,7 @@ - (void)testEmptyDelegateOneHandler {
254
265
@selector (application:didReceiveRemoteNotification:fetchCompletionHandler: )]);
255
266
XCTAssertFalse ([delegate respondsToSelector:
256
267
@selector (application:didReceiveRemoteNotification: )]);
257
- if (&UIApplicationOpenURLOptionsAnnotationKey ) { // iOS 9+
268
+ if (_isIOS9orLater ) {
258
269
XCTAssertTrue ([delegate respondsToSelector: @selector (application:openURL:options: )]);
259
270
XCTAssertFalse ([delegate respondsToSelector:
260
271
@selector (application:openURL:sourceApplication:annotation: )]);
@@ -291,7 +302,7 @@ - (void)testEmptyDelegateOneHandler {
291
302
292
303
// Verify one of the `application:openURL:...` methods is handled.
293
304
OCMExpect ([mockHandler canHandleURL: _url]).andReturn (YES );
294
- if (&UIApplicationOpenURLOptionsAnnotationKey ) { // iOS 9+
305
+ if (_isIOS9orLater ) {
295
306
// Verify `application:openURL:options:` is handled.
296
307
XCTAssertTrue ([delegate application: _mockApplication openURL: _url options: @{}]);
297
308
} else {
@@ -317,7 +328,7 @@ - (void)testEmptyDelegateOneHandler {
317
328
fetchCompletionHandler: ^(UIBackgroundFetchResult result) {
318
329
XCTFail (@" Should not call completion handler." );
319
330
}];
320
- if (&UIApplicationOpenURLOptionsAnnotationKey ) { // iOS 9+
331
+ if (_isIOS9orLater ) {
321
332
XCTAssertFalse ([delegate application: _mockApplication openURL: _url options: @{}]);
322
333
} else {
323
334
XCTAssertFalse ([delegate application: _mockApplication
@@ -338,7 +349,7 @@ - (void)testEmptyDelegateOneHandler {
338
349
fetchCompletionHandler: ^(UIBackgroundFetchResult result) {
339
350
XCTFail (@" Should not call completion handler." );
340
351
}];
341
- if (&UIApplicationOpenURLOptionsAnnotationKey ) { // iOS 9+
352
+ if (_isIOS9orLater ) {
342
353
XCTAssertFalse ([delegate application: _mockApplication openURL: _url options: @{}]);
343
354
} else {
344
355
XCTAssertFalse ([delegate application: _mockApplication
@@ -498,7 +509,7 @@ - (void)testModernDelegateWithUnaffectedInstance {
498
509
XCTAssertFalse ([delegate respondsToSelector:
499
510
@selector (application:didReceiveRemoteNotification: )]);
500
511
XCTAssertTrue ([delegate respondsToSelector: @selector (application:openURL:options: )]);
501
- if (&UIApplicationOpenURLOptionsAnnotationKey ) { // iOS 9+
512
+ if (_isIOS9orLater ) {
502
513
XCTAssertFalse ([delegate respondsToSelector:
503
514
@selector (application:openURL:sourceApplication:annotation: )]);
504
515
} else {
@@ -536,7 +547,7 @@ - (void)testModernDelegateWithUnaffectedInstance {
536
547
537
548
// Verify one of the `application:openURL:...` methods is handled.
538
549
OCMExpect ([mockHandler canHandleURL: _url]).andReturn (YES );
539
- if (&UIApplicationOpenURLOptionsAnnotationKey ) { // iOS 9+
550
+ if (_isIOS9orLater ) {
540
551
// Verify `application:openURL:options:` is handled.
541
552
XCTAssertTrue ([delegate application: _mockApplication openURL: _url options: @{}]);
542
553
} else {
@@ -671,6 +682,8 @@ - (void)testOtherLegacyDelegateHandleOpenURL {
671
682
delegate.urlOpened = nil ;
672
683
}
673
684
685
+ #pragma clang diagnostic pop // ignored "-Wdeprecated-declarations"
686
+
674
687
@end
675
688
676
689
NS_ASSUME_NONNULL_END
0 commit comments