summaryrefslogtreecommitdiff
path: root/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-04-07 22:32:06 +0900
committerJean Chalard <jchalard@google.com>2014-04-10 17:32:05 +0900
commit4370ff0998d3240cfda7745d08edbdd11703b984 (patch)
treebe63baa9809d7b3541c55ec4f11c6af2e5f1cff5 /java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
parenta4ac18551f6bf6ca7ee84139e8cea3656a4a8b86 (diff)
Fix some flaky tests.
In tests, we create many instances of LatinIME, but we never destroy them. That means we never close the dictionaries nor the handlers. This change calls onDestroy, which closes all dictionaries, and adds some code to finish the handlers. Change-Id: I942517a2a940c54256b08763f6b38f5b55809f55
Diffstat (limited to 'java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
index e3b8ab465..64bba681f 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
@@ -20,6 +20,7 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
+import com.android.inputmethod.compat.LooperCompatUtils;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.Suggest;
@@ -80,6 +81,12 @@ class InputLogicHandler implements Handler.Callback {
mNonUIThreadHandler.removeCallbacksAndMessages(null);
}
+ // In unit tests, we create several instances of LatinIME, which results in several instances
+ // of InputLogicHandler. To avoid these handlers lingering, we call this.
+ public void destroy() {
+ LooperCompatUtils.quitSafely(mNonUIThreadHandler.getLooper());
+ }
+
/**
* Handle a message.
* @see android.os.Handler.Callback#handleMessage(android.os.Message)