mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-27 04:07:10 +00:00
switch tests from junit to kotlin.test (mostly)
This commit is contained in:
parent
da8827efc3
commit
df8c0c6c59
8 changed files with 26 additions and 24 deletions
|
@ -109,6 +109,7 @@ dependencies {
|
|||
implementation("com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0")
|
||||
|
||||
// test
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("org.mockito:mockito-core:5.15.2")
|
||||
testImplementation("org.robolectric:robolectric:4.12.1")
|
||||
|
|
|
@ -2,8 +2,8 @@ package helium314.keyboard
|
|||
|
||||
import helium314.keyboard.keyboard.internal.KeySpecParser
|
||||
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class KeySpecParserTest {
|
||||
@Test fun label() {
|
||||
|
|
|
@ -9,6 +9,7 @@ import helium314.keyboard.keyboard.Keyboard
|
|||
import helium314.keyboard.keyboard.KeyboardId
|
||||
import helium314.keyboard.keyboard.KeyboardLayoutSet
|
||||
import helium314.keyboard.keyboard.internal.KeySpecParser
|
||||
import helium314.keyboard.keyboard.internal.KeySpecParser.KeySpecParserError
|
||||
import helium314.keyboard.keyboard.internal.KeyboardBuilder
|
||||
import helium314.keyboard.keyboard.internal.KeyboardParams
|
||||
import helium314.keyboard.keyboard.internal.TouchPositionCorrection
|
||||
|
@ -22,11 +23,6 @@ import helium314.keyboard.latin.RichInputMethodSubtype
|
|||
import helium314.keyboard.latin.utils.AdditionalSubtypeUtils.createEmojiCapableAdditionalSubtype
|
||||
import helium314.keyboard.latin.utils.POPUP_KEYS_LAYOUT
|
||||
import helium314.keyboard.latin.utils.checkKeys
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
@ -35,6 +31,11 @@ import org.robolectric.annotation.Implementation
|
|||
import org.robolectric.annotation.Implements
|
||||
import org.robolectric.shadows.ShadowLog
|
||||
import java.util.Locale
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(shadows = [
|
||||
|
@ -45,8 +46,7 @@ class ParserTest {
|
|||
private lateinit var latinIME: LatinIME
|
||||
private lateinit var params: KeyboardParams
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
@BeforeTest fun setUp() {
|
||||
latinIME = Robolectric.setupService(LatinIME::class.java)
|
||||
ShadowLog.setupLogging()
|
||||
ShadowLog.stream = System.out
|
||||
|
@ -320,7 +320,7 @@ f""", // no newline at the end
|
|||
}
|
||||
|
||||
@Test fun invalidKeys() {
|
||||
assertThrows(KeySpecParser.KeySpecParserError::class.java) {
|
||||
assertFailsWith<KeySpecParserError> {
|
||||
RawKeyboardParser.parseJsonString("""[[{ "label": "!icon/clipboard_action_key" }]]""").map { it.mapNotNull { it.compute(params)?.toKeyParams(params) } }
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ f""", // no newline at the end
|
|||
}
|
||||
|
||||
@Test fun invalidPopupKeys() {
|
||||
assertThrows(KeySpecParser.KeySpecParserError::class.java) {
|
||||
assertFailsWith<KeySpecParserError> {
|
||||
RawKeyboardParser.parseJsonString("""[[{ "label": "a", "popup": {
|
||||
"main": { "label": "!icon/clipboard_action_key" }
|
||||
} }]]""").map { it.mapNotNull { it.compute(params)?.toKeyParams(params) } }
|
||||
|
|
|
@ -24,9 +24,6 @@ import helium314.keyboard.latin.inputlogic.SpaceState
|
|||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||
import helium314.keyboard.latin.utils.ScriptUtils
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.robolectric.Robolectric
|
||||
|
@ -37,6 +34,9 @@ import org.robolectric.annotation.Implements
|
|||
import org.robolectric.shadows.ShadowLog
|
||||
import java.util.*
|
||||
import kotlin.math.min
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(shadows = [
|
||||
|
@ -61,7 +61,8 @@ class InputLogicTest {
|
|||
private val composingReader = RichInputConnection::class.java.getDeclaredField("mComposingText").apply { isAccessible = true }
|
||||
private val connectionComposingText get() = (composingReader.get(connection) as CharSequence).toString()
|
||||
|
||||
@Before fun setUp() {
|
||||
@BeforeTest
|
||||
fun setUp() {
|
||||
latinIME = Robolectric.setupService(LatinIME::class.java)
|
||||
// start logging only after latinIME is created, avoids showing the stack traces if library is not found
|
||||
ShadowLog.setupLogging()
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
package helium314.keyboard.latin
|
||||
|
||||
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class LocaleUtilsTest {
|
||||
@Test fun createLocales() {
|
||||
|
|
|
@ -6,8 +6,8 @@ import helium314.keyboard.latin.utils.ScriptUtils.SCRIPT_CYRILLIC
|
|||
import helium314.keyboard.latin.utils.ScriptUtils.SCRIPT_DEVANAGARI
|
||||
import helium314.keyboard.latin.utils.ScriptUtils.SCRIPT_LATIN
|
||||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ScriptUtilsTest {
|
||||
@Test fun defaultScript() {
|
||||
|
|
|
@ -3,8 +3,8 @@ package helium314.keyboard.latin
|
|||
|
||||
import helium314.keyboard.latin.common.StringUtils
|
||||
import helium314.keyboard.latin.common.getFullEmojiAtEnd
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
// todo: actually this test could/should be significantly expanded...
|
||||
class StringUtilsTest {
|
||||
|
|
|
@ -15,8 +15,6 @@ import helium314.keyboard.latin.settings.Settings
|
|||
import helium314.keyboard.latin.settings.SettingsValuesForSuggestion
|
||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||
import helium314.keyboard.latin.utils.SuggestionResults
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
@ -25,6 +23,8 @@ import org.robolectric.annotation.Implementation
|
|||
import org.robolectric.annotation.Implements
|
||||
import org.robolectric.shadows.ShadowLog
|
||||
import java.util.*
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
|
||||
@Suppress("NonAsciiCharacters")
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
|
@ -43,7 +43,7 @@ class SuggestTest {
|
|||
private val thresholdAggressive = "1"
|
||||
private val thresholdVeryAggressive = "2"
|
||||
|
||||
@Before fun setUp() {
|
||||
@BeforeTest fun setUp() {
|
||||
latinIME = Robolectric.setupService(LatinIME::class.java)
|
||||
// start logging only after latinIME is created, avoids showing the stack traces if library is not found
|
||||
ShadowLog.setupLogging()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue