aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2013-12-12 17:08:51 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2013-12-12 17:08:51 +0900
commitd06de553b2ac21dff9c8819eb59eda7bcba3f5e0 (patch)
tree6ff2de44f274470560cbd1134a41600a3d87fcec /tests/src
parent9ff51527a398a6db15d67e9a592785fd3bce542b (diff)
downloadlatinime-d06de553b2ac21dff9c8819eb59eda7bcba3f5e0.tar.gz
latinime-d06de553b2ac21dff9c8819eb59eda7bcba3f5e0.tar.xz
latinime-d06de553b2ac21dff9c8819eb59eda7bcba3f5e0.zip
Add waitAllTasksForTests for testing.
Bug: 10667710 Change-Id: I7a189e32286a6005393fbde8da736541ca9226a8
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java27
1 files changed, 7 insertions, 20 deletions
diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
index 68e94c816..17423a7ba 100644
--- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
@@ -43,9 +43,6 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
};
- private static final int MIN_USER_HISTORY_DICTIONARY_FILE_SIZE = 1000;
- private static final int WAIT_TERMINATING_IN_MILLISECONDS = 100;
-
/**
* Generates a random word.
*/
@@ -71,8 +68,8 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
private void addToDict(final UserHistoryDictionary dict, final List<String> words) {
String prevWord = null;
for (String word : words) {
- // TODO: Use timestamp properly.
- dict.addToDictionary(prevWord, word, true, 0 /* timestamp */);
+ dict.addToDictionary(prevWord, word, true,
+ (int)TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
prevWord = word;
}
}
@@ -90,10 +87,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
// Add random words to the user history dictionary.
addToDict(dict, words);
if (checkContents) {
- try {
- Thread.sleep(TimeUnit.MILLISECONDS.convert(5L, TimeUnit.SECONDS));
- } catch (InterruptedException e) {
- }
+ dict.waitAllTasksForTests();
for (int i = 0; i < numberOfWords; ++i) {
final String word = words.get(i);
assertTrue(dict.isInDictionaryForTests(word));
@@ -120,17 +114,10 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
* @param testFilenameSuffix file name suffix used for testing.
*/
private void waitForWriting(final String testFilenameSuffix) {
- try {
- final UserHistoryDictionary dict =
- PersonalizationHelper.getUserHistoryDictionary(getContext(),
- new Locale(testFilenameSuffix));
- dict.shutdownExecutorForTests();
- while (!dict.isTerminatedForTests()) {
- Thread.sleep(WAIT_TERMINATING_IN_MILLISECONDS);
- }
- } catch (InterruptedException e) {
- Log.d(TAG, "InterruptedException: ", e);
- }
+ final UserHistoryDictionary dict =
+ PersonalizationHelper.getUserHistoryDictionary(getContext(),
+ new Locale(testFilenameSuffix));
+ dict.waitAllTasksForTests();
}
public void testRandomWords() {