aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.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/InputLogic.java
parenta4ac18551f6bf6ca7ee84139e8cea3656a4a8b86 (diff)
downloadlatinime-4370ff0998d3240cfda7745d08edbdd11703b984.tar.gz
latinime-4370ff0998d3240cfda7745d08edbdd11703b984.tar.xz
latinime-4370ff0998d3240cfda7745d08edbdd11703b984.zip
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/InputLogic.java')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 7cf8c5e49..0754b1fa9 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -148,6 +148,17 @@ public final class InputLogic {
mInputLogicHandler.reset();
}
+ // Normally this class just gets out of scope after the process ends, but in unit tests, we
+ // create several instances of LatinIME in the same process, which results in several
+ // instances of InputLogic. This cleans up the associated handler so that tests don't leak
+ // handlers.
+ public void recycle() {
+ final InputLogicHandler inputLogicHandler = mInputLogicHandler;
+ mInputLogicHandler = InputLogicHandler.NULL_HANDLER;
+ inputLogicHandler.destroy();
+ mSuggest.mDictionaryFacilitator.closeDictionaries();
+ }
+
/**
* React to a string input.
*