From 68069c55c49d21dcccd0a90369cd0fd61982d8cf Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Tue, 14 Jan 2014 18:18:39 -0800 Subject: [PATCH] Fix flaky unit test. Change-Id: I8df0f9a0398b29f679844f256ad84f09ebcea8ee --- .../android/inputmethod/latin/ExpandableBinaryDictionary.java | 3 ++- .../latin/personalization/UserHistoryDictionaryTests.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 7757d2910..cb5b0e3ef 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -58,6 +58,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { private static final boolean DBG_STRESS_TEST = false; private static final int TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS = 100; + private static final int TIMEOUT_FOR_READ_OPS_FOR_TESTS_IN_MILLISECONDS = 1000; /** * The maximum length of a word in this dictionary. @@ -761,7 +762,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } } }); - return holder.get(false, TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS); + return holder.get(false, TIMEOUT_FOR_READ_OPS_FOR_TESTS_IN_MILLISECONDS); } @UsedForTesting diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java index 17423a7ba..8433569ed 100644 --- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java @@ -105,8 +105,10 @@ public class UserHistoryDictionaryTests extends AndroidTestCase { final UserHistoryDictionary dict = PersonalizationHelper.getUserHistoryDictionary(getContext(), new Locale(testFilenameSuffix)); + dict.waitAllTasksForTests(); dict.clearAndFlushDictionary(); dict.close(); + dict.waitAllTasksForTests(); } /**