From 4370ff0998d3240cfda7745d08edbdd11703b984 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 7 Apr 2014 22:32:06 +0900 Subject: 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 --- .../com/android/inputmethod/latin/inputlogic/InputLogic.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java') 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. * -- cgit v1.2.3-83-g751a