Function bodies 25 total
ComputerUseSwift class · ruby · L1-L72 (72 LOC)Formula/computer-use-swift.rb
class ComputerUseSwift < Formula
desc "macOS computer use capabilities CLI — screenshots, input simulation, app management"
homepage "https://github.com/dnakov/computer-use"
url "https://github.com/dnakov/computer-use/archive/refs/tags/v0.1.0.tar.gz"
sha256 "TODO_REPLACE_WITH_ACTUAL_SHA256"
license "MIT"
depends_on :macos => :sonoma
depends_on xcode: ["15.0", :build]
def install
system "swift", "build",
"-c", "release",
"--arch", "arm64",
"--arch", "x86_64",
"--disable-sandbox"
release_dir = ".build/apple/Products/Release"
bin.install "#{release_dir}/computer-use"
# Build and install the teach overlay helper app
system "swift", "build",
"-c", "release",
"--arch", "arm64",
"--arch", "x86_64",
"--disable-sandbox",
"--product", "teach-overlay"
# Create TeachOverlay.app bundle
app_dir = libexec/"TeachOverlay.app/Contents"
(app_dir/"MacOS").install method · ruby · L11-L52 (42 LOC)Formula/computer-use-swift.rb
def install
system "swift", "build",
"-c", "release",
"--arch", "arm64",
"--arch", "x86_64",
"--disable-sandbox"
release_dir = ".build/apple/Products/Release"
bin.install "#{release_dir}/computer-use"
# Build and install the teach overlay helper app
system "swift", "build",
"-c", "release",
"--arch", "arm64",
"--arch", "x86_64",
"--disable-sandbox",
"--product", "teach-overlay"
# Create TeachOverlay.app bundle
app_dir = libexec/"TeachOverlay.app/Contents"
(app_dir/"MacOS").mkpath
cp "#{release_dir}/teach-overlay", app_dir/"MacOS/teach-overlay"
(app_dir/"Info.plist").write <<~PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key><string>teach-overlay</string>
caveats method · ruby · L54-L64 (11 LOC)Formula/computer-use-swift.rb
def caveats
<<~EOS
computer-use requires macOS permissions to function:
- Accessibility (for input simulation)
- Screen Recording (for screenshots)
Grant these in System Settings → Privacy & Security.
To verify: computer-use tcc check-accessibility
EOS
endAuthPresentationContextProvider class · swift · L6-L20 (15 LOC)Sources/ComputerUseSwift/Auth/AuthRequest.swift
class AuthPresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
if let window = NSApp?.keyWindow {
return window
}
// For CLI or headless contexts, create a minimal window as anchor
let window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 1, height: 1),
styleMask: [],
backing: .buffered,
defer: false
)
return window
}
}AuthRequest class · swift · L24-L104 (81 LOC)Sources/ComputerUseSwift/Auth/AuthRequest.swift
public class AuthRequest {
private var session: ASWebAuthenticationSession?
private let contextProvider = AuthPresentationContextProvider()
public init() {}
/// Check if ASWebAuthenticationSession is available (always true on macOS 14+).
public static func isAvailable() -> Bool {
return true
}
/// Start an authentication session.
///
/// - Parameters:
/// - url: The authorization URL to open.
/// - callbackUrlScheme: The URL scheme for the callback.
/// - Returns: An `AuthResult` with either a callback URL or an error message.
public func start(url: String, callbackUrlScheme: String) async throws -> AuthResult {
guard session == nil else {
throw AuthError.alreadyInProgress
}
guard let authURL = URL(string: url) else {
throw AuthError.invalidURL
}
return try await withCheckedThrowingContinuation { continuation in
let webAuthSession = ASWebAutheTeachController class · swift · L55-L353 (299 LOC)Sources/ComputerUseSwift/Teach/GuideOverlay.swift
private class TeachController: NSObject, WKScriptMessageHandler, WKNavigationDelegate {
let steps: [TeachStep]
var results: [TeachOverlayRunner.StepResult] = []
var currentStep = 0
var isDone = false
private var panel: NSPanel?
private var webView: WKWebView?
private var htmlFileURL: URL?
private var webViewReady = false
init(steps: [TeachStep]) {
self.steps = steps
super.init()
}
func setup() {
// Write HTML to temp file
let tmpDir = FileManager.default.temporaryDirectory
let htmlURL = tmpDir.appendingPathComponent("cu-teach-\(ProcessInfo.processInfo.processIdentifier).html")
try? Self.overlayHTML.write(to: htmlURL, atomically: true, encoding: .utf8)
self.htmlFileURL = htmlURL
// Create WKWebView
let config = WKWebViewConfiguration()
let uc = WKUserContentController()
uc.add(self, name: "cuTeach")
config.userContentController = uc
letAppDelegate class · swift · L65-L350 (286 LOC)Sources/TeachOverlayApp/main.swift
class AppDelegate: NSObject, NSApplicationDelegate, WKScriptMessageHandler {
let steps: [StepInput]
var results: [StepResult] = []
var currentStep = 0
var panel: NSPanel!
var webView: WKWebView!
var htmlURL: URL?
init(steps: [StepInput]) {
self.steps = steps
super.init()
}
func applicationDidFinishLaunching(_ notification: Notification) {
// Write HTML to temp
let tmp = FileManager.default.temporaryDirectory
let url = tmp.appendingPathComponent("cu-teach-\(ProcessInfo.processInfo.processIdentifier).html")
try? Self.html.write(to: url, atomically: true, encoding: .utf8)
htmlURL = url
// WKWebView
let config = WKWebViewConfiguration()
let uc = WKUserContentController()
uc.add(self, name: "cuTeach")
config.userContentController = uc
let size = NSSize(width: 440, height: 340)
webView = WKWebView(frame: NSRect(origin: .zero, size: size), conRepobility · open methodology · https://repobility.com/research/
AppClassificationTests class · swift · L4-L141 (138 LOC)Tests/ComputerUseSwiftTests/AppClassificationTests.swift
final class AppClassificationTests: XCTestCase {
// MARK: - classify() by bundle ID
func testSafariClassifiedAsBrowser() {
let result = AppClassification.classify(bundleId: "com.apple.Safari", displayName: nil)
XCTAssertEqual(result, .browser)
}
func testChromeClassifiedAsBrowser() {
let result = AppClassification.classify(bundleId: "com.google.Chrome", displayName: nil)
XCTAssertEqual(result, .browser)
}
func testTerminalClassifiedAsTerminal() {
let result = AppClassification.classify(bundleId: "com.apple.Terminal", displayName: nil)
XCTAssertEqual(result, .terminal)
}
func testVSCodeClassifiedAsTerminal() {
let result = AppClassification.classify(bundleId: "com.microsoft.VSCode", displayName: nil)
XCTAssertEqual(result, .terminal)
}
func testJetBrainsIntelliJClassifiedAsTerminal() {
let result = AppClassification.classify(bundleId: "com.jetbrains.intellij", displayNamAuthErrorTests class · swift · L4-L33 (30 LOC)Tests/ComputerUseSwiftTests/AuthErrorTests.swift
final class AuthErrorTests: XCTestCase {
func testAlreadyInProgress() {
let error = AuthError.alreadyInProgress
XCTAssertEqual(error.errorDescription, "Authentication already in progress")
}
func testInvalidURL() {
let error = AuthError.invalidURL
XCTAssertEqual(error.errorDescription, "Invalid URL")
}
func testFailedToStart() {
let error = AuthError.failedToStart
XCTAssertEqual(
error.errorDescription,
"Failed to start authentication session"
)
}
func testTimeout() {
let error = AuthError.timeout
XCTAssertEqual(error.errorDescription, "Authentication timeout")
}
func testCancelled() {
let error = AuthError.cancelled
XCTAssertEqual(error.errorDescription, "Authentication cancelled")
}
}ConstantsTests class · swift · L4-L91 (88 LOC)Tests/ComputerUseSwiftTests/ConstantsTests.swift
final class ConstantsTests: XCTestCase {
// MARK: - SystemApps.defocusSystemApps
func testDefocusSystemAppsCount() {
XCTAssertEqual(SystemApps.defocusSystemApps.count, 8)
}
func testDefocusSystemAppsContainsAllEntries() {
let expected: Set<String> = [
"Window Server",
"SystemUIServer",
"Dock",
"Spotlight",
"Control Center",
"com.apple.screencaptureui",
"Screenshot",
"screencaptureui",
]
XCTAssertEqual(SystemApps.defocusSystemApps, expected)
}
func testDefocusSystemAppsContainsWindowServer() {
XCTAssertTrue(SystemApps.defocusSystemApps.contains("Window Server"))
}
func testDefocusSystemAppsContainsSystemUIServer() {
XCTAssertTrue(SystemApps.defocusSystemApps.contains("SystemUIServer"))
}
func testDefocusSystemAppsContainsDock() {
XCTAssertTrue(SystemApps.defocusSystemApps.contains("Dock"))
CoordinateConverterTests class · swift · L4-L118 (115 LOC)Tests/ComputerUseSwiftTests/CoordinateConverterTests.swift
final class CoordinateConverterTests: XCTestCase {
// MARK: - imagePixelsToScreen
func testImagePixelToScreenIdentity() {
// Screenshot size == display size, no origin offset
let pt = CoordinateConverter.imagePixelsToScreen(
pixelX: 100, pixelY: 200,
screenshotWidth: 1920, screenshotHeight: 1080,
displayWidth: 1920, displayHeight: 1080,
originX: 0, originY: 0
)
XCTAssertEqual(pt.x, 100)
XCTAssertEqual(pt.y, 200)
}
func testImagePixelToScreenWithScaling() {
// Screenshot is half the display size
let pt = CoordinateConverter.imagePixelsToScreen(
pixelX: 100, pixelY: 50,
screenshotWidth: 960, screenshotHeight: 540,
displayWidth: 1920, displayHeight: 1080,
originX: 0, originY: 0
)
XCTAssertEqual(pt.x, 200)
XCTAssertEqual(pt.y, 100)
}
func testImagePixelToScreenWithOriginOffset() {
DataTypeTests class · swift · L4-L286 (283 LOC)Tests/ComputerUseSwiftTests/DataTypeTests.swift
final class DataTypeTests: XCTestCase {
private let encoder: JSONEncoder = {
let e = JSONEncoder()
e.outputFormatting = .sortedKeys
return e
}()
// MARK: - ScreenshotResult
func testScreenshotResultEncodesAllKeys() throws {
let result = ScreenshotResult(
base64: "data:image/jpeg;base64,abc",
width: 1920,
height: 1080,
displayWidth: 2560,
displayHeight: 1440,
displayId: 1,
originX: 0,
originY: 0,
captureError: nil
)
let data = try encoder.encode(result)
let dict = try JSONSerialization.jsonObject(with: data) as! [String: Any]
let keys = Set(dict.keys)
let expected: Set<String> = [
"base64", "width", "height", "displayWidth", "displayHeight",
"displayId", "originX", "originY", "captureError"
]
XCTAssertEqual(keys, expected)
}
func testScreenshoErrorTests class · swift · L4-L109 (106 LOC)Tests/ComputerUseSwiftTests/ErrorTests.swift
final class ErrorTests: XCTestCase {
// MARK: - ScreenshotError
func testCaptureFailedNoImage() {
let error = ScreenshotError.captureFailedNoImage
XCTAssertEqual(
error.errorDescription,
"Screenshot capture returned nil (permission missing or SCContentFilter failure)"
)
}
func testRegionCaptureFailedNoImage() {
let error = ScreenshotError.regionCaptureFailedNoImage
XCTAssertEqual(
error.errorDescription,
"Region capture returned nil (permission missing or SCContentFilter failure)"
)
}
func testScreenCaptureKitUnavailable() {
let error = ScreenshotError.screenCaptureKitUnavailable
XCTAssertEqual(error.errorDescription, "ScreenCaptureKit requires macOS 14.0")
}
func testMissingPermission() {
let error = ScreenshotError.missingPermission
XCTAssertEqual(error.errorDescription, "Missing screen recording permission")
}
fFrontmostCheckTests class · swift · L4-L176 (173 LOC)Tests/ComputerUseSwiftTests/FrontmostCheckTests.swift
final class FrontmostCheckTests: XCTestCase {
// MARK: - isActionAllowed: mousePosition (always allowed)
func testMousePositionAllowedAtReadTier() {
XCTAssertTrue(FrontmostCheck.isActionAllowed(tier: .read, category: .mousePosition))
}
func testMousePositionAllowedAtClickTier() {
XCTAssertTrue(FrontmostCheck.isActionAllowed(tier: .click, category: .mousePosition))
}
func testMousePositionAllowedAtFullTier() {
XCTAssertTrue(FrontmostCheck.isActionAllowed(tier: .full, category: .mousePosition))
}
// MARK: - isActionAllowed: mouse (click/full)
func testMouseNotAllowedAtReadTier() {
XCTAssertFalse(FrontmostCheck.isActionAllowed(tier: .read, category: .mouse))
}
func testMouseAllowedAtClickTier() {
XCTAssertTrue(FrontmostCheck.isActionAllowed(tier: .click, category: .mouse))
}
func testMouseAllowedAtFullTier() {
XCTAssertTrue(FrontmostCheck.isActionAllowed(tier: .full, category: .mousGrantManagerTests class · swift · L4-L277 (274 LOC)Tests/ComputerUseSwiftTests/GrantManagerTests.swift
final class GrantManagerTests: XCTestCase {
// MARK: - Test data
private let installedApps: [InstalledApp] = [
InstalledApp(bundleId: "com.apple.Safari", displayName: "Safari", path: "/Applications/Safari.app"),
InstalledApp(bundleId: "com.apple.Terminal", displayName: "Terminal", path: "/Applications/Utilities/Terminal.app"),
InstalledApp(bundleId: "com.apple.Notes", displayName: "Notes", path: "/Applications/Notes.app"),
InstalledApp(bundleId: "com.spotify.client", displayName: "Spotify", path: "/Applications/Spotify.app"),
InstalledApp(bundleId: "com.microsoft.VSCode", displayName: "Visual Studio Code", path: "/Applications/Visual Studio Code.app"),
]
// MARK: - App resolution by bundle ID
func testResolveBySafariByBundleId() {
let request = GrantManager.GrantRequest(apps: ["com.apple.Safari"], reason: "test")
let result = GrantManager.resolve(request: request, installedApps: installedApps)
XCTAsAll rows above produced by Repobility · https://repobility.com
ImageSizingTests class · swift · L4-L106 (103 LOC)Tests/ComputerUseSwiftTests/ImageSizingTests.swift
final class ImageSizingTests: XCTestCase {
// MARK: - nTokensForImg
func testNTokens_1x1() {
XCTAssertEqual(ImageSizing.nTokensForImg(width: 1, height: 1, tileSize: 28), 1)
}
func testNTokens_28x28() {
XCTAssertEqual(ImageSizing.nTokensForImg(width: 28, height: 28, tileSize: 28), 1)
}
func testNTokens_29x29() {
// 29 requires 2 tiles per axis: ceil(29/28) = 2
XCTAssertEqual(ImageSizing.nTokensForImg(width: 29, height: 29, tileSize: 28), 4)
}
func testNTokens_56x56() {
// 56/28 = exactly 2 tiles per axis
XCTAssertEqual(ImageSizing.nTokensForImg(width: 56, height: 56, tileSize: 28), 4)
}
func testNTokens_100x100() {
// ceil(100/28) = 4 tiles per axis → 4*4 = 16
XCTAssertEqual(ImageSizing.nTokensForImg(width: 100, height: 100, tileSize: 28), 16)
}
func testNTokens_defaultTileSize() {
// Verify default tileSize parameter is 28
XCTAssertEqual(ImageSizing.nToInputErrorTests class · swift · L4-L127 (124 LOC)Tests/ComputerUseSwiftTests/InputErrorTests.swift
final class InputErrorTests: XCTestCase {
func testInvalidKeyName() {
let error = InputError.invalidKeyName("foo")
XCTAssertEqual(
error.errorDescription,
"Invalid key name: foo. Please use a valid key name."
)
}
func testInvalidKeyNameDifferentValue() {
let error = InputError.invalidKeyName("XYZ123")
XCTAssertEqual(
error.errorDescription,
"Invalid key name: XYZ123. Please use a valid key name."
)
}
func testInvalidAction() {
let error = InputError.invalidAction("baz")
XCTAssertEqual(
error.errorDescription,
"Invalid action: baz. Valid options are: press, release, click"
)
}
func testInvalidActionDifferentValue() {
let error = InputError.invalidAction("hold")
XCTAssertEqual(
error.errorDescription,
"Invalid action: hold. Valid options are: press, release, click"
)
KeyMappingTests class · swift · L4-L285 (282 LOC)Tests/ComputerUseSwiftTests/KeyMappingTests.swift
final class KeyMappingTests: XCTestCase {
// MARK: - Modifier Keys
func testAltMapsToOptionKeycode() {
let result = KeyMapping.virtualKeycode(for: "Alt")
XCTAssertNotNil(result)
XCTAssertEqual(result?.keycode, 0x3A)
XCTAssertTrue(result?.isModifier == true)
}
func testOptionIsAliasForAlt() {
let alt = KeyMapping.virtualKeycode(for: "Alt")
let option = KeyMapping.virtualKeycode(for: "Option")
XCTAssertEqual(alt?.keycode, option?.keycode)
}
func testROptionMapsToRightOption() {
let result = KeyMapping.virtualKeycode(for: "ROption")
XCTAssertEqual(result?.keycode, 0x3D)
XCTAssertTrue(result?.isModifier == true)
}
func testCommandMapsToCorrectKeycode() {
let result = KeyMapping.virtualKeycode(for: "Command")
XCTAssertEqual(result?.keycode, 0x37)
XCTAssertTrue(result?.isModifier == true)
}
func testSuperIsAliasForCommand() {
let cmd = NewModelTests class · swift · L4-L155 (152 LOC)Tests/ComputerUseSwiftTests/NewModelTests.swift
final class NewModelTests: XCTestCase {
private let encoder: JSONEncoder = {
let e = JSONEncoder()
e.outputFormatting = .sortedKeys
return e
}()
// MARK: - FrontmostAppInfo
func testFrontmostAppInfoEncoding() throws {
let info = FrontmostAppInfo(
appName: "Safari",
bundleId: "com.apple.Safari",
appIconBase64: "data:image/png;base64,abc"
)
let data = try encoder.encode(info)
let dict = try JSONSerialization.jsonObject(with: data) as! [String: Any]
XCTAssertEqual(dict["appName"] as? String, "Safari")
XCTAssertEqual(dict["bundleId"] as? String, "com.apple.Safari")
XCTAssertEqual(dict["appIconBase64"] as? String, "data:image/png;base64,abc")
}
func testFrontmostAppInfoKeys() throws {
let info = FrontmostAppInfo(
appName: "Test",
bundleId: "com.test",
appIconBase64: "icon"
)
let data = try PlistValueTests class · swift · L4-L130 (127 LOC)Tests/ComputerUseSwiftTests/PlistValueTests.swift
final class PlistValueTests: XCTestCase {
private let encoder: JSONEncoder = {
let e = JSONEncoder()
e.outputFormatting = .sortedKeys
return e
}()
// MARK: - Encoding
func testStringEncodesAsJsonString() throws {
let value = PlistValue.string("hello")
let data = try encoder.encode(value)
let json = String(data: data, encoding: .utf8)!
XCTAssertEqual(json, "\"hello\"")
}
func testBoolTrueEncodesAsJsonBoolean() throws {
let value = PlistValue.bool(true)
let data = try encoder.encode(value)
let json = String(data: data, encoding: .utf8)!
XCTAssertEqual(json, "true")
}
func testBoolFalseEncodesAsJsonBoolean() throws {
let value = PlistValue.bool(false)
let data = try encoder.encode(value)
let json = String(data: data, encoding: .utf8)!
XCTAssertEqual(json, "false")
}
func testIntegerEncodesAsJsonNumber() throws {
let vScreenshotFilterTests class · swift · L4-L59 (56 LOC)Tests/ComputerUseSwiftTests/ScreenshotFilterTests.swift
final class ScreenshotFilterTests: XCTestCase {
// MARK: - Exclude list with no allowed apps
func testExcludeListWithNoAllowedAppsExcludesRunning() {
// With an empty session (no allowed apps), all running apps should be excluded
let session = SessionState(sessionId: "test-filter")
let excluded = ScreenshotFilter.buildExcludeList(session: session)
// We can't know exactly what's running, but the function should return without error.
// The key invariant: no allowed app should be in the exclude list.
XCTAssertNotNil(excluded)
}
// MARK: - Allowed apps are not excluded
func testAllowedAppsNotInExcludeList() {
var session = SessionState(sessionId: "test-filter")
// Add Finder as allowed — it's almost always running
session.allowedApps = [
GrantedApp(
bundleId: BundleIDs.finder,
displayName: "Finder",
grantedAt: Date(),
SessionLockTests class · swift · L4-L119 (116 LOC)Tests/ComputerUseSwiftTests/SessionLockTests.swift
final class SessionLockTests: XCTestCase {
private let sessionA = "lock-test-session-a"
private let sessionB = "lock-test-session-b"
override func setUp() {
super.setUp()
SessionLock.forceRelease()
}
override func tearDown() {
SessionLock.forceRelease()
super.tearDown()
}
// MARK: - Acquire / Release cycle
func testAcquireReturnsNilOnSuccess() {
let error = SessionLock.acquire(sessionId: sessionA)
XCTAssertNil(error)
}
func testReleaseReturnsTrueWhenHeld() {
_ = SessionLock.acquire(sessionId: sessionA)
let released = SessionLock.release(sessionId: sessionA)
XCTAssertTrue(released)
}
func testCheckReturnsLockInfoAfterAcquire() {
_ = SessionLock.acquire(sessionId: sessionA)
let info = SessionLock.check()
XCTAssertNotNil(info)
XCTAssertEqual(info?.sessionId, sessionA)
XCTAssertEqual(info?.pid, ProcessInfo.processInfo.processSessionStateTests class · swift · L4-L168 (165 LOC)Tests/ComputerUseSwiftTests/SessionStateTests.swift
final class SessionStateTests: XCTestCase {
private let testSessionId = "test-session-\(UUID().uuidString)"
override func tearDown() {
try? SessionState.delete(sessionId: testSessionId)
super.tearDown()
}
// MARK: - Creation
func testInitSetsSessionId() {
let state = SessionState(sessionId: testSessionId)
XCTAssertEqual(state.sessionId, testSessionId)
}
func testInitSetsDefaults() {
let state = SessionState(sessionId: testSessionId)
XCTAssertTrue(state.allowedApps.isEmpty)
XCTAssertEqual(state.grantFlags, GrantFlags())
XCTAssertNil(state.lastScreenshot)
XCTAssertNil(state.selectedDisplayId)
XCTAssertTrue(state.hiddenDuringTurn.isEmpty)
XCTAssertNil(state.clipboardStash)
XCTAssertFalse(state.mouseHeld)
XCTAssertFalse(state.mouseDragged)
XCTAssertNil(state.lockAcquiredAt)
}
func testCreatedAtIsSet() {
let before = Date()
Same scanner, your repo: https://repobility.com — Repobility
SystemKeyCombosTests class · swift · L4-L81 (78 LOC)Tests/ComputerUseSwiftTests/SystemKeyCombosTests.swift
final class SystemKeyCombosTests: XCTestCase {
// MARK: - Blocked combos
func testMetaQIsSystemCombo() {
XCTAssertTrue(SystemKeyCombos.isSystemCombo(["meta", "q"]))
}
func testAltMetaEscapeIsSystemCombo() {
XCTAssertTrue(SystemKeyCombos.isSystemCombo(["alt", "meta", "escape"]))
}
func testMetaTabIsSystemCombo() {
XCTAssertTrue(SystemKeyCombos.isSystemCombo(["meta", "tab"]))
}
func testCtrlMetaQIsSystemCombo() {
XCTAssertTrue(SystemKeyCombos.isSystemCombo(["ctrl", "meta", "q"]))
}
func testMetaSpaceIsSystemCombo() {
XCTAssertTrue(SystemKeyCombos.isSystemCombo(["meta", "space"]))
}
func testShiftMetaQIsSystemCombo() {
XCTAssertTrue(SystemKeyCombos.isSystemCombo(["shift", "meta", "q"]))
}
// MARK: - Non-blocked combos
func testMetaCIsNotSystemCombo() {
XCTAssertFalse(SystemKeyCombos.isSystemCombo(["meta", "c"]))
}
func testShiftAIsNotSystemCombo() {
WindowErrorTests class · swift · L4-L65 (62 LOC)Tests/ComputerUseSwiftTests/WindowErrorTests.swift
final class WindowErrorTests: XCTestCase {
func testWindowNotFound() {
let error = WindowError.windowNotFound
XCTAssertEqual(error.errorDescription, "Window not found")
}
func testInvalidHandleSize() {
let error = WindowError.invalidHandleSize(expected: 4, actual: 8)
XCTAssertEqual(
error.errorDescription,
"expected parameter 'windowHandle' to be the size of a window handle (4 bytes), got 8 bytes"
)
}
func testInvalidHandleSizeDifferentValues() {
let error = WindowError.invalidHandleSize(expected: 8, actual: 2)
XCTAssertEqual(
error.errorDescription,
"expected parameter 'windowHandle' to be the size of a window handle (8 bytes), got 2 bytes"
)
}
func testAxElementCreationFailed() {
let error = WindowError.axElementCreationFailed
XCTAssertEqual(error.errorDescription, "Failed to create AXUIElementRef")
}
func testSystemW