From 6f298d01577a94790d8a73f23ee3c448a8f2bb39 Mon Sep 17 00:00:00 2001 From: nidhi18apr Date: Tue, 6 Oct 2020 00:06:59 -0700 Subject: [PATCH] DK-1067 - Added test case BranchUserTrackingDisabled --- Branch.xcodeproj/project.pbxproj | 4 ++ BranchTests/BranchUserTrackingDisabled.m | 57 +++++++++++++++++++ .../TestBed-macOS.xcodeproj/project.pbxproj | 2 + 3 files changed, 63 insertions(+) create mode 100644 BranchTests/BranchUserTrackingDisabled.m diff --git a/Branch.xcodeproj/project.pbxproj b/Branch.xcodeproj/project.pbxproj index fea5e6b..c62fcf9 100644 --- a/Branch.xcodeproj/project.pbxproj +++ b/Branch.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 035E033D252BD1A80015E37C /* BranchUserTrackingDisabled.m in Sources */ = {isa = PBXBuildFile; fileRef = 035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */; }; 2B073C1020C97F44005D16D2 /* BNCURLBlackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */; }; 2B073C1120C97F44005D16D2 /* BNCURLBlackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */; }; 2B0B035520CA50FF0008938F /* BNCURLBlackList.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B073C0C20C97F43005D16D2 /* BNCURLBlackList.m */; }; @@ -221,6 +222,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchUserTrackingDisabled.m; sourceTree = ""; }; 2B073C0C20C97F43005D16D2 /* BNCURLBlackList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCURLBlackList.m; sourceTree = ""; }; 2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCURLBlackList.h; sourceTree = ""; }; 4D046E8A20C881470073262B /* BranchNetworkServiceProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchNetworkServiceProtocol.h; sourceTree = ""; }; @@ -500,6 +502,7 @@ 4D0B753D211209FA00A06D97 /* BranchTestHost-tvOS.xcconfig */, 4DF8189D20ADDCB500441881 /* BranchTests-Bridging-Header.h */, 4DF818A020ADDCB600441881 /* BranchUniversalObject.Test.m */, + 035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */, 4D54C08520A6560400C76496 /* Info.plist */, 4D046E9620C8B5B20073262B /* NSData+Branch.Test.m */, 4D99773520AA09B300A63EE1 /* NSString+Branch.Test.m */, @@ -830,6 +833,7 @@ 4D159DDE20B62DD5005A9850 /* BNCPersistence.Test.m in Sources */, 4D046E9A20C8CE740073262B /* BNCTestNetworkService.Test.m in Sources */, 4D159DE320B62DD5005A9850 /* BNCThreads.Test.m in Sources */, + 035E033D252BD1A80015E37C /* BranchUserTrackingDisabled.m in Sources */, 4D046E9720C8B5B20073262B /* NSData+Branch.Test.m in Sources */, 4D159DE020B62DD5005A9850 /* BNCTestCase.m in Sources */, 4D159DEA20B62DD5005A9850 /* NSString+Branch.Test.m in Sources */, diff --git a/BranchTests/BranchUserTrackingDisabled.m b/BranchTests/BranchUserTrackingDisabled.m new file mode 100644 index 0000000..bc8446c --- /dev/null +++ b/BranchTests/BranchUserTrackingDisabled.m @@ -0,0 +1,57 @@ +// +/** + @file BranchUserTrackingDisabled.m + @package BranchTests + @brief Tests creation of short link when tracking is disabled. + + @author Nidhi Dixit + @date 2020 + @copyright Copyright © 2020 Branch. All rights reserved. +*/ + +#import +#import "BNCTestCase.h" +#import "BranchError.h" +#import "BNCLog.h" + +@interface BranchUserTrackingDisabled : XCTestCase +@property (strong) Branch *branch; +@end + +@implementation BranchUserTrackingDisabled + +- (void)setUp { + if (!self.branch) { + self.branch = [[Branch alloc] init]; + [self.branch startWithConfiguration:[[BranchConfiguration alloc] initWithKey:BNCTestBranchKey]]; + self.branch.userTrackingDisabled = YES; + } +} + +- (void)tearDown { + if (self.branch) + self.branch.userTrackingDisabled = NO; +} + +- (void)testShortLink { + + BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"id-123"]; + buo.title = @"Test link"; + buo.canonicalUrl = @"https://branch.io/docs/unit-tests"; + BranchLinkProperties *lp = [[BranchLinkProperties alloc] init]; + lp.channel = @"UnitTests"; + XCTestExpectation *expectation = [self expectationWithDescription:@"testShortLinks"]; + [self.branch branchShortLinkWithContent:buo linkProperties:lp completion: + ^ (NSURL * _Nullable shortURL, NSError * _Nullable error) { + XCTAssertNil(error); + XCTAssertNotNil(shortURL); + XCTAssertTrue([shortURL.absoluteString hasPrefix:@"https://testbed-mac.app.link/"]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:5.0 handler:nil]; + + +} + + +@end diff --git a/Examples/TestBed-macOS/TestBed-macOS.xcodeproj/project.pbxproj b/Examples/TestBed-macOS/TestBed-macOS.xcodeproj/project.pbxproj index bdbfe25..fd15310 100644 --- a/Examples/TestBed-macOS/TestBed-macOS.xcodeproj/project.pbxproj +++ b/Examples/TestBed-macOS/TestBed-macOS.xcodeproj/project.pbxproj @@ -489,6 +489,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + OTHER_CODE_SIGN_FLAGS = "--deep"; PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -506,6 +507,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + OTHER_CODE_SIGN_FLAGS = "--deep"; PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac"; PRODUCT_NAME = "$(TARGET_NAME)"; };