diff options
author | 2015-04-06 18:19:09 +0000 | |
---|---|---|
committer | 2015-04-06 18:19:09 +0000 | |
commit | 5382c83909958f913bfdbd6a5741222e3f74b9d1 (patch) | |
tree | 107b5f067cab83a2c3ca0a731d51b400b85d6f84 /tests/src | |
parent | 0fa3b22f17b1659c96942d38386c3ccd3fb4c501 (diff) | |
parent | ec2891b007ac6322bd66aedca217ad4e22b6a85b (diff) | |
download | latinime-5382c83909958f913bfdbd6a5741222e3f74b9d1.tar.gz latinime-5382c83909958f913bfdbd6a5741222e3f74b9d1.tar.xz latinime-5382c83909958f913bfdbd6a5741222e3f74b9d1.zip |
am ec2891b0: Define stats for UserDictionaryLookup.
* commit 'ec2891b007ac6322bd66aedca217ad4e22b6a85b':
Define stats for UserDictionaryLookup.
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/UserDictionaryLookupTest.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/UserDictionaryLookupTest.java b/tests/src/com/android/inputmethod/latin/UserDictionaryLookupTest.java index d8060f286..917140ab5 100644 --- a/tests/src/com/android/inputmethod/latin/UserDictionaryLookupTest.java +++ b/tests/src/com/android/inputmethod/latin/UserDictionaryLookupTest.java @@ -309,6 +309,52 @@ public class UserDictionaryLookupTest extends AndroidTestCase { lookup.close(); } + public void testDictionaryStats() { + Log.d(TAG, "testDictionaryStats"); + + // Insert "foo" and "bar". Only "foo" has a shortcut. + Uri uri = addWord("foo", Locale.GERMANY, 17, "f"); + addWord("bar", Locale.GERMANY, 17, null); + + // Create the UserDictionaryLookup and wait until it's loaded. + UserDictionaryLookup lookup = new UserDictionaryLookup(mContext, ExecutorUtils.SPELLING); + lookup.open(); + while (!lookup.isLoaded()) { + } + + // "foo" should match. + assertTrue(lookup.isValidWord("foo", Locale.GERMANY)); + + // "bar" should match. + assertTrue(lookup.isValidWord("bar", Locale.GERMANY)); + + // "foo" should have a shortcut. + assertEquals("foo", lookup.expandShortcut("f", Locale.GERMANY)); + + // Now delete "foo". + deleteWord(uri); + + // Wait a little bit before expecting a change. The time we wait should be greater than + // UserDictionaryLookup.RELOAD_DELAY_MS. + try { + Thread.sleep(UserDictionaryLookup.RELOAD_DELAY_MS + 1000); + } catch (InterruptedException e) { + } + + // Perform lookups again. Reload should have occured. + // + // "foo" should not match. + assertFalse(lookup.isValidWord("foo", Locale.GERMANY)); + + // "foo" should not have a shortcut. + assertNull(lookup.expandShortcut("f", Locale.GERMANY)); + + // "bar" should still match. + assertTrue(lookup.isValidWord("bar", Locale.GERMANY)); + + lookup.close(); + } + public void testClose() { Log.d(TAG, "testClose"); |