-
-
Notifications
You must be signed in to change notification settings - Fork 333
/
TestSentrySystemWrapper.swift
38 lines (31 loc) · 1.19 KB
/
TestSentrySystemWrapper.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Sentry
public class TestSentrySystemWrapper: SentrySystemWrapper {
public struct Override {
public var memoryFootprintError: NSError?
public var memoryFootprintBytes: SentryRAMBytes?
public var cpuUsageError: NSError?
public var cpuUsage: NSNumber?
public var cpuEnergyUsageError: NSError?
public var cpuEnergyUsage: NSNumber?
}
public var overrides = Override()
public override func memoryFootprintBytes(_ error: NSErrorPointer) -> SentryRAMBytes {
if let errorOverride = overrides.memoryFootprintError {
error?.pointee = errorOverride
return 0
}
return overrides.memoryFootprintBytes ?? super.memoryFootprintBytes(error)
}
public override func cpuUsage() throws -> NSNumber {
if let errorOverride = overrides.cpuUsageError {
throw errorOverride
}
return try overrides.cpuUsage ?? super.cpuUsage()
}
public override func cpuEnergyUsage() throws -> NSNumber {
if let errorOverride = overrides.cpuEnergyUsageError {
throw errorOverride
}
return try overrides.cpuEnergyUsage ?? super.cpuEnergyUsage()
}
}