70 lines
2.1 KiB
Swift
70 lines
2.1 KiB
Swift
import XCTest
|
|
import AppKit
|
|
|
|
#if canImport(cmux_DEV)
|
|
@testable import cmux_DEV
|
|
#elseif canImport(cmux)
|
|
@testable import cmux
|
|
#endif
|
|
|
|
@MainActor
|
|
final class GhosttyEnsureFocusWindowActivationTests: XCTestCase {
|
|
func testAllowsActivationForActiveManager() {
|
|
let activeManager = TabManager()
|
|
let otherManager = TabManager()
|
|
let targetWindow = NSWindow()
|
|
let otherWindow = NSWindow()
|
|
|
|
XCTAssertTrue(
|
|
shouldAllowEnsureFocusWindowActivation(
|
|
activeTabManager: activeManager,
|
|
targetTabManager: activeManager,
|
|
keyWindow: targetWindow,
|
|
mainWindow: targetWindow,
|
|
targetWindow: targetWindow
|
|
)
|
|
)
|
|
XCTAssertFalse(
|
|
shouldAllowEnsureFocusWindowActivation(
|
|
activeTabManager: activeManager,
|
|
targetTabManager: otherManager,
|
|
keyWindow: otherWindow,
|
|
mainWindow: otherWindow,
|
|
targetWindow: targetWindow
|
|
)
|
|
)
|
|
}
|
|
|
|
func testAllowsActivationWhenAppHasNoKeyAndNoMainWindow() {
|
|
let targetManager = TabManager()
|
|
let targetWindow = NSWindow()
|
|
|
|
XCTAssertTrue(
|
|
shouldAllowEnsureFocusWindowActivation(
|
|
activeTabManager: nil,
|
|
targetTabManager: targetManager,
|
|
keyWindow: nil,
|
|
mainWindow: nil,
|
|
targetWindow: targetWindow
|
|
)
|
|
)
|
|
XCTAssertFalse(
|
|
shouldAllowEnsureFocusWindowActivation(
|
|
activeTabManager: nil,
|
|
targetTabManager: targetManager,
|
|
keyWindow: NSWindow(),
|
|
mainWindow: nil,
|
|
targetWindow: targetWindow
|
|
)
|
|
)
|
|
XCTAssertFalse(
|
|
shouldAllowEnsureFocusWindowActivation(
|
|
activeTabManager: nil,
|
|
targetTabManager: targetManager,
|
|
keyWindow: nil,
|
|
mainWindow: NSWindow(),
|
|
targetWindow: targetWindow
|
|
)
|
|
)
|
|
}
|
|
}
|