mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 15:32:48 +00:00
add test & fix for another url detection auto-space issue
This commit is contained in:
parent
ea17006570
commit
0187beeae5
3 changed files with 14 additions and 3 deletions
|
@ -85,7 +85,7 @@ dependencies {
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.mockito:mockito-core:3.12.4'
|
testImplementation 'org.mockito:mockito-core:3.12.4'
|
||||||
testImplementation 'org.mockito:mockito-inline:3.12.4'
|
testImplementation 'org.mockito:mockito-inline:3.12.4'
|
||||||
testImplementation 'org.robolectric:robolectric:4.10.3'
|
testImplementation 'org.robolectric:robolectric:4.11.1'
|
||||||
testImplementation 'androidx.test:runner:1.5.2'
|
testImplementation 'androidx.test:runner:1.5.2'
|
||||||
testImplementation 'androidx.test:core:1.5.0'
|
testImplementation 'androidx.test:core:1.5.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ fun nonWordCodePointAndNoSpaceBeforeCursor(s: CharSequence, spacingAndPunctuatio
|
||||||
loopOverCodePointsBackwards(s) {
|
loopOverCodePointsBackwards(s) {
|
||||||
if (!space && Character.isWhitespace(it))
|
if (!space && Character.isWhitespace(it))
|
||||||
space = true
|
space = true
|
||||||
if (!nonWordCodePoint && !spacingAndPunctuations.isWordCodePoint(it))
|
// treat double quote like a word codepoint for the purpose of this function (not great, maybe clarify name, or extend list of chars?)
|
||||||
|
if (!nonWordCodePoint && !spacingAndPunctuations.isWordCodePoint(it) && it != '"'.code)
|
||||||
nonWordCodePoint = true
|
nonWordCodePoint = true
|
||||||
space && nonWordCodePoint // stop if both are found
|
space && nonWordCodePoint // stop if both are found
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import kotlin.math.min
|
||||||
ShadowKeyboardSwitcher::class,
|
ShadowKeyboardSwitcher::class,
|
||||||
ShadowHandler::class,
|
ShadowHandler::class,
|
||||||
ShadowFacilitator2::class,
|
ShadowFacilitator2::class,
|
||||||
], sdk = [33]) // todo: remove workaround after upgrading robolectric to 4.11
|
])
|
||||||
class InputLogicTest {
|
class InputLogicTest {
|
||||||
private lateinit var latinIME: LatinIME
|
private lateinit var latinIME: LatinIME
|
||||||
private val settingsValues get() = Settings.getInstance().current
|
private val settingsValues get() = Settings.getInstance().current
|
||||||
|
@ -523,6 +523,16 @@ class InputLogicTest {
|
||||||
assertEquals("h", composingText)
|
assertEquals("h", composingText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun `autospace works in URL field when starting with quotes`() {
|
||||||
|
reset()
|
||||||
|
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
|
input("\"")
|
||||||
|
pickSuggestion("this")
|
||||||
|
input("i")
|
||||||
|
assertEquals("\"this i", 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue