Skip to content

Silences compiler warnings in the test file from #207 . #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions Example/Auth/Tests/FIRAuthAppDelegateProxyTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#import <XCTest/XCTest.h>
#import <UIKit/UIKit.h>

#import <objc/runtime.h>

Expand Down Expand Up @@ -161,6 +162,11 @@ @implementation FIRAuthAppDelegateProxyTests {
@brief The fake URL for testing.
*/
NSURL *_url;

/** @var _isIOS9orLater
@brief Whether the OS version is iOS 9 or later.
*/
BOOL _isIOS9orLater;
}

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

- (void)tearDown {
Expand Down Expand Up @@ -235,6 +242,10 @@ - (void)testDisabledByBundleEntry {
imp_removeBlock(method_setImplementation(method, originalImplementation));
}

// Deprecated methods are call intentionally in tests to verify behaviors on older iOS systems.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

/** @fn testEmptyDelegateOneHandler
@brief Tests that the proxy works against an empty @c UIApplicationDelegate for one handler.
*/
Expand All @@ -254,7 +265,7 @@ - (void)testEmptyDelegateOneHandler {
@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)]);
XCTAssertFalse([delegate respondsToSelector:
@selector(application:didReceiveRemoteNotification:)]);
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
if (_isIOS9orLater) {
XCTAssertTrue([delegate respondsToSelector:@selector(application:openURL:options:)]);
XCTAssertFalse([delegate respondsToSelector:
@selector(application:openURL:sourceApplication:annotation:)]);
Expand Down Expand Up @@ -291,7 +302,7 @@ - (void)testEmptyDelegateOneHandler {

// Verify one of the `application:openURL:...` methods is handled.
OCMExpect([mockHandler canHandleURL:_url]).andReturn(YES);
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
if (_isIOS9orLater) {
// Verify `application:openURL:options:` is handled.
XCTAssertTrue([delegate application:_mockApplication openURL:_url options:@{}]);
} else {
Expand All @@ -317,7 +328,7 @@ - (void)testEmptyDelegateOneHandler {
fetchCompletionHandler:^(UIBackgroundFetchResult result) {
XCTFail(@"Should not call completion handler.");
}];
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
if (_isIOS9orLater) {
XCTAssertFalse([delegate application:_mockApplication openURL:_url options:@{}]);
} else {
XCTAssertFalse([delegate application:_mockApplication
Expand All @@ -338,7 +349,7 @@ - (void)testEmptyDelegateOneHandler {
fetchCompletionHandler:^(UIBackgroundFetchResult result) {
XCTFail(@"Should not call completion handler.");
}];
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
if (_isIOS9orLater) {
XCTAssertFalse([delegate application:_mockApplication openURL:_url options:@{}]);
} else {
XCTAssertFalse([delegate application:_mockApplication
Expand Down Expand Up @@ -498,7 +509,7 @@ - (void)testModernDelegateWithUnaffectedInstance {
XCTAssertFalse([delegate respondsToSelector:
@selector(application:didReceiveRemoteNotification:)]);
XCTAssertTrue([delegate respondsToSelector:@selector(application:openURL:options:)]);
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
if (_isIOS9orLater) {
XCTAssertFalse([delegate respondsToSelector:
@selector(application:openURL:sourceApplication:annotation:)]);
} else {
Expand Down Expand Up @@ -536,7 +547,7 @@ - (void)testModernDelegateWithUnaffectedInstance {

// Verify one of the `application:openURL:...` methods is handled.
OCMExpect([mockHandler canHandleURL:_url]).andReturn(YES);
if (&UIApplicationOpenURLOptionsAnnotationKey) { // iOS 9+
if (_isIOS9orLater) {
// Verify `application:openURL:options:` is handled.
XCTAssertTrue([delegate application:_mockApplication openURL:_url options:@{}]);
} else {
Expand Down Expand Up @@ -671,6 +682,8 @@ - (void)testOtherLegacyDelegateHandleOpenURL {
delegate.urlOpened = nil;
}

#pragma clang diagnostic pop // ignored "-Wdeprecated-declarations"

@end

NS_ASSUME_NONNULL_END