Skip to content

Commit 57fba16

Browse files
committed
SDK-76 add unhosted unit tests to validate pre-initialization code.
1 parent 0c166db commit 57fba16

File tree

4 files changed

+250
-2
lines changed

4 files changed

+250
-2
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// Branch_setBranchKeyTests.m
3+
// Branch-SDK-Unhosted-Tests
4+
//
5+
// Created by Ernest Cho on 12/3/18.
6+
// Copyright © 2018 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "Branch.h"
11+
12+
/**
13+
Tests pre-init methods. These must run unhosted in order to avoid initialization that the test app does.
14+
*/
15+
@interface Branch_setBranchKeyTests : XCTestCase
16+
17+
@end
18+
19+
@implementation Branch_setBranchKeyTests
20+
21+
- (void)setUp {
22+
23+
}
24+
25+
- (void)tearDown {
26+
27+
}
28+
29+
- (void)testSetBranchKey_validKey {
30+
XCTAssertNoThrow([Branch setBranchKey:@"key_live_foo"]);
31+
}
32+
33+
- (void)testSetBranchKey_nilKey {
34+
XCTAssertNoThrow([Branch setBranchKey:nil]);
35+
}
36+
37+
- (void)testSetBranchKey_invalidKey {
38+
XCTAssertNoThrow([Branch setBranchKey:@"invalid_key"]);
39+
}
40+
41+
@end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>

Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@
166166
54391A161BA249FA0061CB0F /* BranchCSSearchableItemAttributeSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 54391A141BA249FA0061CB0F /* BranchCSSearchableItemAttributeSet.m */; };
167167
54FF1F8E1BD1D4AE0004CE2E /* BranchUniversalObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 54FF1F8C1BD1D4AE0004CE2E /* BranchUniversalObject.m */; };
168168
54FF1F921BD1DC320004CE2E /* BranchLinkProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 54FF1F901BD1DC320004CE2E /* BranchLinkProperties.m */; };
169+
5F8B7B4021B5F5CD009CE0A6 /* libBranch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 466B58381B17773000A69EDE /* libBranch.a */; };
170+
5F8B7B4721B5F5F0009CE0A6 /* Branch_setBranchKeyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B7B4621B5F5F0009CE0A6 /* Branch_setBranchKeyTests.m */; };
169171
63E4C4881D25E16A00A45FD8 /* LogOutputViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E4C4871D25E16A00A45FD8 /* LogOutputViewController.m */; };
170172
63E4C48B1D25E17B00A45FD8 /* NavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E4C48A1D25E17B00A45FD8 /* NavigationController.m */; };
171173
63E4C4901D25E1BC00A45FD8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63E4C48F1D25E1BC00A45FD8 /* LaunchScreen.storyboard */; };
@@ -221,6 +223,13 @@
221223
remoteGlobalIDString = 6700165F1940F51400A9E103;
222224
remoteInfo = "Branch-TestBed";
223225
};
226+
5F8B7B4121B5F5CD009CE0A6 /* PBXContainerItemProxy */ = {
227+
isa = PBXContainerItemProxy;
228+
containerPortal = 670016581940F51400A9E103 /* Project object */;
229+
proxyType = 1;
230+
remoteGlobalIDString = 466B58371B17773000A69EDE;
231+
remoteInfo = Branch;
232+
};
224233
F1D4F9B11F323F01002D13FF /* PBXContainerItemProxy */ = {
225234
isa = PBXContainerItemProxy;
226235
containerPortal = 670016581940F51400A9E103 /* Project object */;
@@ -379,6 +388,9 @@
379388
54FF1F8C1BD1D4AE0004CE2E /* BranchUniversalObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchUniversalObject.m; sourceTree = "<group>"; };
380389
54FF1F8F1BD1DC320004CE2E /* BranchLinkProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchLinkProperties.h; sourceTree = "<group>"; };
381390
54FF1F901BD1DC320004CE2E /* BranchLinkProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchLinkProperties.m; sourceTree = "<group>"; };
391+
5F8B7B3B21B5F5CD009CE0A6 /* Branch-SDK-Unhosted-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Branch-SDK-Unhosted-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
392+
5F8B7B3F21B5F5CD009CE0A6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
393+
5F8B7B4621B5F5F0009CE0A6 /* Branch_setBranchKeyTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Branch_setBranchKeyTests.m; sourceTree = "<group>"; };
382394
63E4C4861D25E16A00A45FD8 /* LogOutputViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogOutputViewController.h; sourceTree = "<group>"; };
383395
63E4C4871D25E16A00A45FD8 /* LogOutputViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LogOutputViewController.m; sourceTree = "<group>"; };
384396
63E4C4891D25E17B00A45FD8 /* NavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationController.h; sourceTree = "<group>"; };
@@ -469,6 +481,14 @@
469481
);
470482
runOnlyForDeploymentPostprocessing = 0;
471483
};
484+
5F8B7B3821B5F5CD009CE0A6 /* Frameworks */ = {
485+
isa = PBXFrameworksBuildPhase;
486+
buildActionMask = 2147483647;
487+
files = (
488+
5F8B7B4021B5F5CD009CE0A6 /* libBranch.a in Frameworks */,
489+
);
490+
runOnlyForDeploymentPostprocessing = 0;
491+
};
472492
6700165D1940F51400A9E103 /* Frameworks */ = {
473493
isa = PBXFrameworksBuildPhase;
474494
buildActionMask = 2147483647;
@@ -624,13 +644,23 @@
624644
path = "Branch-TestBed-UITests";
625645
sourceTree = "<group>";
626646
};
647+
5F8B7B3C21B5F5CD009CE0A6 /* Branch-SDK-Unhosted-Tests */ = {
648+
isa = PBXGroup;
649+
children = (
650+
5F8B7B4621B5F5F0009CE0A6 /* Branch_setBranchKeyTests.m */,
651+
5F8B7B3F21B5F5CD009CE0A6 /* Info.plist */,
652+
);
653+
path = "Branch-SDK-Unhosted-Tests";
654+
sourceTree = "<group>";
655+
};
627656
670016571940F51400A9E103 = {
628657
isa = PBXGroup;
629658
children = (
630659
4D93D8592098CC4400CFABA6 /* README.md */,
631660
670016BB1946309100A9E103 /* Branch-SDK */,
632661
4D16837A2098C901008819E3 /* Branch-SDK-Tests */,
633662
670016691940F51400A9E103 /* Branch-TestBed */,
663+
5F8B7B3C21B5F5CD009CE0A6 /* Branch-SDK-Unhosted-Tests */,
634664
4D93D85E2098D43C00CFABA6 /* Branch-TestBed-UITests */,
635665
E220F4281C7D39D500F5B126 /* Fabric */,
636666
670016621940F51400A9E103 /* Frameworks */,
@@ -646,6 +676,7 @@
646676
7E6B3B511AA42D0E005F45BF /* Branch-SDK-Tests.xctest */,
647677
466B58381B17773000A69EDE /* libBranch.a */,
648678
F1D4F9AC1F323F01002D13FF /* Branch-TestBed-UITests.xctest */,
679+
5F8B7B3B21B5F5CD009CE0A6 /* Branch-SDK-Unhosted-Tests.xctest */,
649680
);
650681
name = Products;
651682
sourceTree = "<group>";
@@ -911,6 +942,24 @@
911942
productReference = 466B58381B17773000A69EDE /* libBranch.a */;
912943
productType = "com.apple.product-type.library.static";
913944
};
945+
5F8B7B3A21B5F5CD009CE0A6 /* Branch-SDK-Unhosted-Tests */ = {
946+
isa = PBXNativeTarget;
947+
buildConfigurationList = 5F8B7B4521B5F5CD009CE0A6 /* Build configuration list for PBXNativeTarget "Branch-SDK-Unhosted-Tests" */;
948+
buildPhases = (
949+
5F8B7B3721B5F5CD009CE0A6 /* Sources */,
950+
5F8B7B3821B5F5CD009CE0A6 /* Frameworks */,
951+
5F8B7B3921B5F5CD009CE0A6 /* Resources */,
952+
);
953+
buildRules = (
954+
);
955+
dependencies = (
956+
5F8B7B4221B5F5CD009CE0A6 /* PBXTargetDependency */,
957+
);
958+
name = "Branch-SDK-Unhosted-Tests";
959+
productName = "Branch-SDK-Unhosted-Tests";
960+
productReference = 5F8B7B3B21B5F5CD009CE0A6 /* Branch-SDK-Unhosted-Tests.xctest */;
961+
productType = "com.apple.product-type.bundle.unit-test";
962+
};
914963
6700165F1940F51400A9E103 /* Branch-TestBed */ = {
915964
isa = PBXNativeTarget;
916965
buildConfigurationList = 670016921940F51400A9E103 /* Build configuration list for PBXNativeTarget "Branch-TestBed" */;
@@ -981,6 +1030,11 @@
9811030
466B58371B17773000A69EDE = {
9821031
CreatedOnToolsVersion = 6.3.2;
9831032
};
1033+
5F8B7B3A21B5F5CD009CE0A6 = {
1034+
CreatedOnToolsVersion = 10.1;
1035+
DevelopmentTeam = R63EM248DP;
1036+
ProvisioningStyle = Automatic;
1037+
};
9841038
6700165F1940F51400A9E103 = {
9851039
DevelopmentTeam = R63EM248DP;
9861040
SystemCapabilities = {
@@ -1022,12 +1076,20 @@
10221076
466B58371B17773000A69EDE /* Branch */,
10231077
6700165F1940F51400A9E103 /* Branch-TestBed */,
10241078
7E6B3B501AA42D0E005F45BF /* Branch-SDK-Tests */,
1079+
5F8B7B3A21B5F5CD009CE0A6 /* Branch-SDK-Unhosted-Tests */,
10251080
F1D4F9AB1F323F01002D13FF /* Branch-TestBed-UITests */,
10261081
);
10271082
};
10281083
/* End PBXProject section */
10291084

10301085
/* Begin PBXResourcesBuildPhase section */
1086+
5F8B7B3921B5F5CD009CE0A6 /* Resources */ = {
1087+
isa = PBXResourcesBuildPhase;
1088+
buildActionMask = 2147483647;
1089+
files = (
1090+
);
1091+
runOnlyForDeploymentPostprocessing = 0;
1092+
};
10311093
6700165E1940F51400A9E103 /* Resources */ = {
10321094
isa = PBXResourcesBuildPhase;
10331095
buildActionMask = 2147483647;
@@ -1145,6 +1207,14 @@
11451207
);
11461208
runOnlyForDeploymentPostprocessing = 0;
11471209
};
1210+
5F8B7B3721B5F5CD009CE0A6 /* Sources */ = {
1211+
isa = PBXSourcesBuildPhase;
1212+
buildActionMask = 2147483647;
1213+
files = (
1214+
5F8B7B4721B5F5F0009CE0A6 /* Branch_setBranchKeyTests.m in Sources */,
1215+
);
1216+
runOnlyForDeploymentPostprocessing = 0;
1217+
};
11481218
6700165C1940F51400A9E103 /* Sources */ = {
11491219
isa = PBXSourcesBuildPhase;
11501220
buildActionMask = 2147483647;
@@ -1229,6 +1299,11 @@
12291299
target = 6700165F1940F51400A9E103 /* Branch-TestBed */;
12301300
targetProxy = 4D337DDC201019B8009A5774 /* PBXContainerItemProxy */;
12311301
};
1302+
5F8B7B4221B5F5CD009CE0A6 /* PBXTargetDependency */ = {
1303+
isa = PBXTargetDependency;
1304+
target = 466B58371B17773000A69EDE /* Branch */;
1305+
targetProxy = 5F8B7B4121B5F5CD009CE0A6 /* PBXContainerItemProxy */;
1306+
};
12321307
F1D4F9B21F323F01002D13FF /* PBXTargetDependency */ = {
12331308
isa = PBXTargetDependency;
12341309
target = 6700165F1940F51400A9E103 /* Branch-TestBed */;
@@ -1287,6 +1362,51 @@
12871362
};
12881363
name = Release;
12891364
};
1365+
5F8B7B4321B5F5CD009CE0A6 /* Debug */ = {
1366+
isa = XCBuildConfiguration;
1367+
buildSettings = {
1368+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
1369+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
1370+
CLANG_ENABLE_OBJC_WEAK = YES;
1371+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
1372+
CODE_SIGN_STYLE = Automatic;
1373+
DEBUG_INFORMATION_FORMAT = dwarf;
1374+
DEVELOPMENT_TEAM = R63EM248DP;
1375+
GCC_C_LANGUAGE_STANDARD = gnu11;
1376+
INFOPLIST_FILE = "Branch-SDK-Unhosted-Tests/Info.plist";
1377+
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
1378+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1379+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
1380+
MTL_FAST_MATH = YES;
1381+
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.Branch-SDK-Unhosted-Tests";
1382+
PRODUCT_NAME = "$(TARGET_NAME)";
1383+
TARGETED_DEVICE_FAMILY = "1,2";
1384+
};
1385+
name = Debug;
1386+
};
1387+
5F8B7B4421B5F5CD009CE0A6 /* Release */ = {
1388+
isa = XCBuildConfiguration;
1389+
buildSettings = {
1390+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
1391+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
1392+
CLANG_ENABLE_OBJC_WEAK = YES;
1393+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
1394+
CODE_SIGN_STYLE = Automatic;
1395+
COPY_PHASE_STRIP = NO;
1396+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1397+
DEVELOPMENT_TEAM = R63EM248DP;
1398+
GCC_C_LANGUAGE_STANDARD = gnu11;
1399+
INFOPLIST_FILE = "Branch-SDK-Unhosted-Tests/Info.plist";
1400+
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
1401+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1402+
MTL_ENABLE_DEBUG_INFO = NO;
1403+
MTL_FAST_MATH = YES;
1404+
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.Branch-SDK-Unhosted-Tests";
1405+
PRODUCT_NAME = "$(TARGET_NAME)";
1406+
TARGETED_DEVICE_FAMILY = "1,2";
1407+
};
1408+
name = Release;
1409+
};
12901410
670016901940F51400A9E103 /* Debug */ = {
12911411
isa = XCBuildConfiguration;
12921412
buildSettings = {
@@ -1417,7 +1537,7 @@
14171537
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed";
14181538
PRODUCT_NAME = "$(TARGET_NAME)";
14191539
PROVISIONING_PROFILE = "";
1420-
USER_HEADER_SEARCH_PATHS = "$PROJECT_DIR";
1540+
USER_HEADER_SEARCH_PATHS = $PROJECT_DIR;
14211541
WRAPPER_EXTENSION = app;
14221542
};
14231543
name = Debug;
@@ -1438,7 +1558,7 @@
14381558
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed";
14391559
PRODUCT_NAME = "$(TARGET_NAME)";
14401560
PROVISIONING_PROFILE = "";
1441-
USER_HEADER_SEARCH_PATHS = "$PROJECT_DIR";
1561+
USER_HEADER_SEARCH_PATHS = $PROJECT_DIR;
14421562
WRAPPER_EXTENSION = app;
14431563
};
14441564
name = Release;
@@ -1535,6 +1655,15 @@
15351655
defaultConfigurationIsVisible = 0;
15361656
defaultConfigurationName = Release;
15371657
};
1658+
5F8B7B4521B5F5CD009CE0A6 /* Build configuration list for PBXNativeTarget "Branch-SDK-Unhosted-Tests" */ = {
1659+
isa = XCConfigurationList;
1660+
buildConfigurations = (
1661+
5F8B7B4321B5F5CD009CE0A6 /* Debug */,
1662+
5F8B7B4421B5F5CD009CE0A6 /* Release */,
1663+
);
1664+
defaultConfigurationIsVisible = 0;
1665+
defaultConfigurationName = Release;
1666+
};
15381667
6700165B1940F51400A9E103 /* Build configuration list for PBXProject "Branch-TestBed" */ = {
15391668
isa = XCConfigurationList;
15401669
buildConfigurations = (
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1010"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
</BuildAction>
9+
<TestAction
10+
buildConfiguration = "Debug"
11+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13+
shouldUseLaunchSchemeArgsEnv = "YES">
14+
<Testables>
15+
<TestableReference
16+
skipped = "NO">
17+
<BuildableReference
18+
BuildableIdentifier = "primary"
19+
BlueprintIdentifier = "5F8B7B3A21B5F5CD009CE0A6"
20+
BuildableName = "Branch-SDK-Unhosted-Tests.xctest"
21+
BlueprintName = "Branch-SDK-Unhosted-Tests"
22+
ReferencedContainer = "container:Branch-TestBed.xcodeproj">
23+
</BuildableReference>
24+
</TestableReference>
25+
</Testables>
26+
<AdditionalOptions>
27+
</AdditionalOptions>
28+
</TestAction>
29+
<LaunchAction
30+
buildConfiguration = "Debug"
31+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
32+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
33+
launchStyle = "0"
34+
useCustomWorkingDirectory = "NO"
35+
ignoresPersistentStateOnLaunch = "NO"
36+
debugDocumentVersioning = "YES"
37+
debugServiceExtension = "internal"
38+
allowLocationSimulation = "YES">
39+
<AdditionalOptions>
40+
</AdditionalOptions>
41+
</LaunchAction>
42+
<ProfileAction
43+
buildConfiguration = "Release"
44+
shouldUseLaunchSchemeArgsEnv = "YES"
45+
savedToolIdentifier = ""
46+
useCustomWorkingDirectory = "NO"
47+
debugDocumentVersioning = "YES">
48+
</ProfileAction>
49+
<AnalyzeAction
50+
buildConfiguration = "Debug">
51+
</AnalyzeAction>
52+
<ArchiveAction
53+
buildConfiguration = "Release"
54+
revealArchiveInOrganizer = "YES">
55+
</ArchiveAction>
56+
</Scheme>

0 commit comments

Comments
 (0)