Merge pull request #293 from lukhnos/empty-state-regression
Fixes regression in how upper case letters are handled when input state is empty
This commit is contained in:
commit
34f29fd771
|
@ -38,6 +38,10 @@ jobs:
|
|||
- name: Test NSStringUtils
|
||||
run: swift test
|
||||
working-directory: Packages/NSStringUtils
|
||||
- name: Clean McBopomofo for testing
|
||||
run: xcodebuild -scheme McBopomofo -configuration Debug clean
|
||||
- name: Test McBopomofo
|
||||
run: xcodebuild -scheme McBopomofo -configuration Debug test
|
||||
- name: Clean McBopomofo
|
||||
run: xcodebuild -scheme McBopomofo -configuration Release clean
|
||||
- name: Clean McBopomofoInstaller
|
||||
|
|
|
@ -38,6 +38,10 @@ jobs:
|
|||
- name: Test NSStringUtils
|
||||
run: swift test
|
||||
working-directory: Packages/NSStringUtils
|
||||
- name: Clean McBopomofo for testing
|
||||
run: xcodebuild -scheme McBopomofo -configuration Debug clean
|
||||
- name: Test McBopomofo
|
||||
run: xcodebuild -scheme McBopomofo -configuration Debug test
|
||||
- name: Clean McBopomofo
|
||||
run: xcodebuild -scheme McBopomofo -configuration Release clean
|
||||
- name: Clean McBopomofoInstaller
|
||||
|
|
|
@ -266,17 +266,40 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
func testLetter() {
|
||||
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: charCode("A"), flags: .shift, isVerticalMode: false)
|
||||
// Regression test for #292.
|
||||
func testUppercaseLetterWhenEmpty() {
|
||||
let input = KeyHandlerInput(inputText: "A", keyCode: KeyCode.enter.rawValue, charCode: charCode("A"), flags: [], isVerticalMode: false)
|
||||
var state: InputState = InputState.Empty()
|
||||
handler.handle(input: input, state: state) { newState in
|
||||
let result = handler.handle(input: input, state: state) { newState in
|
||||
state = newState
|
||||
} errorCallback: {
|
||||
}
|
||||
XCTAssertFalse(result)
|
||||
}
|
||||
|
||||
// Regression test for #292.
|
||||
func testUppercaseLetterWhenNotEmpty() {
|
||||
var state: InputState = InputState.Empty()
|
||||
let keys = Array("u6").map {
|
||||
String($0)
|
||||
}
|
||||
for key in keys {
|
||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||
handler.handle(input: input, state: state) { newState in
|
||||
state = newState
|
||||
} errorCallback: {
|
||||
}
|
||||
}
|
||||
|
||||
let letterInput = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: charCode("A"), flags: .shift, isVerticalMode: false)
|
||||
handler.handle(input: letterInput, state: state) { newState in
|
||||
state = newState
|
||||
} errorCallback: {
|
||||
}
|
||||
|
||||
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||
if let state = state as? InputState.Inputting {
|
||||
XCTAssertEqual(state.composingBuffer, "a")
|
||||
XCTAssertEqual(state.composingBuffer, "一a")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,15 +25,33 @@ import XCTest
|
|||
@testable import McBopomofo
|
||||
|
||||
class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||
var savedKeyboardLayout: Int = 0
|
||||
var handler = KeyHandler()
|
||||
|
||||
override func setUpWithError() throws {
|
||||
LanguageModelManager.loadDataModels()
|
||||
handler = KeyHandler()
|
||||
handler.inputMode = .plainBopomofo
|
||||
|
||||
savedKeyboardLayout = Preferences.keyboardLayout
|
||||
|
||||
// Punctuation-related tests only work when the layout is Standard.
|
||||
Preferences.keyboardLayout = KeyboardLayout.standard.rawValue
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
Preferences.keyboardLayout = savedKeyboardLayout
|
||||
}
|
||||
|
||||
// Regression test for #292.
|
||||
func testUppercaseLetterWhenEmpty() {
|
||||
let input = KeyHandlerInput(inputText: "A", keyCode: KeyCode.enter.rawValue, charCode: charCode("A"), flags: [], isVerticalMode: false)
|
||||
var state: InputState = InputState.Empty()
|
||||
let result = handler.handle(input: input, state: state) { newState in
|
||||
state = newState
|
||||
} errorCallback: {
|
||||
}
|
||||
XCTAssertFalse(result)
|
||||
}
|
||||
|
||||
func testPunctuationTable() {
|
||||
|
|
|
@ -541,7 +541,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
|||
return YES;
|
||||
}
|
||||
|
||||
if ((char) charCode >= 'A' && (char) charCode <= 'Z') {
|
||||
if ([state isKindOfClass:[InputStateNotEmpty class]] && (char) charCode >= 'A' && (char) charCode <= 'Z') {
|
||||
string letter = string("_letter_") + string(1, (char) charCode);
|
||||
if ([self _handlePunctuation:letter state:state usingVerticalMode:input.useVerticalMode stateCallback:stateCallback errorCallback:errorCallback]) {
|
||||
return YES;
|
||||
|
|
Loading…
Reference in New Issue