summaryrefslogtreecommitdiffstats
path: root/core/tests/coretests
diff options
context:
space:
mode:
authorMattias Niklewski <mattias.niklewski@sonyericsson.com>2011-02-02 15:52:37 +0100
committerJohan Redestig <johan.redestig@sonymobile.com>2012-09-11 14:18:23 +0200
commit158d6b70ac2f0c8fd7dafe0f865112090fb31699 (patch)
treea55861301c7d6f638667e1a0bdd8b58310901652 /core/tests/coretests
parentbfe1ab825731d365fef169deab646d7ceeafc998 (diff)
downloadframeworks_base-158d6b70ac2f0c8fd7dafe0f865112090fb31699.zip
frameworks_base-158d6b70ac2f0c8fd7dafe0f865112090fb31699.tar.gz
frameworks_base-158d6b70ac2f0c8fd7dafe0f865112090fb31699.tar.bz2
Reattach header view after DPAD scroll.
A header view that was scrolled off screen using the DPAD would not be reattached properly when scrolled back into view, due to the flag recycledHeaderFooter. Solved this by using detachViewFromParent() instead of removeViewInLayout(). Compare to AbsListView.trackMotionScroll(). Change-Id: I0ac0ec0f9bf23bc62430c1f62ae7d1a8570b0a24
Diffstat (limited to 'core/tests/coretests')
-rw-r--r--core/tests/coretests/src/android/widget/listview/focus/ListWithEditTextHeaderTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/tests/coretests/src/android/widget/listview/focus/ListWithEditTextHeaderTest.java b/core/tests/coretests/src/android/widget/listview/focus/ListWithEditTextHeaderTest.java
index b9051e9..532b9d1 100644
--- a/core/tests/coretests/src/android/widget/listview/focus/ListWithEditTextHeaderTest.java
+++ b/core/tests/coretests/src/android/widget/listview/focus/ListWithEditTextHeaderTest.java
@@ -22,6 +22,7 @@ import android.test.TouchUtils;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.view.KeyEvent;
+import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.listview.ListWithEditTextHeader;
@@ -63,4 +64,22 @@ public class ListWithEditTextHeaderTest extends ActivityInstrumentationTestCase2
assertTrue("header does not have focus", mListView.getChildAt(0).isFocused());
assertEquals("something is selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
}
+
+ @LargeTest
+ public void testScrollingDoesNotDetachHeaderViewFromWindow() {
+ View header = mListView.getChildAt(0);
+ assertNotNull("header is not attached to a window (?!)", header.getWindowToken());
+
+ // Scroll header off the screen and back onto the screen
+ int numItemsOnScreen = mListView.getChildCount();
+ for (int i = 0; i < numItemsOnScreen; i++) {
+ sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
+ }
+ for (int i = 0; i < numItemsOnScreen; i++) {
+ sendKeys(KeyEvent.KEYCODE_DPAD_UP);
+ }
+
+ // Make sure the header was not accidentally left detached from its window
+ assertNotNull("header has lost its window", header.getWindowToken());
+ }
}