Skip to content

Commit a26fc96

Browse files
authored
Add a test to make sure ProcessInfo can deliver the correct thermal state and power state on all platforms (#905)
1 parent 660f795 commit a26fc96

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Tests/FoundationEssentialsTests/ProcessInfoTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,20 @@ final class ProcessInfoTests : XCTestCase {
200200
XCTAssertNil(env[""])
201201
}
202202
}
203+
204+
// MARK: - ThermalState and PowerState tests
205+
#if FOUNDATION_FRAMEWORK
206+
extension ProcessInfoTests {
207+
func testThermalPowerState() {
208+
// This test simply makes sure we can deliver the correct
209+
// thermal and power state for all platforms.
210+
// Fake a new value
211+
_NSSwiftProcessInfo._globalState.withLock {
212+
$0.thermalState = .critical
213+
$0.powerState = .restricted
214+
}
215+
XCTAssertEqual(ProcessInfo.processInfo.thermalState, .critical)
216+
XCTAssertEqual(ProcessInfo.processInfo.isLowPowerModeEnabled, true)
217+
}
218+
}
219+
#endif // FOUDATION_FRAMEWORK

0 commit comments

Comments
 (0)