25 lines
1.4 KiB
Swift
25 lines
1.4 KiB
Swift
import Foundation
|
|
|
|
@main struct AppearancePreferencesChecks {
|
|
@MainActor static func main() {
|
|
let suite = "kymo.appearance." + UUID().uuidString
|
|
let defaults = UserDefaults(suiteName: suite)!
|
|
defer { defaults.removePersistentDomain(forName: suite) }
|
|
defaults.set(true, forKey: "appearance.reduceMotion")
|
|
let sampling = SamplingPreferences(defaults: defaults)
|
|
let appearance = AppearancePreferences(defaults: defaults)
|
|
precondition(appearance.appearance == .system && !sampling.backgroundEnabled)
|
|
appearance.appearance = .dark
|
|
precondition(AppearancePreferences(defaults: defaults).appearance == .dark)
|
|
precondition(!sampling.backgroundEnabled && sampling.panelMilliseconds == 2000)
|
|
sampling.backgroundEnabled = true
|
|
sampling.backgroundMilliseconds = 5000
|
|
appearance.appearance = .light
|
|
precondition(sampling.backgroundEnabled && sampling.backgroundMilliseconds == 5000)
|
|
precondition(defaults.bool(forKey: "appearance.reduceMotion"), "Obsolete motion keys must be ignored, not overwritten")
|
|
defaults.set("invalid", forKey: "appearance")
|
|
precondition(AppearancePreferences(defaults: defaults).appearance == .system)
|
|
print("PASS: appearance persistence/fallback, independent sampling and preservation of obsolete motion preferences")
|
|
}
|
|
}
|