Skip to content

Commit

Permalink
fix more conditional compilation for UIKit
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed Aug 29, 2023
1 parent 01292d2 commit bc99782
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@class SentrySwizzleWrapper;
@class SentrySystemWrapper;
@class SentryThreadWrapper;
@class SentryUIDeviceWrapper;
@protocol SentryRandom;

#if SENTRY_HAS_METRIC_KIT
Expand All @@ -26,6 +25,7 @@
@class SentryFramesTracker;
@class SentryScreenshot;
@class SentryUIApplication;
@class SentryUIDeviceWrapper;
@class SentryViewHierarchy;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ final class SentryExtraContextProviderTests: XCTestCase {

private class Fixture {
let crashWrapper = TestSentryCrashWrapper.sharedInstance()
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
let deviceWrapper = TestSentryUIDeviceWrapper()
#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
let processWrapper = TestSentryNSProcessInfoWrapper()

func getSut() -> SentryExtraContextProvider {
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
SentryDependencyContainer.sharedInstance().uiDeviceWrapper = deviceWrapper
#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
return SentryExtraContextProvider(
crashWrapper: crashWrapper,
processInfoWrapper: processWrapper)
Expand Down
4 changes: 4 additions & 0 deletions Tests/SentryTests/SentryClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class SentryClientTest: XCTestCase {
let trace = SentryTracer(transactionContext: TransactionContext(name: "SomeTransaction", operation: "SomeOperation"), hub: nil)
let transaction: Transaction
let crashWrapper = TestSentryCrashWrapper.sharedInstance()
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
let deviceWrapper = TestSentryUIDeviceWrapper()
#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
let processWrapper = TestSentryNSProcessInfoWrapper()
let extraContentProvider: SentryExtraContextProvider
let locale = Locale(identifier: "en_US")
Expand Down Expand Up @@ -63,7 +65,9 @@ class SentryClientTest: XCTestCase {
crashWrapper.internalAppMemorySize = 234_567
crashWrapper.internalFreeStorageSize = 345_678

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
SentryDependencyContainer.sharedInstance().uiDeviceWrapper = deviceWrapper
#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)

extraContentProvider = SentryExtraContextProvider(crashWrapper: crashWrapper, processInfoWrapper: processWrapper)
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/SentryTests/SentryCrash/TestSentryUIDeviceWrapper.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Sentry

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
class TestSentryUIDeviceWrapper: SentryUIDeviceWrapper {
#if os(iOS)
var internalOrientation = UIDeviceOrientation.portrait
var internalIsBatteryMonitoringEnabled = true
var internalBatteryLevel: Float = 0.6
Expand All @@ -22,5 +22,5 @@ class TestSentryUIDeviceWrapper: SentryUIDeviceWrapper {
override func batteryState() -> UIDevice.BatteryState {
return internalBatteryState
}
#endif
}
#endif // os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)

0 comments on commit bc99782

Please sign in to comment.