diff options
author | 2013-09-27 11:13:22 +0900 | |
---|---|---|
committer | 2013-09-27 16:46:34 +0900 | |
commit | a328f538c34ad2dafdfa53642085cb1072224d80 (patch) | |
tree | c9d3fff6dfe6c3fa23d68cc99a4fcb70847a7ef3 /tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java | |
parent | 781feb748cc59d3d34e9b52553cac192f1699dce (diff) | |
download | latinime-a328f538c34ad2dafdfa53642085cb1072224d80.tar.gz latinime-a328f538c34ad2dafdfa53642085cb1072224d80.tar.xz latinime-a328f538c34ad2dafdfa53642085cb1072224d80.zip |
Fix PrioritizedSerialExecutor.
It was possible that fetchNextTasks() would be called by multiple
threads concurrently.
If it happens, some tasks in the task queues might be ignored.
Change-Id: Idc81c43c45e382da3850cc55b9a42c281548d2a8
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java index d605cdb84..06c427193 100644 --- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java @@ -84,29 +84,24 @@ public class UserHistoryDictionaryTests extends AndroidTestCase { } /** - * @param checksContents if true, checks whether written words are actually in the dictionary + * @param checkContents if true, checks whether written words are actually in the dictionary * or not. */ private void addAndWriteRandomWords(final String testFilenameSuffix, final int numberOfWords, - final Random random, final boolean checksContents) { + final Random random, final boolean checkContents) { final List<String> words = generateWords(numberOfWords, random); final UserHistoryPredictionDictionary dict = PersonalizationHelper.getUserHistoryPredictionDictionary(getContext(), testFilenameSuffix /* locale */, mPrefs); // Add random words to the user history dictionary. addToDict(dict, words); - if (checksContents) { + if (checkContents) { try { Thread.sleep(TimeUnit.MILLISECONDS.convert(5L, TimeUnit.SECONDS)); } catch (InterruptedException e) { } - // Limit word count to check when using a Java on memory dictionary. - final int wordCountToCheck = - ExpandableBinaryDictionary.ENABLE_BINARY_DICTIONARY_DYNAMIC_UPDATE ? - numberOfWords : 10; - for (int i = 0; i < wordCountToCheck; ++i) { + for (int i = 0; i < numberOfWords; ++i) { final String word = words.get(i); - // This may fail as long as we use tryLock on inserting the bigram words assertTrue(dict.isInDictionaryForTests(word)); } } |