31 lines
1.5 KiB
Swift
31 lines
1.5 KiB
Swift
import Foundation
|
|
import AppKit
|
|
import CoreGraphics
|
|
|
|
@main struct PresentationChecks {
|
|
@MainActor static func main() {
|
|
precondition(AppAppearance.system.resolved(systemIsDark: true) == .dark)
|
|
precondition(AppAppearance.system.resolved(systemIsDark: false) == .light)
|
|
precondition(AppAppearance.light.resolved(systemIsDark: true) == .light)
|
|
precondition(AppAppearance.dark.resolved(systemIsDark: false) == .dark)
|
|
precondition(SystemAppearanceObserver.isDark(globalDomain: ["AppleInterfaceStyle": "Dark"]))
|
|
precondition(!SystemAppearanceObserver.isDark(globalDomain: [:]))
|
|
_ = NSApplication.shared
|
|
let global = NSApp.appearance
|
|
let window = NSWindow(contentRect: .zero, styleMask: .borderless, backing: .buffered, defer: true)
|
|
window.isReleasedWhenClosed = false
|
|
for choice in [AppAppearance.light, .system, .dark, .system] {
|
|
WindowAppearance.apply(choice, to: window)
|
|
if choice == .system {
|
|
precondition(window.appearance == nil)
|
|
precondition(window.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]) == NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]))
|
|
} else {
|
|
precondition(window.appearance?.name == choice.windowAppearance?.name)
|
|
}
|
|
precondition(NSApp.appearance === global)
|
|
}
|
|
window.close()
|
|
print("PASS: explicit/system window appearance reset, independent system resolution")
|
|
}
|
|
}
|