From fe27a9dd60d2ef27eec20268523fa359ae91e0ca Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Thu, 13 Dec 2018 15:04:45 -0800 Subject: [PATCH 1/2] fix the unit test --- ...FIRMessagingRemoteNotificationsProxyTest.m | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m b/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m index 6c7fcecc010..3e67e0f6b66 100644 --- a/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m +++ b/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m @@ -161,32 +161,14 @@ - (void)testSwizzlingAppDelegate { XCTAssertTrue(self.proxy.didSwizzleAppDelegateMethods); } -- (void)testSwizzledIncompleteAppDelegateRemoteNotificationMethod { - IncompleteAppDelegate *incompleteAppDelegate = [[IncompleteAppDelegate alloc] init]; - [self.mockProxy swizzleAppDelegateMethods:incompleteAppDelegate]; -#ifdef BUG_1451 - SEL selector = @selector(application:didReceiveRemoteNotification:); - XCTAssertTrue([incompleteAppDelegate respondsToSelector:selector]); - [incompleteAppDelegate application:OCMClassMock([UIApplication class]) - didReceiveRemoteNotification:@{}]; - // Verify our swizzled method was called - OCMVerify(FCM_swizzle_appDidReceiveRemoteNotification); -#endif -} - -// If the remote notification with fetch handler is NOT implemented, we will force-implement -// the backup -application:didReceiveRemoteNotification: method - (void)testIncompleteAppDelegateRemoteNotificationWithFetchHandlerMethod { IncompleteAppDelegate *incompleteAppDelegate = [[IncompleteAppDelegate alloc] init]; [self.mockProxy swizzleAppDelegateMethods:incompleteAppDelegate]; SEL remoteNotificationWithFetchHandler = @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:); XCTAssertFalse([incompleteAppDelegate respondsToSelector:remoteNotificationWithFetchHandler]); - -#ifdef BUG_1451 SEL remoteNotification = @selector(application:didReceiveRemoteNotification:); - XCTAssertTrue([incompleteAppDelegate respondsToSelector:remoteNotification]); -#endif + XCTAssertFalse([incompleteAppDelegate respondsToSelector:remoteNotification]); } - (void)testSwizzledAppDelegateRemoteNotificationMethods { From 5a8a76eccdbc695c00c7c5147aa7d2f771dbfa6f Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Fri, 14 Dec 2018 15:57:01 -0800 Subject: [PATCH 2/2] revert the boolean value --- .../Tests/FIRMessagingRemoteNotificationsProxyTest.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m b/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m index 3e67e0f6b66..0e972798c12 100644 --- a/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m +++ b/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m @@ -161,6 +161,16 @@ - (void)testSwizzlingAppDelegate { XCTAssertTrue(self.proxy.didSwizzleAppDelegateMethods); } +- (void)testSwizzledIncompleteAppDelegateRemoteNotificationMethod { + IncompleteAppDelegate *incompleteAppDelegate = [[IncompleteAppDelegate alloc] init]; + [self.mockProxy swizzleAppDelegateMethods:incompleteAppDelegate]; + + [incompleteAppDelegate application:OCMClassMock([UIApplication class]) + didReceiveRemoteNotification:@{}]; + // Verify our swizzled method was called + OCMVerify(FCM_swizzle_appDidReceiveRemoteNotification); +} + - (void)testIncompleteAppDelegateRemoteNotificationWithFetchHandlerMethod { IncompleteAppDelegate *incompleteAppDelegate = [[IncompleteAppDelegate alloc] init]; [self.mockProxy swizzleAppDelegateMethods:incompleteAppDelegate]; @@ -168,7 +178,7 @@ - (void)testIncompleteAppDelegateRemoteNotificationWithFetchHandlerMethod { @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:); XCTAssertFalse([incompleteAppDelegate respondsToSelector:remoteNotificationWithFetchHandler]); SEL remoteNotification = @selector(application:didReceiveRemoteNotification:); - XCTAssertFalse([incompleteAppDelegate respondsToSelector:remoteNotification]); + XCTAssertTrue([incompleteAppDelegate respondsToSelector:remoteNotification]); } - (void)testSwizzledAppDelegateRemoteNotificationMethods {