Files
OSGKeyboard/OSGKeyboardExtTests/KeyboardSurfaceStateTests.swift
T
Rocky d1e5fed964 chore(typing): snapshot local pinyin WIP before syncing cloud branch
Preserve the in-progress local typing/pinyin implementation so feat/pinyin
can safely reset to origin/feat/pinyin (cloud English + Chinese typing).
2026-08-03 13:14:01 +08:00

54 lines
1.8 KiB
Swift

// KeyboardSurfaceStateTests.swift
// OSGKeyboard · Ext unit tests
import XCTest
@testable import OSGKeyboardShared
@MainActor
final class KeyboardSurfaceStateTests: XCTestCase {
func testRecordingLocksTyping() {
let state = KeyboardState()
state.phase = .idle
XCTAssertTrue(state.canEnterTypingSurface)
state.phase = .recording
XCTAssertTrue(state.locksTypingSurface)
XCTAssertFalse(state.canEnterTypingSurface)
}
func testStandardLayoutHasQwertyTopRow() {
let layout = StandardTypingLayout()
let rows = layout.rows(for: .letters, shiftActive: false)
XCTAssertEqual(rows.first, ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"])
let shifted = layout.rows(for: .letters, shiftActive: true)
XCTAssertEqual(shifted.first?.first, "Q")
}
func testVoiceAndTypingChromeShareStableDimensions() {
XCTAssertEqual(KeyboardChromeLayout.totalHeight, 281)
XCTAssertEqual(KeyboardChromeLayout.actionKeyHeight, 50)
XCTAssertEqual(KeyboardChromeLayout.actionKeyCornerRadius, 10)
XCTAssertEqual(KeyboardChromeLayout.horizontalInset, 8)
}
func testSharedCapsuleCanSelectSpecificTypingLanguage() {
let typing = TypingSessionController()
XCTAssertEqual(typing.language, .chinese)
XCTAssertEqual(typing.setLanguage(.english), "")
XCTAssertEqual(typing.language, .english)
XCTAssertEqual(typing.setLanguage(.chinese), "")
XCTAssertEqual(typing.language, .chinese)
}
func testShiftStateProducesUppercaseKeyRows() {
let typing = TypingSessionController()
XCTAssertFalse(typing.shiftActive)
_ = typing.handleKey("⇧")
XCTAssertTrue(typing.shiftActive)
XCTAssertEqual(typing.keyRows.first?.first, "Q")
}
}