From 1c4df070a1e7679998bd4951ccd91bcb2ac30dc5 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 14 Feb 2024 21:00:16 -0800 Subject: [PATCH] Test for EEA is failing on repeat run. --- Branch-TestBed/Branch-SDK-Tests/BranchClassTests.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Branch-TestBed/Branch-SDK-Tests/BranchClassTests.m b/Branch-TestBed/Branch-SDK-Tests/BranchClassTests.m index f66ed3e53..9d337a14e 100644 --- a/Branch-TestBed/Branch-SDK-Tests/BranchClassTests.m +++ b/Branch-TestBed/Branch-SDK-Tests/BranchClassTests.m @@ -13,6 +13,11 @@ #import "BNCAppGroupsData.h" #import "BNCPartnerParameters.h" +@interface BNCPreferenceHelper(Test) +// Expose internal private method to clear EEA data +- (void)writeObjectToDefaults:(NSString *)key value:(NSObject *)value; +@end + @interface BranchClassTests : XCTestCase @property (nonatomic, strong) Branch *branch; @end @@ -221,14 +226,19 @@ - (void)testGetLongURLWithParamsAndChannelAndTagsAndFeatureAndStageAndAlias { } - (void)testSetDMAParamsForEEA { - XCTAssertFalse([[BNCPreferenceHelper sharedInstance] eeaRegionInitialized]); + [Branch setDMAParamsForEEA:FALSE AdPersonalizationConsent:TRUE AdUserDataUsageConsent:TRUE]; XCTAssertTrue([[BNCPreferenceHelper sharedInstance] eeaRegionInitialized]); XCTAssertFalse([BNCPreferenceHelper sharedInstance].eeaRegion); XCTAssertTrue([BNCPreferenceHelper sharedInstance].adPersonalizationConsent); XCTAssertTrue([BNCPreferenceHelper sharedInstance].adUserDataUsageConsent); + // Manually clear values after testing + // By design, this API is meant to be set once and always set. However, in a test scenario it needs to be cleared. + [[BNCPreferenceHelper sharedInstance] writeObjectToDefaults:@"bnc_dma_eea" value:nil]; + [[BNCPreferenceHelper sharedInstance] writeObjectToDefaults:@"bnc_dma_ad_personalization" value:nil]; + [[BNCPreferenceHelper sharedInstance] writeObjectToDefaults:@"bnc_dma_ad_user_data" value:nil]; } @end