diff options
author | 2013-12-12 17:08:51 +0900 | |
---|---|---|
committer | 2013-12-12 17:08:51 +0900 | |
commit | d06de553b2ac21dff9c8819eb59eda7bcba3f5e0 (patch) | |
tree | 6ff2de44f274470560cbd1134a41600a3d87fcec /java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java | |
parent | 9ff51527a398a6db15d67e9a592785fd3bce542b (diff) | |
download | latinime-d06de553b2ac21dff9c8819eb59eda7bcba3f5e0.tar.gz latinime-d06de553b2ac21dff9c8819eb59eda7bcba3f5e0.tar.xz latinime-d06de553b2ac21dff9c8819eb59eda7bcba3f5e0.zip |
Add waitAllTasksForTests for testing.
Bug: 10667710
Change-Id: I7a189e32286a6005393fbde8da736541ca9226a8
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java')
-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 |