Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import Foundationimport RealityDriverSupportimport Testing
struct DriverWindowSelectionTests { @Test(arguments: [0, 1, 2]) func auxiliaryWindowsDoNotCreateAStandardWindowAmbiguity(index: Int) throws { var candidates = [ DriverWindowRole(windowID: 2, role: "AXHelpTag", subrole: "AXUnknown"), DriverWindowRole(windowID: 3, role: "AXWindow", subrole: "AXFloatingWindow"), ] candidates.insert(DriverWindowRole(windowID: 1, role: "AXWindow", subrole: "AXStandardWindow"), at: index) #expect(try DriverWindowSelection.standardWindowIDs(candidates) == [1]) }
@Test func twoStandardWindowsRemainAmbiguous() throws { let candidates = [ DriverWindowRole(windowID: 2, role: "AXWindow", subrole: "AXStandardWindow"), DriverWindowRole(windowID: 1, role: "AXWindow", subrole: "AXStandardWindow"), ] #expect(try DriverWindowSelection.standardWindowIDs(candidates) == [1, 2]) }
@Test(arguments: [UInt32(0), 1]) func invalidOrDuplicateStandardIdentitiesFail(windowID: UInt32) { let candidate = DriverWindowRole(windowID: windowID, role: "AXWindow", subrole: "AXStandardWindow") #expect(throws: DriverError.self) { try DriverWindowSelection.standardWindowIDs([candidate, candidate]) } }
@Test func noStandardWindowIsNotReplacedWithAnAuxiliaryWindow() throws { #expect(try DriverWindowSelection.standardWindowIDs([]).isEmpty) #expect( try DriverWindowSelection.standardWindowIDs([ DriverWindowRole(windowID: 1, role: "AXWindow", subrole: "AXDialog") ]).isEmpty) }
@Test(arguments: [ DriverCommand.standardWindows(pid: 0, candidates: [1]), .standardWindows(pid: 1, candidates: []), .standardWindows(pid: 1, candidates: [0]), .standardWindows(pid: 1, candidates: [1, 1]), .standardWindows(pid: 1, candidates: Array(1...65)), ]) func roleProbeRequiresABoundedUniqueIdentitySet(command: DriverCommand) { #expect(throws: DriverError.self) { try command.validate() } }
@Test func unrelatedUnsupportedElementsDoNotHideTheOwnedWindow() throws { let selection = try DriverWindowSelection.select( windowID: 42, candidates: [.unsupported("window identification unsupported"), .identified(12), .identified(42)]) #expect(selection.index == 2) #expect(selection.warnings == ["AX candidate 0: window identification unsupported"]) let response = DriverResponse(id: 1, identificationWarnings: selection.warnings) #expect(try JSONDecoder().decode(DriverResponse.self, from: JSONEncoder().encode(response)) == response) }
@Test func duplicateIdentityIsNeverResolvedByOrder() { #expect(throws: DriverError.self) { try DriverWindowSelection.select(windowID: 42, candidates: [.identified(42), .identified(42)]) } }
@Test(arguments: [[DriverWindowIdentity](), [.identified(12)], [.unsupported("unsupported")]]) func absentTargetRemainsAnExplicitFailure(_ candidates: [DriverWindowIdentity]) { #expect(throws: DriverError.self) { try DriverWindowSelection.select(windowID: 42, candidates: candidates) } }
@Test func zeroTargetIsRejected() { #expect(throws: DriverError.self) { try DriverWindowSelection.select(windowID: 0, candidates: [.identified(0)]) } }}