@@ -79,6 +79,8 @@ - (BOOL)setUpWithLaunchOptions:(nullable NSDictionary *)launchOptions
79
79
urlScheme : (nullable NSString *)urlScheme
80
80
userDefaults : (nullable NSUserDefaults *)userDefaults ;
81
81
- (BOOL )canParseUniversalLinkURL : (nullable NSURL *)url ;
82
+ - (void )passRetrievedDynamicLinkToApplication : (NSURL *)url ;
83
+ - (BOOL )isOpenUrlMethodPresentInAppDelegate : (id <UIApplicationDelegate>)applicationDelegate ;
82
84
@end
83
85
84
86
@interface FakeShortLinkResolver : FIRDynamicLinkNetworking
@@ -1119,7 +1121,7 @@ - (void)test_retrievePendingDeepLinkShouldSetkFIRDLOpenURLKeyRegardlessOfFailure
1119
1121
apiKey: kAPIKey
1120
1122
urlScheme: nil
1121
1123
userDefaults: [NSUserDefaults standardUserDefaults ]];
1122
- FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *deleagte =
1124
+ FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *delegate =
1123
1125
(FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *)self.service ;
1124
1126
1125
1127
// Error Result to pass
@@ -1131,13 +1133,36 @@ - (void)test_retrievePendingDeepLinkShouldSetkFIRDLOpenURLKeyRegardlessOfFailure
1131
1133
1132
1134
FIRDLDefaultRetrievalProcessV2 *defaultRetrievalProcess = [FIRDLDefaultRetrievalProcessV2 alloc ];
1133
1135
1134
- [deleagte retrievalProcess: defaultRetrievalProcess completedWithResult: result];
1136
+ [delegate retrievalProcess: defaultRetrievalProcess completedWithResult: result];
1135
1137
1136
1138
NSString *kFIRDLOpenURLKey = @" com.google.appinvite.openURL" ;
1137
1139
XCTAssertEqual ([[NSUserDefaults standardUserDefaults ] boolForKey: kFIRDLOpenURLKey ], YES ,
1138
1140
@" kFIRDLOpenURL key should be set regardless of failures" );
1139
1141
}
1140
1142
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
+
1141
1166
#pragma mark - Self-diagnose tests
1142
1167
1143
1168
- (void )testSelfDiagnoseWithNilCompletion {
0 commit comments