Skip to content

Commit 590f25b

Browse files
committed
Release 3.11.0 Updates.
1 parent e3b2b38 commit 590f25b

40 files changed

+1152
-35
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
//
2+
// BNCODMTests.m
3+
// Branch-SDK-Tests
4+
//
5+
// Created by Nidhi Dixit on 4/16/25.
6+
// Copyright © 2025 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "Branch.h"
11+
#import "BNCPreferenceHelper.h"
12+
#import "BNCRequestFactory.h"
13+
#import "BNCEncodingUtils.h"
14+
#import "BNCODMInfoCollector.h"
15+
#import "NSError+Branch.h"
16+
17+
@interface BNCODMTests : XCTestCase
18+
@property (nonatomic, strong, readwrite) BNCPreferenceHelper *prefHelper;
19+
@end
20+
21+
@implementation BNCODMTests
22+
23+
- (void)setUp {
24+
_prefHelper = [BNCPreferenceHelper sharedInstance];
25+
}
26+
27+
- (void)testSetODM {
28+
NSString *odm = @"testODMString";
29+
NSDate *firstOpenTS = [NSDate date];
30+
[Branch setODMInfo:odm andFirstOpenTimestamp:firstOpenTS];
31+
XCTAssertTrue([_prefHelper.odmInfo isEqualToString:odm]);
32+
XCTAssertTrue([_prefHelper.odmInfoInitDate isEqualToDate:firstOpenTS]);
33+
34+
}
35+
36+
- (void)testSetODMandSDKRequests {
37+
NSString* requestUUID = [[NSUUID UUID ] UUIDString];
38+
NSNumber* requestCreationTimeStamp = BNCWireFormatFromDate([NSDate date]);
39+
NSString *odm = @"testODMString";
40+
NSDate *firstOpenTS = [NSDate date];
41+
42+
[Branch setODMInfo:odm andFirstOpenTimestamp:firstOpenTS];
43+
44+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
45+
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd" UUID:requestUUID TimeStamp:requestCreationTimeStamp];
46+
NSDictionary *jsonInstall = [factory dataForInstallWithURLString:@"https://branch.io"];
47+
XCTAssertTrue([odm isEqualToString:[jsonInstall objectForKey:@"odm_info"]]);
48+
49+
NSDictionary *jsonOpen = [factory dataForOpenWithURLString:@"https://branch.io"];
50+
XCTAssertTrue([odm isEqualToString:[jsonOpen objectForKey:@"odm_info"]]);
51+
52+
NSDictionary *event = @{@"name": @"ADD_TO_CART"};
53+
NSDictionary *jsonEvent = [factory dataForEventWithEventDictionary:[event mutableCopy]];
54+
XCTAssertTrue([jsonEvent objectForKey:@"odm_info"] == nil);
55+
56+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelReduced];
57+
jsonInstall = [factory dataForInstallWithURLString:@"https://branch.io"];
58+
XCTAssertTrue([jsonInstall objectForKey:@"odm_info"] == nil);
59+
60+
jsonOpen = [factory dataForOpenWithURLString:@"https://branch.io"];
61+
XCTAssertTrue([jsonOpen objectForKey:@"odm_info"] == nil);
62+
63+
self.prefHelper.odmInfo = nil;
64+
self.prefHelper.odmInfoInitDate = nil;
65+
}
66+
67+
- (void)testODMTimeOut {
68+
69+
NSString* requestUUID = [[NSUUID UUID ] UUIDString];
70+
NSNumber* requestCreationTimeStamp = BNCWireFormatFromDate([NSDate date]);
71+
NSString *odm = @"testODMString";
72+
NSDate *firstOpenTS = [[NSDate date] dateByAddingTimeInterval:-((180*24*3600) - 5)];
73+
74+
[Branch setODMInfo:odm andFirstOpenTimestamp:firstOpenTS];
75+
76+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
77+
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd" UUID:requestUUID TimeStamp:requestCreationTimeStamp];
78+
NSDictionary *jsonInstall = [factory dataForInstallWithURLString:@"https://branch.io"];
79+
XCTAssertTrue([odm isEqualToString:[jsonInstall objectForKey:@"odm_info"]]);
80+
81+
sleep(10);
82+
83+
NSDictionary *jsonOpen = [factory dataForOpenWithURLString:@"https://branch.io"];
84+
XCTAssertTrue(![odm isEqualToString:[jsonOpen objectForKey:@"odm_info"]]);
85+
86+
self.prefHelper.odmInfo = nil;
87+
self.prefHelper.odmInfoInitDate = nil;
88+
89+
}
90+
91+
92+
- (void) testODMAPIsNotLoaded {
93+
XCTestExpectation *expectation = [self expectationWithDescription:@"Check if ODCManager class is loaded."];
94+
[[BNCODMInfoCollector instance ] loadODMInfoWithTimeOut:DISPATCH_TIME_FOREVER andCompletionHandler:^(NSString * _Nullable odmInfo, NSError * _Nullable error) {
95+
if (error.code == BNCClassNotFoundError){
96+
[expectation fulfill];
97+
}
98+
}];
99+
[self waitForExpectationsWithTimeout:15 handler:nil];
100+
}
101+
102+
@end

Branch-TestBed/Branch-TestBed-CI.xctestplan

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212

1313
},
1414
"testTargets" : [
15+
{
16+
"target" : {
17+
"containerPath" : "container:Branch-TestBed.xcodeproj",
18+
"identifier" : "E7AC745F2DB064BC002D8C40",
19+
"name" : "Reflection_ODM_Tests"
20+
}
21+
},
1522
{
1623
"target" : {
1724
"containerPath" : "container:Branch-TestBed.xcodeproj",

Branch-TestBed/Branch-TestBed.xcodeproj/Branch-TestBed.xctestplan

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,32 @@
2626
},
2727
"testTargets" : [
2828
{
29-
"deviceAppDataReference" : {
30-
"resolvedPath" : "..\/Simulate-FirstRun.xcappdata"
31-
},
3229
"skippedTests" : [
33-
"BNCServerInterfaceTests",
34-
"BranchDelegateTest"
30+
"UITestSafari",
31+
"UITestSafari\/testDeepLinking"
3532
],
3633
"target" : {
3734
"containerPath" : "container:Branch-TestBed.xcodeproj",
38-
"identifier" : "7E6B3B501AA42D0E005F45BF",
39-
"name" : "Branch-SDK-Tests"
35+
"identifier" : "F1D4F9AB1F323F01002D13FF",
36+
"name" : "Branch-TestBed-UITests"
37+
}
38+
},
39+
{
40+
"target" : {
41+
"containerPath" : "container:Branch-TestBed.xcodeproj",
42+
"identifier" : "E7AC745F2DB064BC002D8C40",
43+
"name" : "Reflection_ODM_Tests"
4044
}
4145
},
4246
{
4347
"skippedTests" : [
44-
"UITestSafari",
45-
"UITestSafari\/testDeepLinking"
48+
"BNCServerInterfaceTests",
49+
"BranchDelegateTest"
4650
],
4751
"target" : {
4852
"containerPath" : "container:Branch-TestBed.xcodeproj",
49-
"identifier" : "F1D4F9AB1F323F01002D13FF",
50-
"name" : "Branch-TestBed-UITests"
53+
"identifier" : "7E6B3B501AA42D0E005F45BF",
54+
"name" : "Branch-SDK-Tests"
5155
}
5256
},
5357
{

0 commit comments

Comments
 (0)