ListButtonsDiagonalAcrossItemsTestpublic class ListButtonsDiagonalAcrossItemsTest extends android.test.ActivityInstrumentationTestCase Test that ListView will override default behavior of focus searching to
make sure going right and left doesn't change selection |
Fields Summary |
---|
private android.widget.Button | mLeftButton | private android.widget.Button | mCenterButton | private android.widget.Button | mRightButton | private android.widget.ListView | mListView |
Constructors Summary |
---|
public ListButtonsDiagonalAcrossItemsTest()
super("com.android.frameworks.coretests", ListButtonsDiagonalAcrossItems.class);
|
Methods Summary |
---|
protected void | setUp()
super.setUp();
mLeftButton = getActivity().getLeftButton();
mCenterButton = getActivity().getCenterButton();
mRightButton = getActivity().getRightButton();
mListView = getActivity().getListView();
| public void | testGoingLeftDoesNotChangeSelection()
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
assertEquals("list view postion", 1, mListView.getSelectedItemPosition());
assertTrue("mCenterButton.isFocused()", mCenterButton.isFocused());
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT);
assertEquals("selected position shouldn't have changed",
1,
mListView.getSelectedItemPosition());
assertTrue("center should still be focused", mCenterButton.isFocused());
| public void | testGoingRightDoesNotChangeSelection()
sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);
assertEquals("selected position shouldn't have changed",
0,
mListView.getSelectedItemPosition());
assertTrue("left should still be focused", mLeftButton.isFocused());
| public void | testPreconditions()
final ListView lv = mListView;
assertEquals("num children", 3, lv.getChildCount());
assertEquals("selected position", 0, lv.getSelectedItemPosition());
assertTrue("left button focused", mLeftButton.isFocused());
assertTrue("left left of center",
mLeftButton.getRight()
< mCenterButton.getLeft());
assertTrue("center left of right",
mCenterButton.getRight()
< mRightButton.getLeft());
assertEquals("focus search right from left button should be center button",
mCenterButton,
FocusFinder.getInstance().findNextFocus(mListView, mLeftButton, View.FOCUS_RIGHT));
assertEquals("focus search right from center button should be right button",
mRightButton,
FocusFinder.getInstance().findNextFocus(mListView, mCenterButton, View.FOCUS_RIGHT));
assertEquals("focus search left from centr button should be left button",
mLeftButton,
FocusFinder.getInstance().findNextFocus(mListView, mCenterButton, View.FOCUS_LEFT));
|
|