Move MockView to SplitTreeTests itself

This commit is contained in:
Pieter Ouwerkerk
2026-02-17 09:23:45 -08:00
parent 8fdedbce45
commit ce66bea581
2 changed files with 24 additions and 27 deletions

View File

@@ -1,27 +0,0 @@
import AppKit
// @preconcurrency suppresses Sendable errors from Codable on NSView
// but the Swift compiler still complains about it.
class MockView: NSView, @preconcurrency Codable, Identifiable {
let id: UUID
init(id: UUID = UUID()) {
self.id = id
super.init(frame: .zero)
}
required init?(coder: NSCoder) { fatalError() }
enum CodingKeys: CodingKey { case id }
required init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
self.id = try c.decode(UUID.self, forKey: .id)
super.init(frame: .zero)
}
func encode(to encoder: Encoder) throws {
var c = encoder.container(keyedBy: CodingKeys.self)
try c.encode(id, forKey: .id)
}
}

View File

@@ -2,6 +2,30 @@ import AppKit
import Testing
@testable import Ghostty
class MockView: NSView, Codable, Identifiable {
let id: UUID
init(id: UUID = UUID()) {
self.id = id
super.init(frame: .zero)
}
required init?(coder: NSCoder) { fatalError() }
enum CodingKeys: CodingKey { case id }
required init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
self.id = try c.decode(UUID.self, forKey: .id)
super.init(frame: .zero)
}
func encode(to encoder: Encoder) throws {
var c = encoder.container(keyedBy: CodingKeys.self)
try c.encode(id, forKey: .id)
}
}
struct SplitTreeTests {
/// Creates a two-view horizontal split tree (view1 | view2).
private func makeHorizontalSplit() throws -> (SplitTree<MockView>, MockView, MockView) {