Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmuxTests/BrowserConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ final class CmuxWebViewKeyEquivalentTests: XCTestCase {
super.delegate = newValue
}
}

/// macOS 27's NSTextView initializer reads its own `delegate`. Only
/// reads after construction belong to the code under test.
func resetDelegateReadCount() {
delegateReadCount = 0
}
}

private final class FieldEditorProbeTextView: NSTextView {
Expand All @@ -329,6 +335,12 @@ final class CmuxWebViewKeyEquivalentTests: XCTestCase {
}
}

/// macOS 27's NSTextView initializer reads its own `delegate`. Only
/// reads after construction belong to the code under test.
func resetDelegateReadCount() {
delegateReadCount = 0
}

override var isFieldEditor: Bool {
get { true }
set {}
Expand Down Expand Up @@ -991,6 +1003,7 @@ final class CmuxWebViewKeyEquivalentTests: XCTestCase {
window.contentView = container

let textView = DelegateProbeTextView(frame: NSRect(x: 0, y: 0, width: 100, height: 40))
textView.resetDelegateReadCount()
container.addSubview(textView)

window.makeKeyAndOrderFront(nil)
Expand Down Expand Up @@ -1028,6 +1041,7 @@ final class CmuxWebViewKeyEquivalentTests: XCTestCase {
webView.addSubview(descendant)

let fieldEditor = FieldEditorProbeTextView(frame: NSRect(x: 0, y: 0, width: 100, height: 20))
fieldEditor.resetDelegateReadCount()

window.makeKeyAndOrderFront(nil)
defer {
Expand Down
7 changes: 7 additions & 0 deletions cmuxTests/ShortcutAndCommandPaletteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,12 @@ final class CommandPaletteFocusStealerClassificationTests: XCTestCase {
super.delegate = newValue
}
}

/// macOS 27's NSTextView initializer reads its own `delegate`. Only
/// reads after construction belong to the code under test.
func resetDelegateReadCount() {
delegateReadCount = 0
}
}

func testTreatsGhosttySurfaceViewAsFocusStealer() {
Expand Down Expand Up @@ -748,6 +754,7 @@ final class CommandPaletteFocusStealerClassificationTests: XCTestCase {

func testDoesNotReadTextViewDelegateForFocusStealerClassification() {
let textView = DelegateTrackingTextView(frame: NSRect(x: 0, y: 0, width: 120, height: 24))
textView.resetDelegateReadCount()

XCTAssertFalse(textView.isCommandPaletteFocusStealingTerminalOrBrowser)
XCTAssertEqual(
Expand Down
7 changes: 7 additions & 0 deletions cmuxTests/TerminalAndGhosttyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2984,6 +2984,12 @@ final class GhosttyResponderResolutionTests: XCTestCase {
super.delegate = newValue
}
}

/// macOS 27's NSTextView initializer reads its own `delegate`. Only
/// reads after construction belong to the code under test.
func resetDelegateReadCount() {
delegateReadCount = 0
}
}

func testResolvesGhosttyViewFromDescendantResponder() {
Expand Down Expand Up @@ -3044,6 +3050,7 @@ final class GhosttyResponderResolutionTests: XCTestCase {

func testDoesNotReadTextViewDelegateForGhosttyResponderResolution() {
let textView = DelegateTrackingTextView(frame: NSRect(x: 0, y: 0, width: 40, height: 40))
textView.resetDelegateReadCount()

XCTAssertNil(textView.cmuxStrictOwningGhosttyView())
XCTAssertEqual(
Expand Down
Loading