Adds tests.
This commit is contained in:
parent
ef61acf563
commit
472b149020
|
@ -119,6 +119,36 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
func testEnterWithReading() {
|
||||
let input = KeyHandlerInput(inputText: "s", keyCode: 0, charCode: charCode("s"), flags: .shift, isVerticalMode: false)
|
||||
var state: InputState = InputState.Empty()
|
||||
handler.handle(input: input, state: state) { newState in
|
||||
state = newState
|
||||
} errorCallback: {
|
||||
}
|
||||
|
||||
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||
if let state = state as? InputState.Inputting {
|
||||
XCTAssertEqual(state.composingBuffer, "ㄋ")
|
||||
}
|
||||
|
||||
let enter = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 13, flags: [], isVerticalMode: false)
|
||||
var count = 0
|
||||
|
||||
handler.handle(input: enter, state: state) { newState in
|
||||
if count == 0 {
|
||||
state = newState
|
||||
}
|
||||
count += 1
|
||||
} errorCallback: {
|
||||
}
|
||||
|
||||
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||
if let state = state as? InputState.Inputting {
|
||||
XCTAssertEqual(state.composingBuffer, "ㄋ")
|
||||
}
|
||||
}
|
||||
|
||||
func testInputNe() {
|
||||
let input = KeyHandlerInput(inputText: "s", keyCode: 0, charCode: charCode("s"), flags: .shift, isVerticalMode: false)
|
||||
var state: InputState = InputState.Empty()
|
||||
|
|
|
@ -779,12 +779,15 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
return NO;
|
||||
}
|
||||
|
||||
if (_inputMode == InputModePlainBopomofo) {
|
||||
if (!_bpmfReadingBuffer->isEmpty()) {
|
||||
errorCallback();
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
// Actually the lines would not be reached. When there is BMPF reading and
|
||||
// a user input enter, we just send the readings to the client app.
|
||||
|
||||
// if (_inputMode == InputModePlainBopomofo) {
|
||||
// if (!_bpmfReadingBuffer->isEmpty()) {
|
||||
// errorCallback();
|
||||
// }
|
||||
// return YES;
|
||||
// }
|
||||
|
||||
[self clear];
|
||||
|
||||
|
|
Loading…
Reference in New Issue