M4: TranslationSession actor with epochs/one-in-flight streaming, PanelViewModel, non-activating NSPanel, streaming panel UI, searchable/recent target languages, warnings/errors and Copy/Retry/Replace actions. M5: InsertionCoordinator with target capture, AX direct replacement, secure-field/own-PID refusal, frontmost and selected-text verification, snapshot/⌘V/restore fallback, cancellation-safe restore and blocking-warning gate. M6: versioned AppSettings/SettingsStore, onboarding for Ollama/model/target/Accessibility, General/Model/Translation/Privacy/Diagnostics settings, launch-at-login via SMAppService, status menu (target, copy/replace last, setup, diagnostics, about), text-free diagnostics and first-run setup. Docs: PROGRESS M4–M6, ARCHITECTURE §10–§12, ADR-019/020, SELECTION_AND_CLIPBOARD and TESTING. Manual 10-app matrices, real AX/paste delivery, VoiceOver and focus checks remain open. Verified: make verify green (format, strict lint, scripts, privacy, Debug+Release signatures, 217 package tests); app launches and a two-copy clipboard smoke test opens the panel.
66 lines
1.6 KiB
Swift
66 lines
1.6 KiB
Swift
import Foundation
|
|
import SprachmittlerCore
|
|
|
|
/// An in-memory settings backend for tests.
|
|
public final class InMemorySettingsDataStore: SettingsDataStoring, @unchecked Sendable {
|
|
private let lock = NSLock()
|
|
private var values: [String: Data] = [:]
|
|
|
|
/// Creates an empty store.
|
|
public init() {}
|
|
|
|
public func data(forKey key: String) -> Data? {
|
|
lock.lock()
|
|
defer { lock.unlock() }
|
|
return values[key]
|
|
}
|
|
|
|
public func set(_ data: Data?, forKey key: String) {
|
|
lock.lock()
|
|
values[key] = data
|
|
lock.unlock()
|
|
}
|
|
}
|
|
|
|
/// An Accessibility fake for onboarding and insertion tests.
|
|
@MainActor
|
|
public final class FakeAccessibilityPermission: AccessibilityPermissionChecking {
|
|
public var isTrusted: Bool
|
|
public private(set) var requestCount = 0
|
|
public private(set) var openSettingsCount = 0
|
|
|
|
/// Creates a fake.
|
|
public init(isTrusted: Bool = false) {
|
|
self.isTrusted = isTrusted
|
|
}
|
|
|
|
public func requestTrust() {
|
|
requestCount += 1
|
|
}
|
|
|
|
public func openSettings() {
|
|
openSettingsCount += 1
|
|
}
|
|
}
|
|
|
|
/// A launch-at-login fake.
|
|
@MainActor
|
|
public final class FakeLaunchAtLogin: LaunchAtLoginControlling {
|
|
public var isEnabled: Bool
|
|
public private(set) var requestedValues: [Bool] = []
|
|
public var error: (any Error)?
|
|
|
|
/// Creates a fake.
|
|
public init(isEnabled: Bool = false) {
|
|
self.isEnabled = isEnabled
|
|
}
|
|
|
|
public func setEnabled(_ enabled: Bool) throws {
|
|
requestedValues.append(enabled)
|
|
if let error {
|
|
throw error
|
|
}
|
|
isEnabled = enabled
|
|
}
|
|
}
|