add input logic test for double space -> period (and deletion)

This commit is contained in:
Helium314 2024-05-12 12:00:49 +02:00
parent 8f3e4fff8c
commit b3aac1a05a

View file

@ -535,6 +535,16 @@ class InputLogicTest {
assertEquals("\"this i", text) assertEquals("\"this i", text)
} }
@Test fun `double space results in period and space, and delete removes the period`() {
reset()
chainInput("hello")
input(' ')
input(' ')
assertEquals("hello. ", text)
functionalKeyPress(KeyCode.DELETE)
assertEquals("hello ", text)
}
// ------- helper functions --------- // ------- helper functions ---------
// should be called before every test, so the same state is guaranteed // should be called before every test, so the same state is guaranteed
@ -566,7 +576,9 @@ class InputLogicTest {
latinIME.onEvent(Event.createEventForCodePointFromUnknownSource(codePoint)) latinIME.onEvent(Event.createEventForCodePointFromUnknownSource(codePoint))
handleMessages() handleMessages()
if (currentScript != ScriptUtils.SCRIPT_HANGUL) { // check fails if hangul combiner merges symbols if (currentScript != ScriptUtils.SCRIPT_HANGUL // check fails if hangul combiner merges symbols
&& !(codePoint == Constants.CODE_SPACE && oldBefore.lastOrNull() == ' ') // check fails when 2 spaces are converted into a period
) {
if (phantomSpaceToInsert.isEmpty()) if (phantomSpaceToInsert.isEmpty())
assertEquals(oldBefore + insert, textBeforeCursor) assertEquals(oldBefore + insert, textBeforeCursor)
else // in some cases autospace might be suppressed else // in some cases autospace might be suppressed