mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
The full keyboard's Hex key ignored taps and needed a 0.35 s hold; a tap now dictates too (sliding still opens the style menu). The dictation bar's Hex mark opened Hex through the cold-start handoff; with no warm session it now starts in-keyboard dictation instead. Removes the stray-tap-does-nothing guard because Ryan wants the key to act like a dictation button. Verified HexKeyGestureTests (5 passed) in the iPhone 18 Pro simulator and installed on the iPhone 17 Pro.
49 lines
1.8 KiB
Swift
49 lines
1.8 KiB
Swift
import CoreGraphics
|
|
import XCTest
|
|
@testable import HEX
|
|
|
|
final class HexKeyGestureTests: XCTestCase {
|
|
func testTapDictates() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 3, y: 2)), .ignored, "a jitter is still a tap")
|
|
XCTAssertEqual(gesture.touchUp(), .tap)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored, "a timer left over from the tap")
|
|
XCTAssertEqual(gesture.state, .idle)
|
|
}
|
|
|
|
func testStillHoldFiresOnce() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
XCTAssertEqual(gesture.holdElapsed(), .hold)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored)
|
|
XCTAssertEqual(gesture.touchUp(), .ignored)
|
|
}
|
|
|
|
func testMoveBeforeHoldOpensMenu() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: CGPoint(x: 20, y: 20))
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 20, y: 9)), .openMenu)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored, "the menu won, no dictation")
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 0, y: -40)), .dragMenu)
|
|
XCTAssertEqual(gesture.touchUp(), .releaseMenu)
|
|
XCTAssertEqual(gesture.state, .idle)
|
|
}
|
|
|
|
func testMoveAfterHoldDoesNothing() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
XCTAssertEqual(gesture.holdElapsed(), .hold)
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 0, y: -80)), .ignored)
|
|
XCTAssertEqual(gesture.touchUp(), .ignored)
|
|
}
|
|
|
|
func testCancelResets() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
gesture.cancel()
|
|
XCTAssertEqual(gesture.state, .idle)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored)
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 50, y: 0)), .ignored)
|
|
}
|
|
}
|