Skip to content

Commit

Permalink
add another test, situation may need improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed Sep 26, 2023
1 parent 3447212 commit 22a5c6d
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class InputLogicTest {
@Test fun urlProperlySelected() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
setText("http://example.com/here")
setCursorPosition(18) // after .com
functionalKeyPress(Constants.CODE_DELETE)
Expand All @@ -327,6 +328,21 @@ class InputLogicTest {
assertEquals("example.net", composingText)
}

@Test fun urlProperlySelectedWhenNotDeletingFullTld() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
setText("http://example.com/here")
setCursorPosition(18) // after .com
functionalKeyPress(Constants.CODE_DELETE)
functionalKeyPress(Constants.CODE_DELETE) // delete om
// todo: this is a weird difference to deleting the full TLD (see urlProperlySelected)
// what do we want here? (probably consistency)
assertEquals("example.c/here", composingText)
chainInput("z")
assertEquals("", composingText) // todo: this is a weird difference to deleting the full TLD
// assertEquals("example.cz", composingText) // fails, but probably would be better than above
}

@Test fun dontCommitPartialUrlBeforeFirstPeriod() {
reset()
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
Expand Down

0 comments on commit 22a5c6d

Please sign in to comment.