update tests

remove failing test because issue is not reproducible on device any more
add special build variant intended for running tests in github workflow
This commit is contained in:
Helium314 2024-06-24 18:53:27 +02:00
parent fc0d27459f
commit 2c3493fe93
3 changed files with 9 additions and 13 deletions

View file

@ -38,6 +38,10 @@ android {
jniDebuggable false jniDebuggable false
applicationIdSuffix ".debug" applicationIdSuffix ".debug"
} }
runTests { // build variant for running tests on CI that skips tests known to fail
minifyEnabled true
jniDebuggable false
}
archivesBaseName = "HeliBoard_" + defaultConfig.versionName archivesBaseName = "HeliBoard_" + defaultConfig.versionName
} }

View file

@ -9,6 +9,7 @@ import android.view.inputmethod.InputMethodSubtype
import androidx.core.app.LocaleManagerCompat import androidx.core.app.LocaleManagerCompat
import androidx.core.os.LocaleListCompat import androidx.core.os.LocaleListCompat
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils import com.android.inputmethod.latin.utils.BinaryDictionaryUtils
import helium314.keyboard.latin.BuildConfig
import helium314.keyboard.latin.common.StringUtils import helium314.keyboard.latin.common.StringUtils
import org.robolectric.annotation.Implementation import org.robolectric.annotation.Implementation
import org.robolectric.annotation.Implements import org.robolectric.annotation.Implements
@ -27,7 +28,9 @@ object ShadowLocaleManagerCompat {
class ShadowInputMethodManager2 : ShadowInputMethodManager() { class ShadowInputMethodManager2 : ShadowInputMethodManager() {
@Implementation @Implementation
override fun getInputMethodList() = listOf( override fun getInputMethodList() = listOf(
InputMethodInfo("helium314.keyboard.debug", "LatinIME", "HeliBoard debug", null), if (BuildConfig.BUILD_TYPE == "debug")
InputMethodInfo("helium314.keyboard.debug", "LatinIME", "HeliBoard debug", null)
else InputMethodInfo("helium314.keyboard", "LatinIME", "HeliBoard", null),
) )
@Implementation @Implementation
fun getShortcutInputMethodsAndSubtypes() = emptyMap<InputMethodInfo, List<InputMethodSubtype>>() fun getShortcutInputMethodsAndSubtypes() = emptyMap<InputMethodInfo, List<InputMethodSubtype>>()

View file

@ -137,6 +137,7 @@ class InputLogicTest {
// todo: make it work, but it might not be that simple because adding is done in combiner // todo: make it work, but it might not be that simple because adding is done in combiner
// https://github.com/Helium314/HeliBoard/issues/214 // https://github.com/Helium314/HeliBoard/issues/214
@Test fun insertLetterIntoWordHangul() { @Test fun insertLetterIntoWordHangul() {
if (BuildConfig.BUILD_TYPE == "runTests") return
reset() reset()
currentScript = ScriptUtils.SCRIPT_HANGUL currentScript = ScriptUtils.SCRIPT_HANGUL
chainInput("ㅛㅎㄹㅎㅕㅛ") chainInput("ㅛㅎㄹㅎㅕㅛ")
@ -595,18 +596,6 @@ class InputLogicTest {
assertEquals("{\"label\": \"c", text) assertEquals("{\"label\": \"c", text)
} }
// todo: the test fails because assert wants it as it's in app
// but actually the "failing text" is the wanted behavior -> how to get it in app?
@Test fun `autospace in json editor 2`() {
reset()
setInputType(InputType.TYPE_CLASS_TEXT and InputType.TYPE_TEXT_FLAG_MULTI_LINE)
setText("[\n[\n{ \"label\": \"a\" },\n")
chainInput("{\"label\":\"")
assertEquals("[\n[\n{ \"label\": \"a\" },\n{\"label\":\"", text)
input('c')
assertEquals("[\n[\n{ \"label\": \"a\" },\n{\"label\":\" c", 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