diff options
author | 2013-12-12 00:18:28 -0800 | |
---|---|---|
committer | 2013-12-12 00:18:28 -0800 | |
commit | 5a190037e493c88c01d7ccb9ee3c70322e57879d (patch) | |
tree | fc323b2f2ebf56b18a64d40df750abdfbc703a22 /java/src/com/android/inputmethod/latin | |
parent | 589cbdf13d6a06526773949d9366203495563f1f (diff) | |
parent | 5f304d0d71b422d1fd4edc41c71e99181b6e8174 (diff) | |
download | latinime-5a190037e493c88c01d7ccb9ee3c70322e57879d.tar.gz latinime-5a190037e493c88c01d7ccb9ee3c70322e57879d.tar.xz latinime-5a190037e493c88c01d7ccb9ee3c70322e57879d.zip |
am 5f304d0d: Merge "Add waitAllTasksForTests for testing."
* commit '5f304d0d71b422d1fd4edc41c71e99181b6e8174':
Add waitAllTasksForTests for testing.
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r-- | java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 4cc31659c..ed80a9629 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -36,6 +36,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -738,13 +739,19 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } @UsedForTesting - public void shutdownExecutorForTests() { - getExecutor(mDictName).shutdown(); - } - - @UsedForTesting - public boolean isTerminatedForTests() { - return getExecutor(mDictName).isTerminated(); + public void waitAllTasksForTests() { + final CountDownLatch countDownLatch = new CountDownLatch(1); + getExecutor(mDictName).execute(new Runnable() { + @Override + public void run() { + countDownLatch.countDown(); + } + }); + try { + countDownLatch.await(); + } catch (InterruptedException e) { + Log.e(TAG, "Interrupted while waiting for finishing dictionary operations.", e); + } } @UsedForTesting |