Skip to content

Commit a908201

Browse files
committed
Refactored iOS Test app for SPM
1 parent 7ec6bbc commit a908201

File tree

38 files changed

+477
-135
lines changed

38 files changed

+477
-135
lines changed

SDKIntegrationTestApps/Source/TestObserver.swift renamed to SDKIntegrationTestApps/Source/IntegrationTests/TestObserver.swift

File renamed without changes.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// iOSReleaseTestTests.swift
3+
// iOSReleaseTestTests
4+
//
5+
// Created by Nidhi Dixit on 1/15/23.
6+
//
7+
8+
import XCTest
9+
@testable import iOSReleaseTest
10+
@testable import BranchSDK
11+
12+
final class iOSReleaseTestTests: XCTestCase {
13+
14+
private static var testObserver: TestObserver?
15+
16+
override class func setUp() {
17+
super.setUp()
18+
testObserver = TestObserver()
19+
XCTestObservationCenter.shared.addTestObserver(testObserver!)
20+
print("[TestSetup] Test observer registered for enhanced GitHub Actions logging")
21+
}
22+
23+
override class func tearDown() {
24+
if let observer = testObserver {
25+
XCTestObservationCenter.shared.removeTestObserver(observer)
26+
testObserver = nil
27+
}
28+
super.tearDown()
29+
}
30+
31+
override func setUpWithError() throws {
32+
print("[Setup] Setting up test: \(self.name)")
33+
}
34+
35+
override func tearDownWithError() throws {
36+
print("[Teardown] Cleaning up test: \(self.name)")
37+
}
38+
39+
func testDummy() throws {
40+
print("[Test] Running dummy test")
41+
XCTAssertTrue(true, "Dummy test should always pass")
42+
print("[Test] Dummy test completed")
43+
}
44+
45+
func testSetTrackingDisabled() throws {
46+
print("[Test] Starting testSetTrackingDisabled")
47+
48+
let expectation = expectation(description: "InitSession should complete.")
49+
50+
let sdk = BranchSDKTest(){ params, error in
51+
print(params as? [String: AnyObject] ?? {})
52+
expectation.fulfill()
53+
}
54+
print("Setting CPP Level to none.")
55+
sdk.setCPPLevel(status: BranchAttributionLevel.none)
56+
57+
let cppLevel = BNCPreferenceHelper.sharedInstance().attributionLevel
58+
print("[Test] CPP Level: \(String(describing: cppLevel))")
59+
60+
XCTAssertTrue(cppLevel!.isEqual(to: BranchAttributionLevel.none.rawValue) , "Tracking should be disabled (true)")
61+
62+
print("[Test] Disabling tracking again...")
63+
sdk.setCPPLevel(status: BranchAttributionLevel.full)
64+
65+
waitForExpectations(timeout: 30, handler: nil)
66+
print("[Test] testSetTrackingDisabled completed")
67+
}
68+
69+
}

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/AppDelegate.swift renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/AppDelegate.swift

File renamed without changes.

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/Assets.xcassets/AccentColor.colorset/Contents.json renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/Assets.xcassets/AccentColor.colorset/Contents.json

File renamed without changes.

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/Assets.xcassets/AppIcon.appiconset/Contents.json renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/Assets.xcassets/AppIcon.appiconset/Contents.json

File renamed without changes.

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/Assets.xcassets/Contents.json renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/Assets.xcassets/Contents.json

File renamed without changes.

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/Base.lproj/LaunchScreen.storyboard renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/Base.lproj/LaunchScreen.storyboard

File renamed without changes.

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/Base.lproj/Main.storyboard renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/Base.lproj/Main.storyboard

File renamed without changes.

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/BranchSDKTest.swift renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/BranchSDKTest.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ import BranchSDK
1111
class BranchSDKTest {
1212

1313
init(callback: @escaping ([AnyHashable: Any]?, Error?) -> Void) {
14-
// Branch.getInstance().enableLogging()
15-
// Branch.getInstance().initSession(launchOptions: nil, callback: callback)
1614
Branch.getInstance().initSession(launchOptions:nil, andRegisterDeepLinkHandler: callback)
1715
}
1816

19-
func disableTracking( status: Bool) {
20-
Branch.setTrackingDisabled(status)
21-
}
22-
23-
func trackingStatus() -> Bool {
24-
return Branch.trackingDisabled()
17+
func setCPPLevel( status: BranchAttributionLevel) {
18+
Branch.getInstance().setConsumerProtectionAttributionLevel(BranchAttributionLevel.full)
2519
}
2620
}

SDKIntegrationTestApps/iOSReleaseTest-SPM/iOSReleaseTest/Info.plist renamed to SDKIntegrationTestApps/Source/iOSReleaseTest/Info.plist

File renamed without changes.

0 commit comments

Comments
 (0)