Skip to content

Commit ce2309d

Browse files
committed
Release 3.13.0 Updates
1 parent 4043484 commit ce2309d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+675
-640
lines changed

Branch-TestBed/Branch-SDK-Tests/BNCAPIServerTest.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ - (void)testSetSafeTrackServiceURLWithUserTrackingDomain {
450450
XCTAssertEqualObjects(storedUrl, expectedUrl);
451451

452452
storedUrl = [[BNCServerAPI sharedInstance] validationServiceURL];
453-
expectedUrl = @"https://links.toTestDomain.com/v1/app-link-settings";
453+
expectedUrl = @"https://api3.branch.io/v1/app-link-settings";
454454
XCTAssertEqualObjects(storedUrl, expectedUrl);
455455

456456
[BNCServerAPI sharedInstance].useTrackingDomain = NO;
@@ -501,7 +501,7 @@ - (void)testSetSafeTrackServiceURLWithOutUserTrackingDomain {
501501
XCTAssertEqualObjects(storedUrl, expectedUrl);
502502

503503
storedUrl = [[BNCServerAPI sharedInstance] validationServiceURL];
504-
expectedUrl = @"https://links.toTestDomain.com/v1/app-link-settings";
504+
expectedUrl = @"https://api3.branch.io/v1/app-link-settings";
505505
XCTAssertEqualObjects(storedUrl, expectedUrl);
506506

507507
[BNCServerAPI sharedInstance].useTrackingDomain = NO;

Branch-TestBed/Branch-SDK-Tests/BNCAppleReceiptTests.m

Lines changed: 0 additions & 33 deletions
This file was deleted.

Branch-TestBed/Branch-SDK-Tests/BNCODMTests.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ - (void)testSetODMandSDKRequests {
6565
}
6666

6767
- (void)testODMTimeOut {
68-
68+
6969
NSString* requestUUID = [[NSUUID UUID ] UUIDString];
7070
NSNumber* requestCreationTimeStamp = BNCWireFormatFromDate([NSDate date]);
7171
NSString *odm = @"testODMString";
@@ -80,21 +80,23 @@ - (void)testODMTimeOut {
8080

8181
sleep(10);
8282

83-
NSDictionary *jsonOpen = [factory dataForOpenWithURLString:@"https://branch.io"];
83+
BNCRequestFactory *factory2 = [[BNCRequestFactory alloc] initWithBranchKey:@"key_abcd" UUID:requestUUID TimeStamp:requestCreationTimeStamp];
84+
NSDictionary *jsonOpen = [factory2 dataForOpenWithURLString:@"https://branch.io"];
8485
XCTAssertTrue(![odm isEqualToString:[jsonOpen objectForKey:@"odm_info"]]);
8586

8687
self.prefHelper.odmInfo = nil;
8788
self.prefHelper.odmInfoInitDate = nil;
88-
89+
8990
}
9091

9192

9293
- (void) testODMAPIsNotLoaded {
94+
9395
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-
}
96+
[[BNCODMInfoCollector instance ] loadODMInfoWithCompletionHandler:^(NSString * _Nullable odmInfo, NSError * _Nullable error) {
97+
if (error.code == BNCClassNotFoundError){
98+
[expectation fulfill];
99+
}
98100
}];
99101
[self waitForExpectationsWithTimeout:15 handler:nil];
100102
}

Branch-TestBed/Branch-SDK-Tests/BNCPreferenceHelperTests.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,27 @@ - (void)testSaveContentAnalyticsManifest {
414414
XCTAssertEqualObjects(retrievedManifest, dummyManifest);
415415
}
416416

417+
- (void)testThirdPartyAPIsTimeoutDefaultValue {
418+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, 0.5,
419+
@"Default third party APIs timeout should be 0.5 seconds");
420+
}
421+
422+
- (void)testThirdPartyAPIsTimeoutSetterGetter {
423+
NSTimeInterval testTimeout1 = 1.0;
424+
self.prefHelper.thirdPartyAPIsWaitTime = testTimeout1;
425+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, testTimeout1,
426+
@"Third party APIs timeout should be settable and retrievable");
427+
428+
NSTimeInterval testTimeout2 = 2.5;
429+
self.prefHelper.thirdPartyAPIsWaitTime = testTimeout2;
430+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, testTimeout2,
431+
@"Third party APIs timeout should be updatable");
432+
433+
NSTimeInterval testTimeout3 = 0.1;
434+
self.prefHelper.thirdPartyAPIsWaitTime = testTimeout3;
435+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, testTimeout3,
436+
@"Third party APIs timeout should support small values");
437+
}
438+
439+
417440
@end

Branch-TestBed/Branch-SDK-Tests/BranchClassTests.m

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ - (void)writeObjectToDefaults:(NSString *)key value:(NSObject *)value;
2020

2121
@interface BranchClassTests : XCTestCase
2222
@property (nonatomic, strong) Branch *branch;
23+
@property (nonatomic, strong, readwrite) BNCPreferenceHelper *prefHelper;
2324
@end
2425

2526
@implementation BranchClassTests
2627

