Skip to content

Commit 5d984b0

Browse files
authored
Silences compiler warnings in the Auth test file from #207 . (#219)
1 parent 2a22a88 commit 5d984b0

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Example/Auth/Tests/FIRAuthAppDelegateProxyTests.m

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#import <XCTest/XCTest.h>
18+
#import <UIKit/UIKit.h>
1819

1920
#import <objc/runtime.h>
2021

@@ -161,6 +162,11 @@ @implementation FIRAuthAppDelegateProxyTests {
161162
@brief The fake URL for testing.
162163
*/
163164
NSURL *_url;
165+
166+
/** @var _isIOS9orLater
167+
@brief Whether the OS version is iOS 9 or later.
168+
*/
169+
BOOL _isIOS9orLater;
164170
}
165171

166172
- (void)setUp {
@@ -169,6 +175,7 @@ - (void)setUp {
169175
_deviceToken = [@"asdf" dataUsingEncoding:NSUTF8StringEncoding];
170176
_notification = @{ @"zxcv" : @1234 };
171177
_url = [NSURL URLWithString:@"https://abc.def/ghi"];
178+
_isIOS9orLater = [[[UIDevice currentDevice] systemVersion] doubleValue] >= 9.0;
172179
}
173180

174181
- (void)tearDown {
@@ -235,6 +242,10 @@ - (void)testDisabledByBundleEntry {
235242
imp_removeBlock(method_setImplementation(method, originalImplementation));
236243
}
237244

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+
238249
/** @fn testEmptyDelegateOneHandler
239250
@brief Tests that the proxy works against an empty @c UIApplicationDelegate for one handler.
240251
*/
@@ -254,7 +265,7 @@ - (void)testEmptyDelegateOneHandler {
254265
@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)]);
255266
XCTAssertFalse([delegate respondsToSelector:
256267
@selector(application:didReceiveRemoteNotification:)]);
257-
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
268+
if (_isIOS9orLater) {
258269
XCTAssertTrue([delegate respondsToSelector:@selector(application:openURL:options:)]);
259270
XCTAssertFalse([delegate respondsToSelector:
260271
@selector(application:openURL:sourceApplication:annotation:)]);
@@ -291,7 +302,7 @@ - (void)testEmptyDelegateOneHandler {
291302

292303
// Verify one of the `application:openURL:...` methods is handled.
293304
OCMExpect([mockHandler canHandleURL:_url]).andReturn(YES);
294-
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
305+
if (_isIOS9orLater) {
295306
// Verify `application:openURL:options:` is handled.
296307
XCTAssertTrue([delegate application:_mockApplication openURL:_url options:@{}]);
297308
} else {
@@ -317,7 +328,7 @@ - (void)testEmptyDelegateOneHandler {
317328
fetchCompletionHandler:^(UIBackgroundFetchResult result) {
318329
XCTFail(@"Should not call completion handler.");
319330
}];
320-
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
331+
if (_isIOS9orLater) {
321332
XCTAssertFalse([delegate application:_mockApplication openURL:_url options:@{}]);
322333
} else {
323334
XCTAssertFalse([delegate application:_mockApplication
@@ -338,7 +349,7 @@ - (void)testEmptyDelegateOneHandler {
338349
fetchCompletionHandler:^(UIBackgroundFetchResult result) {
339350
XCTFail(@"Should not call completion handler.");
340351
}];
341-
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
352+
if (_isIOS9orLater) {
342353
XCTAssertFalse([delegate application:_mockApplication openURL:_url options:@{}]);
343354
} else {
344355
XCTAssertFalse([delegate application:_mockApplication
@@ -498,7 +509,7 @@ - (void)testModernDelegateWithUnaffectedInstance {
498509
XCTAssertFalse([delegate respondsToSelector:
499510
@selector(application:didReceiveRemoteNotification:)]);
500511
XCTAssertTrue([delegate respondsToSelector:@selector(application:openURL:options:)]);
501-
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
512+
if (_isIOS9orLater) {
502513
XCTAssertFalse([delegate respondsToSelector:
503514
@selector(application:openURL:sourceApplication:annotation:)]);
504515
} else {
@@ -536,7 +547,7 @@ - (void)testModernDelegateWithUnaffectedInstance {
536547

537548
// Verify one of the `application:openURL:...` methods is handled.
538549
OCMExpect([mockHandler canHandleURL:_url]).andReturn(YES);
539-
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
550+
if (_isIOS9orLater) {
540551
// Verify `application:openURL:options:` is handled.
541552
XCTAssertTrue([delegate application:_mockApplication openURL:_url options:@{}]);
542553
} else {
@@ -671,6 +682,8 @@ - (void)testOtherLegacyDelegateHandleOpenURL {
671682
delegate.urlOpened = nil;
672683
}
673684

685+
#pragma clang diagnostic pop // ignored "-Wdeprecated-declarations"
686+
674687
@end
675688

676689
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)