diff options
author | 2014-09-29 15:15:07 +0900 | |
---|---|---|
committer | 2014-10-06 23:14:48 +0900 | |
commit | 7b8f3170504ab3f1b4f8eda02ed6f8fb43bdd5cf (patch) | |
tree | 37b80e4c8ab3e8e3979aeb07b87ad76856de9fd9 /tests | |
parent | 4f04fd95f40377e94a35c0385352aa0f16b4695f (diff) | |
download | latinime-7b8f3170504ab3f1b4f8eda02ed6f8fb43bdd5cf.tar.gz latinime-7b8f3170504ab3f1b4f8eda02ed6f8fb43bdd5cf.tar.xz latinime-7b8f3170504ab3f1b4f8eda02ed6f8fb43bdd5cf.zip |
Postponing memory deallocation after onFinishInputView
Bug: 17559789
Change-Id: I1d4b1524028164d27ec4eadd3960b567148f2b84
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()); + } +} |