Skip to content

Commit 5ac8bf1

Browse files
authored
Merge pull request #339 from Countly/fix-ios-sdk
Added iOS sdk missing changes
2 parents 06a5083 + c4baabc commit 5ac8bf1

File tree

7 files changed

+295
-5
lines changed

7 files changed

+295
-5
lines changed

ios/src/Countly.xcodeproj/project.pbxproj

Lines changed: 178 additions & 3 deletions
Large diffs are not rendered by default.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// CountlyBaseTestCase.swift
3+
// CountlyTests
4+
//
5+
// Created by Muhammad Junaid Akram on 27/12/2023.
6+
// Copyright © 2023 Alin Radut. All rights reserved.
7+
//
8+
9+
import XCTest
10+
@testable import Countly
11+
12+
class CountlyBaseTestCase: XCTestCase {
13+
var countly: Countly!
14+
var deviceID: String = ""
15+
let appKey: String = "appkey"
16+
var host: String = "https://test.count.ly/"
17+
18+
override func setUpWithError() throws {
19+
// Put setup code here. This method is called before the invocation of each test method in the class.
20+
cleanupState()
21+
}
22+
23+
func createBaseConfig() -> CountlyConfig {
24+
let config: CountlyConfig = CountlyConfig()
25+
config.appKey = appKey
26+
config.host = host
27+
config.enableDebug = true
28+
config.features = [CLYFeature.crashReporting];
29+
return config
30+
}
31+
32+
override func tearDownWithError() throws {
33+
// Put teardown code here. This method is called after the invocation of each test method in the class.
34+
}
35+
36+
func cleanupState() {
37+
Countly.sharedInstance().halt(true)
38+
}
39+
40+
}
41+
42+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import "CountlyCommon.h"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// CountlyTests.swift
3+
// CountlyTests
4+
//
5+
// Created by Muhammad Junaid Akram on 22/12/2023.
6+
// Copyright © 2023 Alin Radut. All rights reserved.
7+
//
8+
9+
import XCTest
10+
@testable import Countly
11+
12+
13+
class CountlyTests: CountlyBaseTestCase {
14+
15+
// MARK: - Configuration Tests
16+
17+
func testReInitWithDeviceId() throws {
18+
let config = createBaseConfig()
19+
// No Device ID provided during init
20+
Countly.sharedInstance().start(with: config);
21+
22+
let sdkGeneratedDeviceID = Countly.sharedInstance().deviceID()
23+
XCTAssertTrue(CountlyCommon.sharedInstance().hasStarted, "Countly initialization failed.")
24+
XCTAssertTrue(Countly.sharedInstance().deviceIDType() == CLYDeviceIDType.IDFV, "Countly deviced id type should be IDFV when no device id is provided during init.")
25+
Countly.sharedInstance().halt(false)
26+
XCTAssertTrue(!CountlyCommon.sharedInstance().hasStarted, "Countly halt failed.")
27+
28+
let deviceID = String(Int.random(in: 0..<100))
29+
30+
let newConfig = createBaseConfig()
31+
newConfig.deviceID = deviceID
32+
Countly.sharedInstance().start(with: newConfig);
33+
34+
XCTAssertTrue(CountlyCommon.sharedInstance().hasStarted, "Countly initialization failed.")
35+
XCTAssertTrue(Countly.sharedInstance().deviceID() == sdkGeneratedDeviceID, "Countly device id not match with provided device id.")
36+
XCTAssertTrue(Countly.sharedInstance().deviceIDType() == CLYDeviceIDType.IDFV, "Countly deviced id type should be custom when device id is provided during init.")
37+
}
38+
39+
func testPerformanceExample() async throws {
40+
// This is an example of a performance test case.
41+
measure {
42+
// Put the code you want to measure the time of here.
43+
}
44+
}
45+
46+
47+
func checkPersistentValues() {
48+
let countlyPersistency = CountlyPersistency.sharedInstance()
49+
if(countlyPersistency != nil) {
50+
if let queuedRequests = CountlyPersistency.sharedInstance().value(forKey: "queuedRequests") as? NSMutableArray,
51+
let recordedEvents = CountlyPersistency.sharedInstance().value(forKey: "recordedEvents") as? NSMutableArray,
52+
let startedEvents = CountlyPersistency.sharedInstance().value(forKey: "startedEvents") as? NSMutableDictionary,
53+
let isQueueBeingModified = CountlyPersistency.sharedInstance().value(forKey: "isQueueBeingModified") as? Bool {
54+
print("Successfully access private properties.")
55+
56+
57+
}
58+
else {
59+
print("Failed to access private properties.")
60+
}
61+
}
62+
63+
}
64+
}
65+
66+
67+

ios/src/Package.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ let package = Package(
3333
"Info.plist",
3434
"Countly.podspec",
3535
"Countly-PL.podspec",
36-
"LICENSE.md",
36+
"LICENSE",
3737
"README.md",
3838
"countly_dsym_uploader.sh",
3939
"CHANGELOG.md",
40-
"SECURITY.md"
40+
"SECURITY.md",
41+
"CountlyTests/"
4142
],
4243

4344
linkerSettings:
@@ -53,5 +54,9 @@ let package = Package(
5354
.linkedFramework("WebKit", .when(platforms: [.iOS])),
5455
.linkedFramework("CoreTelephony", .when(platforms: [.iOS])),
5556
]),
57+
.testTarget(
58+
name: "CountlyTests",
59+
dependencies: ["Countly"]
60+
),
5661
]
5762
)

ios/src/include/CountlySDKLimitsConfig.h

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CountlySDKLimitsConfig.h

ios/src/include/Resettable.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

ios/src/include/Resettable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../Resettable.h

0 commit comments

Comments
 (0)