Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243import Foundationimport Testing
@testable import ParcelRealityTests
struct TabViewConsoleSessionTests { @Test(arguments: [false, true]) func lockedConsoleRefusesInput(onConsole: Bool) { let session = TabViewConsoleSession(onConsole: onConsole, loginDone: true, screenLocked: true) #expect(throws: RealityError.self) { try session.requireUnlocked() } }
@Test(arguments: [Bool?.none, .some(false)]) func unlockedConsoleAcceptsTheOptionalLockMarker(screenLocked: Bool?) throws { try TabViewConsoleSession(onConsole: true, loginDone: true, screenLocked: screenLocked).requireUnlocked() }
@Test(arguments: [(false, true), (true, false), (false, false)]) func incompleteSessionRefusesInput(state: (Bool, Bool)) { let session = TabViewConsoleSession(onConsole: state.0, loginDone: state.1, screenLocked: false) #expect(throws: RealityError.self) { try session.requireUnlocked() } }
@Test(arguments: [(false, true, false), (true, false, false), (true, true, true)]) func unsafeConsoleFailuresStopTheLane(state: (Bool, Bool, Bool)) throws { let session = TabViewConsoleSession(onConsole: state.0, loginDone: state.1, screenLocked: state.2) do { try session.requireUnlocked() Issue.record("Unsafe console was accepted") } catch let error as RealityError { #expect(error.description.hasPrefix("Safety stop:")) } }
@Test func nativeKeysDecodeTheLockRatherThanAssumingAnUnlockedSession() throws { let data = Data( "{\"kCGSSessionOnConsoleKey\":true,\"kCGSessionLoginDoneKey\":true,\"CGSSessionScreenIsLocked\":true}".utf8) let session = try JSONDecoder().decode(TabViewConsoleSession.self, from: data) #expect(session.onConsole && session.loginDone && session.screenLocked == true) #expect(throws: RealityError.self) { try session.requireUnlocked() } }}