Skip to content

Commit 6f298d0

Browse files
author
nidhi18apr
committed
DK-1067 - Added test case BranchUserTrackingDisabled
1 parent ccae395 commit 6f298d0

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

Branch.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
035E033D252BD1A80015E37C /* BranchUserTrackingDisabled.m in Sources */ = {isa = PBXBuildFile; fileRef = 035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */; };
1011
2B073C1020C97F44005D16D2 /* BNCURLBlackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */; };
1112
2B073C1120C97F44005D16D2 /* BNCURLBlackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */; };
1213
2B0B035520CA50FF0008938F /* BNCURLBlackList.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B073C0C20C97F43005D16D2 /* BNCURLBlackList.m */; };
@@ -221,6 +222,7 @@
221222
/* End PBXBuildFile section */
222223

223224
/* Begin PBXFileReference section */
225+
035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchUserTrackingDisabled.m; sourceTree = "<group>"; };
224226
2B073C0C20C97F43005D16D2 /* BNCURLBlackList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCURLBlackList.m; sourceTree = "<group>"; };
225227
2B073C0D20C97F44005D16D2 /* BNCURLBlackList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCURLBlackList.h; sourceTree = "<group>"; };
226228
4D046E8A20C881470073262B /* BranchNetworkServiceProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchNetworkServiceProtocol.h; sourceTree = "<group>"; };
@@ -500,6 +502,7 @@
500502
4D0B753D211209FA00A06D97 /* BranchTestHost-tvOS.xcconfig */,
501503
4DF8189D20ADDCB500441881 /* BranchTests-Bridging-Header.h */,
502504
4DF818A020ADDCB600441881 /* BranchUniversalObject.Test.m */,
505+
035E033C252BD1A80015E37C /* BranchUserTrackingDisabled.m */,
503506
4D54C08520A6560400C76496 /* Info.plist */,
504507
4D046E9620C8B5B20073262B /* NSData+Branch.Test.m */,
505508
4D99773520AA09B300A63EE1 /* NSString+Branch.Test.m */,
@@ -830,6 +833,7 @@
830833
4D159DDE20B62DD5005A9850 /* BNCPersistence.Test.m in Sources */,
831834
4D046E9A20C8CE740073262B /* BNCTestNetworkService.Test.m in Sources */,
832835
4D159DE320B62DD5005A9850 /* BNCThreads.Test.m in Sources */,
836+
035E033D252BD1A80015E37C /* BranchUserTrackingDisabled.m in Sources */,
833837
4D046E9720C8B5B20073262B /* NSData+Branch.Test.m in Sources */,
834838
4D159DE020B62DD5005A9850 /* BNCTestCase.m in Sources */,
835839
4D159DEA20B62DD5005A9850 /* NSString+Branch.Test.m in Sources */,
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
/**
3+
@file BranchUserTrackingDisabled.m
4+
@package BranchTests
5+
@brief Tests creation of short link when tracking is disabled.
6+
7+
@author Nidhi Dixit
8+
@date 2020
9+
@copyright Copyright © 2020 Branch. All rights reserved.
10+
*/
11+
12+
#import <XCTest/XCTest.h>
13+
#import "BNCTestCase.h"
14+
#import "BranchError.h"
15+
#import "BNCLog.h"
16+
17+
@interface BranchUserTrackingDisabled : XCTestCase
18+
@property (strong) Branch *branch;
19+
@end
20+
21+
@implementation BranchUserTrackingDisabled
22+
23+
- (void)setUp {
24+
if (!self.branch) {
25+
self.branch = [[Branch alloc] init];
26+
[self.branch startWithConfiguration:[[BranchConfiguration alloc] initWithKey:BNCTestBranchKey]];
27+
self.branch.userTrackingDisabled = YES;
28+
}
29+
}
30+
31+
- (void)tearDown {
32+
if (self.branch)
33+
self.branch.userTrackingDisabled = NO;
34+
}
35+
36+
- (void)testShortLink {
37+
38+
BranchUniversalObject *buo = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"id-123"];
39+
buo.title = @"Test link";
40+
buo.canonicalUrl = @"https://branch.io/docs/unit-tests";
41+
BranchLinkProperties *lp = [[BranchLinkProperties alloc] init];
42+
lp.channel = @"UnitTests";
43+
XCTestExpectation *expectation = [self expectationWithDescription:@"testShortLinks"];
44+
[self.branch branchShortLinkWithContent:buo linkProperties:lp completion:
45+
^ (NSURL * _Nullable shortURL, NSError * _Nullable error) {
46+
XCTAssertNil(error);
47+
XCTAssertNotNil(shortURL);
48+
XCTAssertTrue([shortURL.absoluteString hasPrefix:@"https://testbed-mac.app.link/"]);
49+
[expectation fulfill];
50+
}];
51+
[self waitForExpectationsWithTimeout:5.0 handler:nil];
52+
53+
54+
}
55+
56+
57+
@end

Examples/TestBed-macOS/TestBed-macOS.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@
489489
"$(inherited)",
490490
"@executable_path/../Frameworks",
491491
);
492+
OTHER_CODE_SIGN_FLAGS = "--deep";
492493
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
493494
PRODUCT_NAME = "$(TARGET_NAME)";
494495
};
@@ -506,6 +507,7 @@
506507
"$(inherited)",
507508
"@executable_path/../Frameworks",
508509
);
510+
OTHER_CODE_SIGN_FLAGS = "--deep";
509511
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.TestBed-Mac";
510512
PRODUCT_NAME = "$(TARGET_NAME)";
511513
};

0 commit comments

Comments
 (0)