diff options
author | 2014-10-06 23:45:37 +0000 | |
---|---|---|
committer | 2014-10-06 23:45:40 +0000 | |
commit | 639837f85d648443359ac1883aa6f9c11e287c33 (patch) | |
tree | 7aacd97095571d75077960d552acce43cd35cc08 /tests | |
parent | 7a2e38ad403fdc9a1c5450862db6256e8108d007 (diff) | |
parent | 7b8f3170504ab3f1b4f8eda02ed6f8fb43bdd5cf (diff) | |
download | latinime-639837f85d648443359ac1883aa6f9c11e287c33.tar.gz latinime-639837f85d648443359ac1883aa6f9c11e287c33.tar.xz latinime-639837f85d648443359ac1883aa6f9c11e287c33.zip |
Merge "Postponing memory deallocation after onFinishInputView"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/LatinIMEForTests.java | 12 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/LatinImeTests.java | 40 |
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/LatinIMEForTests.java b/tests/src/com/android/inputmethod/latin/LatinIMEForTests.java index e47c55736..035c8d7ce 100644 --- a/tests/src/com/android/inputmethod/latin/LatinIMEForTests.java +++ b/tests/src/com/android/inputmethod/latin/LatinIMEForTests.java @@ -21,4 +21,16 @@ public class LatinIMEForTests extends LatinIME { public boolean isInputViewShown() { return true; } + + private boolean deallocateMemoryWasPerformed = false; + + @Override + protected void deallocateMemory() { + super.deallocateMemory(); + deallocateMemoryWasPerformed = true; + } + + public boolean getDeallocateMemoryWasPerformed() { + return deallocateMemoryWasPerformed; + } } diff --git a/tests/src/com/android/inputmethod/latin/LatinImeTests.java b/tests/src/com/android/inputmethod/latin/LatinImeTests.java new file mode 100644 index 000000000..c6f631328 --- /dev/null +++ b/tests/src/com/android/inputmethod/latin/LatinImeTests.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.inputmethod.latin; + +import android.test.suitebuilder.annotation.LargeTest; + +@LargeTest +public class LatinImeTests extends InputTestsBase { + public void testDeferredDeallocation_doesntHappenBeforeTimeout() { + mLatinIME.mHandler.onFinishInputView(true); + runMessages(); + sleep(1000); // 1s + runMessages(); + assertFalse("memory deallocation performed before timeout passed", + ((LatinIMEForTests)mLatinIME).getDeallocateMemoryWasPerformed()); + } + + public void testDeferredDeallocation_doesHappenAfterTimeout() { + mLatinIME.mHandler.onFinishInputView(true); + runMessages(); + sleep(11000); // 11s (timeout is at 10s) + runMessages(); + assertTrue("memory deallocation not performed although timeout passed", + ((LatinIMEForTests)mLatinIME).getDeallocateMemoryWasPerformed()); + } +} |