diff options
author | 2013-04-15 17:33:48 +0900 | |
---|---|---|
committer | 2013-04-16 18:03:49 +0900 | |
commit | 73ec85b8ad3102ce1c7e6013be73afe83475e589 (patch) | |
tree | 7d1545c756bf5ab4cd1f6a2e14acc11645808a58 /tests/src | |
parent | 252412d7eb4573f91588b06b0fe49ef9f0ac38ac (diff) | |
download | latinime-73ec85b8ad3102ce1c7e6013be73afe83475e589.tar.gz latinime-73ec85b8ad3102ce1c7e6013be73afe83475e589.tar.xz latinime-73ec85b8ad3102ce1c7e6013be73afe83475e589.zip |
Don't insert automatic spaces when text looks like a URL
This is about as ad-hoc as it gets, but then again, what we want
is probably as ad-hoc as it gets.
All URL boxes I know of double as search bars, and not adding
automatic spaces there sucks (e.g. in Chrome URL bar).
And in other boxes actually you don't want to add a space if
it looks like a URL. QSB isn't even a search box, and it behaves
like this.
So I think this is actually the right answer to the problem.
Bug: 7062925
Change-Id: Ib09472b34644fd5bf2dc84bb97cedeeba28bcd02
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/RichInputConnectionTests.java | 5 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/StringUtilsTests.java | 22 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/RichInputConnectionTests.java b/tests/src/com/android/inputmethod/latin/RichInputConnectionTests.java index dc8837dab..aacd60f4d 100644 --- a/tests/src/com/android/inputmethod/latin/RichInputConnectionTests.java +++ b/tests/src/com/android/inputmethod/latin/RichInputConnectionTests.java @@ -85,6 +85,11 @@ public class RichInputConnectionTests extends AndroidTestCase { public boolean endBatchEdit() { return true; } + + @Override + public boolean finishComposingText() { + return true; + } } private class MockInputMethodService extends InputMethodService { diff --git a/tests/src/com/android/inputmethod/latin/StringUtilsTests.java b/tests/src/com/android/inputmethod/latin/StringUtilsTests.java index 98a50b730..1e3cc8ad4 100644 --- a/tests/src/com/android/inputmethod/latin/StringUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/StringUtilsTests.java @@ -215,4 +215,26 @@ public class StringUtilsTests extends AndroidTestCase { checkCapitalize("Lorem!Ipsum (dolor) Sit * Amet", "Lorem!Ipsum (Dolor) Sit * Amet", " \n,.;!?*()&", Locale.ENGLISH); } + + public void testLooksLikeURL() { + assertTrue(StringUtils.lastPartLooksLikeURL("http://www.google.")); + assertFalse(StringUtils.lastPartLooksLikeURL("word wo")); + assertTrue(StringUtils.lastPartLooksLikeURL("/etc/foo")); + assertFalse(StringUtils.lastPartLooksLikeURL("left/right")); + assertTrue(StringUtils.lastPartLooksLikeURL("www.goo")); + assertTrue(StringUtils.lastPartLooksLikeURL("www.")); + assertFalse(StringUtils.lastPartLooksLikeURL("U.S.A")); + assertFalse(StringUtils.lastPartLooksLikeURL("U.S.A.")); + assertTrue(StringUtils.lastPartLooksLikeURL("rtsp://foo.")); + assertTrue(StringUtils.lastPartLooksLikeURL("://")); + assertFalse(StringUtils.lastPartLooksLikeURL("abc/")); + assertTrue(StringUtils.lastPartLooksLikeURL("abc.def/ghi")); + assertFalse(StringUtils.lastPartLooksLikeURL("abc.def")); + // TODO: ideally this would not look like a URL, but to keep down the complexity of the + // code for now True is acceptable. + assertTrue(StringUtils.lastPartLooksLikeURL("abc./def")); + // TODO: ideally this would not look like a URL, but to keep down the complexity of the + // code for now True is acceptable. + assertTrue(StringUtils.lastPartLooksLikeURL(".abc/def")); + } } |