@@ -79,6 +79,8 @@ - (BOOL)setUpWithLaunchOptions:(nullable NSDictionary *)launchOptions
7979 urlScheme : (nullable NSString *)urlScheme
8080 userDefaults : (nullable NSUserDefaults *)userDefaults ;
8181- (BOOL )canParseUniversalLinkURL : (nullable NSURL *)url ;
82+ - (void )passRetrievedDynamicLinkToApplication : (NSURL *)url ;
83+ - (BOOL )isOpenUrlMethodPresentInAppDelegate : (id <UIApplicationDelegate>)applicationDelegate ;
8284@end
8385
8486@interface FakeShortLinkResolver : FIRDynamicLinkNetworking
@@ -1119,7 +1121,7 @@ - (void)test_retrievePendingDeepLinkShouldSetkFIRDLOpenURLKeyRegardlessOfFailure
11191121 apiKey: kAPIKey
11201122 urlScheme: nil
11211123 userDefaults: [NSUserDefaults standardUserDefaults ]];
1122- FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *deleagte =
1124+ FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *delegate =
11231125 (FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *)self.service ;
11241126
11251127 // Error Result to pass
@@ -1131,13 +1133,36 @@ - (void)test_retrievePendingDeepLinkShouldSetkFIRDLOpenURLKeyRegardlessOfFailure
11311133
11321134 FIRDLDefaultRetrievalProcessV2 *defaultRetrievalProcess = [FIRDLDefaultRetrievalProcessV2 alloc ];
11331135
1134- [deleagte retrievalProcess: defaultRetrievalProcess completedWithResult: result];
1136+ [delegate retrievalProcess: defaultRetrievalProcess completedWithResult: result];
11351137
11361138 NSString *kFIRDLOpenURLKey = @" com.google.appinvite.openURL" ;
11371139 XCTAssertEqual ([[NSUserDefaults standardUserDefaults ] boolForKey: kFIRDLOpenURLKey ], YES ,
11381140 @" kFIRDLOpenURL key should be set regardless of failures" );
11391141}
11401142
1143+ - (void )test_passRetrievedDynamicLinkToApplicationDelegatesProperly {
1144+ // Creating ApplicationDelegate partial mock object.
1145+ id applicationDelegate = OCMPartialMock ([UIApplication sharedApplication ].delegate );
1146+ // Creating FIRDynamicLinks partial mock object.
1147+ id firebaseDynamicLinks = OCMPartialMock (self.service );
1148+ // Stubbing Application delegate to return YES when application:openURL:options method is called.
1149+ // Not sure why this is required as we are not concerned about its return, but without this, the
1150+ // test will throw NSInvalidArgumentException with message "unrecognized selector sent to
1151+ // instance".
1152+ OCMStub ([applicationDelegate application: [OCMArg any ] openURL: [OCMArg any ] options: [OCMArg any ]])
1153+ .andReturn (YES );
1154+ // Stubbing firebase dynamiclinks instance to return YES when isOpenUrlMethodPresentInAppDelegate
1155+ // is called.
1156+ OCMStub ([firebaseDynamicLinks isOpenUrlMethodPresentInAppDelegate: [OCMArg any ]]).andReturn (YES );
1157+
1158+ // Executing the function with a URL.
1159+ NSURL *url = [NSURL URLWithString: @" http://www.google.com" ];
1160+ [firebaseDynamicLinks passRetrievedDynamicLinkToApplication: url];
1161+
1162+ // Verifying the application:openURL:options method is called in AppDelegate.
1163+ OCMVerify ([applicationDelegate application: [OCMArg any ] openURL: url options: [OCMArg any ]]);
1164+ }
1165+
11411166#pragma mark - Self-diagnose tests
11421167
11431168- (void )testSelfDiagnoseWithNilCompletion {
0 commit comments