diff options
author | 2015-04-06 09:19:23 -0700 | |
---|---|---|
committer | 2015-04-06 11:10:55 -0700 | |
commit | ec2891b007ac6322bd66aedca217ad4e22b6a85b (patch) | |
tree | bdec1ddcd12fef482352aed2f38bfa3edbc6988b /tests/src/com/android/inputmethod/latin/UserDictionaryLookupTest.java | |
parent | c79ed10cf74c464bc9d6a32135ccb50d99998daf (diff) | |
download | latinime-ec2891b007ac6322bd66aedca217ad4e22b6a85b.tar.gz latinime-ec2891b007ac6322bd66aedca217ad4e22b6a85b.tar.xz latinime-ec2891b007ac6322bd66aedca217ad4e22b6a85b.zip |
Define stats for UserDictionaryLookup.
Bug 20071513.
Change-Id: Iaab909575da29bfe6e17bb3865ce51d1e7720e7c
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/UserDictionaryLookupTest.java')
-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"); |