项目文件夹

文件
wehub-resource-sync bd44b5aa08
Test / build-libghostty-vt (x86_64-windows-gnu) (push) Has been cancelled
Test / build-libghostty-vt-macos (aarch64-ios) (push) Has been cancelled
Test / build-libghostty-vt-macos (aarch64-macos) (push) Has been cancelled
Test / build-libghostty-vt-macos (x86_64-macos) (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / build-dist (push) Has been cancelled
Test / GTK x11=true wayland=true (push) Has been cancelled
Test / Build -Dsimd=false (push) Has been cancelled
Test / Build -Dsimd=true (push) Has been cancelled
Test / Build -Dsentry=false (push) Has been cancelled
Test / Build -Dsentry=true (push) Has been cancelled
Test / zig-fmt (push) Has been cancelled
Test / GitHub Actions Pins (push) Has been cancelled
Test / prettier (push) Has been cancelled
Test / swiftlint (push) Has been cancelled
Test / alejandra (push) Has been cancelled
Test / typos (push) Has been cancelled
Nix / Required Checks: Nix (push) Has been cancelled
Nix / check-zig-cache-hash (push) Has been cancelled
Test / skip (push) Has been cancelled
Test / Required Checks: Test (push) Has been cancelled
Test / build-bench (push) Has been cancelled
Test / list-examples (push) Has been cancelled
Test / Example ${{ matrix.dir }} (Windows) (push) Has been cancelled
Test / build-cmake (push) Has been cancelled
Test / test-lib-vt-pkgconfig (push) Has been cancelled
Test / build-flatpak (push) Has been cancelled
Test / build-snap (push) Has been cancelled
Test / build-libghostty-vt (aarch64-linux) (push) Has been cancelled
Test / build-libghostty-vt (aarch64-macos) (push) Has been cancelled
Test / build-libghostty-vt (wasm32-freestanding) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-linux) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-linux-musl) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-macos) (push) Has been cancelled
Test / build-libghostty-vt-android (aarch64-linux-android) (push) Has been cancelled
Test / build-libghostty-vt-android (arm-linux-androideabi) (push) Has been cancelled
Test / build-libghostty-vt-android (x86_64-linux-android) (push) Has been cancelled
Test / build-libghostty-vt-windows (push) Has been cancelled
Test / build-libghostty-windows-gnu (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / build-linux-libghostty (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-dist-lib-vt (push) Has been cancelled
Test / trigger-snap (push) Has been cancelled
Test / trigger-flatpak (push) Has been cancelled
Test / build-macos (push) Has been cancelled
Test / build-macos-freetype (push) Has been cancelled
Test / test (push) Has been cancelled
Test / test-lib-vt (push) Has been cancelled
Test / GTK x11=false wayland=false (push) Has been cancelled
Test / GTK x11=true wayland=false (push) Has been cancelled
Test / GTK x11=false wayland=true (push) Has been cancelled
Test / test-macos (push) Has been cancelled
Test / test-windows (push) Has been cancelled
Test / Build -Di18n=false (push) Has been cancelled
Test / Build -Di18n=true (push) Has been cancelled
Test / Build test/fuzz-libghostty (push) Has been cancelled
Test / shellcheck (push) Has been cancelled
Test / translations (push) Has been cancelled
Test / blueprint-compiler (push) Has been cancelled
Test / Test pkg/wuffs (push) Has been cancelled
Test / Test build on Debian 13 (push) Has been cancelled
Test / valgrind (push) Has been cancelled
Test / Example ${{ matrix.dir }} (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:02:48 +08:00

164 行
6.6 KiB
Swift

//
// GhosttyThemeTests.swift
// Ghostty
//
// Created by luca on 27.10.2025.
//
import AppKit
import XCTest
final class GhosttyThemeTests: GhosttyCustomConfigCase {
override static var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
let windowTitle = "GhosttyThemeTests"
private func assertTitlebarAppearance(
_ appearance: XCUIDevice.Appearance,
for app: XCUIApplication,
title: String? = nil,
colorLocation: CGPoint? = nil,
file: StaticString = #filePath,
line: UInt = #line
) throws {
for i in 0 ..< app.windows.count {
let titleView = app.windows.element(boundBy: i).staticTexts.element(matching: NSPredicate(format: "value == '\(title ?? windowTitle)'"))
let image = titleView.screenshot().image
guard let imageColor = image.colorAt(x: Int(colorLocation?.x ?? 1), y: Int(colorLocation?.y ?? 1)) else {
throw XCTSkip("failed to get pixel color", file: file, line: line)
}
switch appearance {
case .dark:
XCTAssertLessThanOrEqual(imageColor.luminance, 0.5, "Expected dark appearance for this test", file: file, line: line)
default:
XCTAssertGreaterThanOrEqual(imageColor.luminance, 0.5, "Expected light appearance for this test", file: file, line: line)
}
}
}
/// https://github.com/ghostty-org/ghostty/issues/8282
@MainActor
func testIssue8282() async throws {
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night")
XCUIDevice.shared.appearance = .dark
let app = try ghosttyApplication()
app.launch()
try assertTitlebarAppearance(.dark, for: app)
// create a split
app.groups["Terminal pane"].typeKey("d", modifierFlags: .command)
// reload config
app.typeKey(",", modifierFlags: [.command, .shift])
try await Task.sleep(for: .seconds(0.5))
// create a new window
app.typeKey("n", modifierFlags: [.command])
try assertTitlebarAppearance(.dark, for: app)
}
@MainActor
func testLightTransparentWindowThemeWithDarkTerminal() async throws {
try updateConfig("title=\(windowTitle) \n window-theme=light")
let app = try ghosttyApplication()
app.launch()
try await Task.sleep(for: .seconds(0.5))
try assertTitlebarAppearance(.dark, for: app)
}
@MainActor
func testLightNativeWindowThemeWithDarkTerminal() async throws {
try updateConfig("title=\(windowTitle) \n window-theme = light \n macos-titlebar-style = native")
let app = try ghosttyApplication()
app.launch()
try assertTitlebarAppearance(.light, for: app)
}
@MainActor
func testReloadingLightTransparentWindowTheme() async throws {
try updateConfig("title=\(windowTitle) \n ")
let app = try ghosttyApplication()
app.launch()
// default dark theme
try assertTitlebarAppearance(.dark, for: app)
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night \n window-theme = light")
// reload config
app.typeKey(",", modifierFlags: [.command, .shift])
try await Task.sleep(for: .seconds(0.5))
try assertTitlebarAppearance(.light, for: app)
}
@MainActor
func testSwitchingSystemTheme() async throws {
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night")
XCUIDevice.shared.appearance = .dark
let app = try ghosttyApplication()
app.launch()
try assertTitlebarAppearance(.dark, for: app)
XCUIDevice.shared.appearance = .light
try await Task.sleep(for: .seconds(0.5))
try assertTitlebarAppearance(.light, for: app)
}
@MainActor
func testReloadFromLightWindowThemeToDefaultTheme() async throws {
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night")
XCUIDevice.shared.appearance = .light
let app = try ghosttyApplication()
app.launch()
try assertTitlebarAppearance(.light, for: app)
try updateConfig("title=\(windowTitle) \n ")
// reload config
app.typeKey(",", modifierFlags: [.command, .shift])
try await Task.sleep(for: .seconds(0.5))
try assertTitlebarAppearance(.dark, for: app)
}
@MainActor
func testReloadFromDefaultThemeToDarkWindowTheme() async throws {
try updateConfig("title=\(windowTitle) \n ")
XCUIDevice.shared.appearance = .light
let app = try ghosttyApplication()
app.launch()
try assertTitlebarAppearance(.dark, for: app)
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night \n window-theme=dark")
// reload config
app.typeKey(",", modifierFlags: [.command, .shift])
try await Task.sleep(for: .seconds(0.5))
try assertTitlebarAppearance(.dark, for: app)
}
@MainActor
func testReloadingFromDarkThemeToSystemLightTheme() async throws {
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night \n window-theme=dark")
XCUIDevice.shared.appearance = .light
let app = try ghosttyApplication()
app.launch()
try assertTitlebarAppearance(.dark, for: app)
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night")
// reload config
app.typeKey(",", modifierFlags: [.command, .shift])
try await Task.sleep(for: .seconds(0.5))
try assertTitlebarAppearance(.light, for: app)
}
@MainActor
func testQuickTerminalThemeChange() async throws {
try updateConfig("title=\(windowTitle) \n theme=light:3024 Day,dark:3024 Night \n confirm-close-surface=false")
XCUIDevice.shared.appearance = .light
let app = try ghosttyApplication()
app.launch()
// close default window
app.typeKey("w", modifierFlags: [.command])
// open quick terminal
app.menuBarItems["View"].firstMatch.click()
app.menuItems["Quick Terminal"].firstMatch.click()
let title = "Debug builds of Ghostty are very slow and you may experience performance problems. Debug builds are only recommended during development."
try assertTitlebarAppearance(.light, for: app, title: title, colorLocation: CGPoint(x: 5, y: 5)) // to avoid dark edge
XCUIDevice.shared.appearance = .dark
try await Task.sleep(for: .seconds(0.5))
try assertTitlebarAppearance(.dark, for: app, title: title, colorLocation: CGPoint(x: 5, y: 5))
}
}