mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
Move MockView to SplitTreeTests itself
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user