Ensure Plain BPMF tests run with Standard layout
This exposes an issue that our Preferences is a global singleton that uses the user defaults store and is therefore not hermetic.
This commit is contained in:
parent
fda39761ec
commit
5d53b4a93c
|
@ -25,15 +25,22 @@ import XCTest
|
||||||
@testable import McBopomofo
|
@testable import McBopomofo
|
||||||
|
|
||||||
class KeyHandlerPlainBopomofoTests: XCTestCase {
|
class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
|
var savedKeyboardLayout: Int = 0
|
||||||
var handler = KeyHandler()
|
var handler = KeyHandler()
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
LanguageModelManager.loadDataModels()
|
LanguageModelManager.loadDataModels()
|
||||||
handler = KeyHandler()
|
handler = KeyHandler()
|
||||||
handler.inputMode = .plainBopomofo
|
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 {
|
override func tearDownWithError() throws {
|
||||||
|
Preferences.keyboardLayout = savedKeyboardLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPunctuationTable() {
|
func testPunctuationTable() {
|
||||||
|
|
Loading…
Reference in New Issue