Skip to content

Commit 853000a

Browse files
committed
Add tests
1 parent da8ae24 commit 853000a

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,7 @@
11041104
FA94E7242E6F339400576666 /* SentryEnvelopeItemType.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */; };
11051105
FAA414532ED7615D00B269CD /* SentrySessionReplayHybridSDK.m in Sources */ = {isa = PBXBuildFile; fileRef = FAA414502ED7608E00B269CD /* SentrySessionReplayHybridSDK.m */; };
11061106
FAA414542ED7616800B269CD /* SentrySessionReplayHybridSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = D80382BE2C09C6FD0090E048 /* SentrySessionReplayHybridSDK.h */; settings = {ATTRIBUTES = (Private, ); }; };
1107+
FAA415552ED7CE7300B269CD /* UserFeedbackIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAA4154F2ED7CE6A00B269CD /* UserFeedbackIntegrationTests.swift */; };
11071108
FAAB29F12E3D252300ACD577 /* SentrySession.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB29F02E3D252000ACD577 /* SentrySession.swift */; };
11081109
FAAB2EE02E4BE97500FE8B7E /* TestSentryNSApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */; };
11091110
FAAB2F972E4D345800FE8B7E /* SentryUIDeviceWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB2F962E4D344F00FE8B7E /* SentryUIDeviceWrapper.swift */; };
@@ -2486,6 +2487,7 @@
24862487
FA94E6B12E6D265500576666 /* SentryEnvelope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelope.swift; sourceTree = "<group>"; };
24872488
FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeItemType.swift; sourceTree = "<group>"; };
24882489
FAA414502ED7608E00B269CD /* SentrySessionReplayHybridSDK.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentrySessionReplayHybridSDK.m; sourceTree = "<group>"; };
2490+
FAA4154F2ED7CE6A00B269CD /* UserFeedbackIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserFeedbackIntegrationTests.swift; sourceTree = "<group>"; };
24892491
FAAB29F02E3D252000ACD577 /* SentrySession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySession.swift; sourceTree = "<group>"; };
24902492
FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryNSApplication.swift; sourceTree = "<group>"; };
24912493
FAAB2F962E4D344F00FE8B7E /* SentryUIDeviceWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIDeviceWrapper.swift; sourceTree = "<group>"; };
@@ -4045,6 +4047,7 @@
40454047
843FB3422D156B9900558F18 /* Feedback */ = {
40464048
isa = PBXGroup;
40474049
children = (
4050+
FAA4154F2ED7CE6A00B269CD /* UserFeedbackIntegrationTests.swift */,
40484051
843FB3412D156B9900558F18 /* SentryFeedbackTests.swift */,
40494052
);
40504053
path = Feedback;
@@ -6391,6 +6394,7 @@
63916394
7BC6EBF8255C05060059822A /* TestData.swift in Sources */,
63926395
92235CB02E155B2600865983 /* SentryLoggerTests.swift in Sources */,
63936396
7B88F30224BC5C6D00ADF90A /* SentrySdkInfoTests.swift in Sources */,
6397+
FAA415552ED7CE7300B269CD /* UserFeedbackIntegrationTests.swift in Sources */,
63946398
7BC8523B2458849E005A70F0 /* SentryDataCategoryMapperTests.swift in Sources */,
63956399
63FE721220DA66EC00CDBAE8 /* SentryCrashMach_Tests.m in Sources */,
63966400
0A94158228F6C4C2006A5DD1 /* SentryAppStateManagerTests.swift in Sources */,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@_spi(Private) @testable import Sentry
2+
import XCTest
3+
4+
#if os(iOS)
5+
6+
final class UserFeedbackIntegrationTests: XCTestCase {
7+
8+
static private var optionsWithFeedback: Options {
9+
let options = Options()
10+
options.configureUserFeedback = { _ in }
11+
return options
12+
}
13+
14+
static private var optionsWithoutFeedback: Options {
15+
return Options()
16+
}
17+
18+
static private var screenshotSource: SentryScreenshotSource {
19+
let viewRenderer = SentryDefaultViewRenderer()
20+
let photographer = SentryViewPhotographer(
21+
renderer: viewRenderer,
22+
redactOptions: Options().screenshot,
23+
enableMaskRendererV2: false)
24+
return SentryScreenshotSource(photographer: photographer)
25+
}
26+
27+
private struct MockDependencies: ScreenshotSourceProvider {
28+
let screenshotSource: SentryScreenshotSource?
29+
}
30+
31+
func testUsesCorrectName() {
32+
XCTAssertEqual(UserFeedbackIntegration<MockDependencies>.name, "SentryUserFeedbackIntegration")
33+
}
34+
35+
func testInitializerFailsWhenNoScreenshotSource() {
36+
let integration = UserFeedbackIntegration(with: Self.optionsWithFeedback, dependencies: MockDependencies(screenshotSource: nil))
37+
XCTAssertNil(integration)
38+
}
39+
40+
func testInitializerSucceedsWhenScreenshotSourceIsPresent() {
41+
let integration = UserFeedbackIntegration(with: Self.optionsWithFeedback, dependencies: MockDependencies(screenshotSource: Self.screenshotSource))
42+
XCTAssertNotNil(integration)
43+
}
44+
45+
func testInitializerFailsWhenFeedbackNotConfigured() {
46+
let integration = UserFeedbackIntegration(with: Self.optionsWithoutFeedback, dependencies: MockDependencies(screenshotSource: nil))
47+
XCTAssertNil(integration)
48+
}
49+
}
50+
51+
#endif

0 commit comments

Comments
 (0)