2728
- (void)setUp {
2829
[super setUp];
2930
self.branch = [Branch getInstance];
31+
self.prefHelper = [BNCPreferenceHelper sharedInstance];
3032
}
3133

3234
- (void)tearDown {
@@ -261,5 +263,197 @@ - (void)testSetConsumerProtectionAttributionLevel {
261263

262264
}
263265

266+
- (void)testBranchSetSDKWaitTimeForThirdPartyAPIs {
267+
// Test Branch instance method for setting timeout
268+
NSTimeInterval testTimeout = 2.0;
269+
[Branch setSDKWaitTimeForThirdPartyAPIs:testTimeout];
270+
271+
// Verify it was set in the preference helper
272+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, testTimeout,
273+
@"Branch setSDKWaitTimeForThirdPartyAPIs should update preference helper");
274+
}
275+
276+
- (void)testBranchSetSDKWaitTimeForThirdPartyAPIsMultipleValues {
277+
// Test setting multiple different values
278+
NSArray *testValues = @[@0.5, @1.0, @1.5, @3.0, @5.0];
279+
280+
for (NSNumber *timeoutValue in testValues) {
281+
NSTimeInterval timeout = [timeoutValue doubleValue];
282+
[Branch setSDKWaitTimeForThirdPartyAPIs:timeout];
283+
284+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, timeout,
285+
@"Branch setSDKWaitTimeForThirdPartyAPIs should handle value %.1f", timeout);
286+
}
287+
}
288+
289+
- (void)testTimeoutIntegrationWithPreferenceHelper {
290+
// Test that Branch and PreferenceHelper work together correctly
291+
NSTimeInterval branchTimeout = 1.8;
292+
NSTimeInterval directTimeout = 2.3;
293+
294+
// Set via Branch
295+
[Branch setSDKWaitTimeForThirdPartyAPIs:branchTimeout];
296+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, branchTimeout,
297+
@"Wait Time set via Branch should be readable from PreferenceHelper");
298+
299+
// Set directly on PreferenceHelper
300+
self.prefHelper.thirdPartyAPIsWaitTime = directTimeout;
301+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, directTimeout,
302+
@"Wait time set directly should be readable via Branch");
303+
}
304+
305+
- (void)testTimeoutValueConsistency {
306+
// Test that the same instance maintains consistent values
307+
NSTimeInterval testTimeout = 1.25;
308+
309+
[Branch setSDKWaitTimeForThirdPartyAPIs:testTimeout];
310+
311+
// Read multiple times to ensure consistency
312+
for (int i = 0; i < 5; i++) {
313+
XCTAssertEqual(self.prefHelper.thirdPartyAPIsWaitTime, testTimeout,
314+
@"Timeout value should remain consistent across multiple reads");
315+
}
316+
}
317+
318+
- (void)testBranchSetSDKWaitTimeForThirdPartyAPIsInvalidLowValues {
319+
320+
NSArray *invalidLowValues = @[@0.0, @-1.0, @-0.5];
321+
NSTimeInterval originalTimeout = [BNCPreferenceHelper sharedInstance].thirdPartyAPIsWaitTime;
322+
323+
for (NSNumber *timeoutValue in invalidLowValues) {
324+
NSTimeInterval timeout = [timeoutValue doubleValue];
325+
[Branch setSDKWaitTimeForThirdPartyAPIs:timeout];
326+
XCTAssertEqual([BNCPreferenceHelper sharedInstance].thirdPartyAPIsWaitTime, originalTimeout,
327+
@"Branch setSDKWaitTimeForThirdPartyAPIs should reject invalid low value %.3f", timeout);
328+
}
329+
}
330+
331+
- (void)testBranchsetSDKWaitTimeForThirdPartyAPIsInvalidHighValues {
332+
333+
NSArray *invalidHighValues = @[@10.1, @15.0, @30.0, @60.0];
334+
NSTimeInterval originalTimeout = [BNCPreferenceHelper sharedInstance].thirdPartyAPIsWaitTime;
335+
336+
for (NSNumber *timeoutValue in invalidHighValues) {
337+
NSTimeInterval timeout = [timeoutValue doubleValue];
338+
[Branch setSDKWaitTimeForThirdPartyAPIs:timeout];
339+
XCTAssertEqual([BNCPreferenceHelper sharedInstance].thirdPartyAPIsWaitTime, originalTimeout,
340+
@"Branch setSDKWaitTimeForThirdPartyAPIs should reject invalid high value %.3f", timeout);
341+
}
342+
}
343+
344+
- (void)testBranchSetSDKWaitTimeForThirdPartyAPIsBoundaryValues {
345+
346+
// Test exactly 10.0 (should be valid)
347+
[Branch setSDKWaitTimeForThirdPartyAPIs:10.0];
348+
XCTAssertEqual([BNCPreferenceHelper sharedInstance].thirdPartyAPIsWaitTime, 10.0,
349+
@"Timeout of exactly 10.0 seconds should be valid");
350+
351+
// Test just over 10.0 (should be invalid)
352+
[Branch setSDKWaitTimeForThirdPartyAPIs:10.0001];
353+
XCTAssertEqual([BNCPreferenceHelper sharedInstance].thirdPartyAPIsWaitTime, 10.0,
354+
@"Timeout of 10.0001 seconds should be rejected");
355+
356+
// Test very small positive value (should be valid)
357+
[Branch setSDKWaitTimeForThirdPartyAPIs:0.0001];
358+
XCTAssertEqual([BNCPreferenceHelper sharedInstance].thirdPartyAPIsWaitTime, 0.0001,
359+
@"Very small positive timeout should be valid");
360+
}
361+
362+
- (void)testSetAnonID {
363+
NSString *expectedAnonID = @"static-test-anon-id-12345";
364+
365+
[Branch setAnonID:expectedAnonID];
366+
367+
NSString *actualAnonID = [BNCPreferenceHelper sharedInstance].anonID;
368+
XCTAssertEqualObjects(actualAnonID, expectedAnonID, @"setAnonID should set valid string");
369+
}
370+
371+
- (void)testSetAnonID_UpdateExistingValue {
372+
NSString *initialAnonID = @"initial-anon-id";
373+
NSString *updatedAnonID = @"updated-anon-id";
374+
375+
[Branch setAnonID:initialAnonID];
376+
XCTAssertEqualObjects([BNCPreferenceHelper sharedInstance].anonID, initialAnonID);
377+
378+
[Branch setAnonID:updatedAnonID];
379+
XCTAssertEqualObjects([BNCPreferenceHelper sharedInstance].anonID, updatedAnonID);
380+
}
381+
382+
- (void)testSetAnonID_NilValue {
383+
NSString *initialAnonID = @"initial-anon-id";
384+
385+
[Branch setAnonID:initialAnonID];
386+
XCTAssertEqualObjects([BNCPreferenceHelper sharedInstance].anonID, initialAnonID);
387+
388+
[Branch setAnonID:nil];
389+
XCTAssertEqualObjects([BNCPreferenceHelper sharedInstance].anonID, initialAnonID);
390+
}
391+
392+
- (void)testSetAnonID_EmptyString {
393+
NSString *emptyAnonID = @"";
394+
395+
[Branch setAnonID:emptyAnonID];
396+
397+
NSString *actualAnonID = [BNCPreferenceHelper sharedInstance].anonID;
398+
XCTAssertEqualObjects(actualAnonID, emptyAnonID, @"Static setAnonID should accept empty string");
399+
}
400+
401+
- (void)testSetAnonID_NonStringObject {
402+
NSString *initialAnonID = @"initial-anon-id";
403+
404+
[Branch setAnonID:initialAnonID];
405+
XCTAssertEqualObjects([BNCPreferenceHelper sharedInstance].anonID, initialAnonID);
406+
407+
// Try to set with a non-string object (NSNumber)
408+
NSNumber *nonStringValue = @123;
409+
[Branch setAnonID:(NSString *)nonStringValue];
410+
411+
XCTAssertEqualObjects([BNCPreferenceHelper sharedInstance].anonID, initialAnonID);
412+
}
413+
414+
- (void)testSetAnonID_LongString {
415+
NSString *longAnonID = @"very-long-anon-id-with-many-characters-to-test-string-handling-1234567890-abcdefghijklmnopqrstuvwxyz";
416+
417+
[Branch setAnonID:longAnonID];
418+
419+
NSString *actualAnonID = [BNCPreferenceHelper sharedInstance].anonID;
420+
XCTAssertEqualObjects(actualAnonID, longAnonID, @"setAnonID should handle long strings");
421+
}
422+
423+
- (void)testSetAnonID_SpecialCharacters {
424+
NSString *specialCharAnonID = @"static-anon-id-with-special-chars-!@#$%^&*()_+-=[]{}|;:,.<>?";
425+
426+
[Branch setAnonID:specialCharAnonID];
427+
428+
NSString *actualAnonID = [BNCPreferenceHelper sharedInstance].anonID;
429+
XCTAssertEqualObjects(actualAnonID, specialCharAnonID, @"setAnonID should handle special characters");
430+
}
431+
432+
- (void)testSetAnonID_ThreadSafety {
433+
NSString *anonID1 = @"thread-test-anon-id-1";
434+
NSString *anonID2 = @"thread-test-anon-id-2";
435+
436+
// Test that the method is thread-safe by calling it from different queues
437+
dispatch_group_t group = dispatch_group_create();
438+
439+
dispatch_group_enter(group);
440+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
441+
[Branch setAnonID:anonID1];
442+
dispatch_group_leave(group);
443+
});
444+
445+
dispatch_group_enter(group);
446+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
447+
[Branch setAnonID:anonID2];
448+
dispatch_group_leave(group);
449+
});
450+
451+
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
452+
453+
// Verify that one of the values was set (we can't predict which due to concurrency)
454+
NSString *finalAnonID = [BNCPreferenceHelper sharedInstance].anonID;
455+
XCTAssertTrue([finalAnonID isEqualToString:anonID1] || [finalAnonID isEqualToString:anonID2],
456+
@"One of the anonID values should be set");
457+
}
264458

265459
@end

0 commit comments

Comments
 (0)