|
|
@@ -79,6 +79,8 @@ typedef NSURL * (^FakeShortLinkResolverHandler)(NSURL *shortLink);
|
|
|
urlScheme:(nullable NSString *)urlScheme
|
|
|
userDefaults:(nullable NSUserDefaults *)userDefaults;
|
|
|
- (BOOL)canParseUniversalLinkURL:(nullable NSURL *)url;
|
|
|
+- (void)passRetrievedDynamicLinkToApplication:(NSURL *)url;
|
|
|
+- (BOOL)isOpenUrlMethodPresentInAppDelegate:(id<UIApplicationDelegate>)applicationDelegate;
|
|
|
@end
|
|
|
|
|
|
@interface FakeShortLinkResolver : FIRDynamicLinkNetworking
|
|
|
@@ -1119,7 +1121,7 @@ static NSString *const kInfoPlistCustomDomainsKey = @"FirebaseDynamicLinksCustom
|
|
|
apiKey:kAPIKey
|
|
|
urlScheme:nil
|
|
|
userDefaults:[NSUserDefaults standardUserDefaults]];
|
|
|
- FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *deleagte =
|
|
|
+ FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *delegate =
|
|
|
(FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *)self.service;
|
|
|
|
|
|
// Error Result to pass
|
|
|
@@ -1131,13 +1133,36 @@ static NSString *const kInfoPlistCustomDomainsKey = @"FirebaseDynamicLinksCustom
|
|
|
|
|
|
FIRDLDefaultRetrievalProcessV2 *defaultRetrievalProcess = [FIRDLDefaultRetrievalProcessV2 alloc];
|
|
|
|
|
|
- [deleagte retrievalProcess:defaultRetrievalProcess completedWithResult:result];
|
|
|
+ [delegate retrievalProcess:defaultRetrievalProcess completedWithResult:result];
|
|
|
|
|
|
NSString *kFIRDLOpenURLKey = @"com.google.appinvite.openURL";
|
|
|
XCTAssertEqual([[NSUserDefaults standardUserDefaults] boolForKey:kFIRDLOpenURLKey], YES,
|
|
|
@"kFIRDLOpenURL key should be set regardless of failures");
|
|
|
}
|
|
|
|
|
|
+- (void)test_passRetrievedDynamicLinkToApplicationDelegatesProperly {
|
|
|
+ // Creating ApplicationDelegate partial mock object.
|
|
|
+ id applicationDelegate = OCMPartialMock([UIApplication sharedApplication].delegate);
|
|
|
+ // Creating FIRDynamicLinks partial mock object.
|
|
|
+ id firebaseDynamicLinks = OCMPartialMock(self.service);
|
|
|
+ // Stubbing Application delegate to return YES when application:openURL:options method is called.
|
|
|
+ // Not sure why this is required as we are not concerned about its return, but without this, the
|
|
|
+ // test will throw NSInvalidArgumentException with message "unrecognized selector sent to
|
|
|
+ // instance".
|
|
|
+ OCMStub([applicationDelegate application:[OCMArg any] openURL:[OCMArg any] options:[OCMArg any]])
|
|
|
+ .andReturn(YES);
|
|
|
+ // Stubbing firebase dynamiclinks instance to return YES when isOpenUrlMethodPresentInAppDelegate
|
|
|
+ // is called.
|
|
|
+ OCMStub([firebaseDynamicLinks isOpenUrlMethodPresentInAppDelegate:[OCMArg any]]).andReturn(YES);
|
|
|
+
|
|
|
+ // Executing the function with a URL.
|
|
|
+ NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
|
|
|
+ [firebaseDynamicLinks passRetrievedDynamicLinkToApplication:url];
|
|
|
+
|
|
|
+ // Verifying the application:openURL:options method is called in AppDelegate.
|
|
|
+ OCMVerify([applicationDelegate application:[OCMArg any] openURL:url options:[OCMArg any]]);
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Self-diagnose tests
|
|
|
|
|
|
- (void)testSelfDiagnoseWithNilCompletion {
|