Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/src/androidTest/kotlin/be/scri/helpers/KeyboardTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
package be.scri.helpers

import android.view.KeyEvent
import android.view.inputmethod.InputConnection
import android.widget.Button
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -71,6 +72,26 @@ class KeyboardTest {
verify(exactly = 1) { mockInputConnection.deleteSurroundingText(1, 0) }
}

@Test
fun testEnterKeyInsertsNewLine() {
every { mockIME.currentState } returns ScribeState.IDLE
// Simulate the IME behavior for Enter key: sending ACTION_DOWN and ACTION_UP events.
every { mockIME.handleKeycodeEnter() } answers {
mockInputConnection.sendKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER))
mockInputConnection.sendKeyEvent(KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER))
}

keyHandler.handleKey(KeyboardBase.KEYCODE_ENTER, "en")

verify(exactly = 1) { mockIME.handleKeycodeEnter() }
verify(exactly = 1) {
mockInputConnection.sendKeyEvent(match { it.action == KeyEvent.ACTION_DOWN && it.keyCode == KeyEvent.KEYCODE_ENTER })
}
verify(exactly = 1) {
mockInputConnection.sendKeyEvent(match { it.action == KeyEvent.ACTION_UP && it.keyCode == KeyEvent.KEYCODE_ENTER })
}
}

@Test
fun processSuggestions() {
every { mockIME.findGenderForLastWord(any(), "in") } returns listOf("Neuter")
Expand Down
Loading