FileDocCategorySizeDatePackage
HorizontalFocusSearchTest.javaAPI DocAndroid 5.1 API4998Thu Mar 12 22:22:12 GMT 2015android.widget.focus

HorizontalFocusSearchTest

public class HorizontalFocusSearchTest extends android.test.ActivityInstrumentationTestCase
Tests that focus searching works on a horizontal linear layout of buttons of various widths and vertical placements.

Fields Summary
private android.widget.focus.VerticalFocusSearchTest.FocusSearchAlg
mFocusFinder
private android.widget.LinearLayout
mLayout
private android.widget.Button
mLeftTall
private android.widget.Button
mMidShort1Top
private android.widget.Button
mMidShort2Bottom
private android.widget.Button
mRightTall
Constructors Summary
public HorizontalFocusSearchTest()

        super("com.android.frameworks.coretests", HorizontalFocusSearch.class);
    
Methods Summary
public voidTODO_testSearchFromMiddleLeftButton()

        assertNull("going up from mMidShort1Top",
                mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_UP));
        assertEquals("going down from mMidShort1Top",
                mMidShort2Bottom,
                mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_DOWN));
        assertEquals("going left from mMidShort1Top",
                mLeftTall,
                mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_LEFT));
        assertEquals("going right from mMidShort1Top",
                mMidShort2Bottom,
                mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_RIGHT));
    
public voidTODO_testSearchFromMiddleRightButton()

        assertEquals("going up from mMidShort2Bottom",
                mMidShort1Top,
                mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_UP));
        assertNull("going down from mMidShort2Bottom",
                mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_DOWN));
        assertEquals("going left from mMidShort2Bottom",
                mMidShort1Top,
                mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_LEFT));
        assertEquals("goind right from mMidShort2Bottom",
                mRightTall,
                mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_RIGHT));
    
protected voidsetUp()

        super.setUp();

        mFocusFinder = new NewFocusSearchAlg();

        mLayout = getActivity().getLayout();
        mLeftTall = getActivity().getLeftTall();
        mMidShort1Top = getActivity().getMidShort1Top();
        mMidShort2Bottom = getActivity().getMidShort2Bottom();
        mRightTall = getActivity().getRightTall();
    
public voidtestPreconditions()

        assertNotNull(mLayout);
        assertNotNull(mLeftTall);
        assertNotNull(mMidShort1Top);
        assertNotNull(mMidShort2Bottom);
        assertNotNull(mRightTall);
    
public voidtestSearchFromLeftButton()

        assertNull("going up from mLeftTall",
                mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_UP));
        assertNull("going down from mLeftTall",
                mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_DOWN));
        assertNull("going left from mLeftTall",
                mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_LEFT));

        assertEquals("going right from mLeftTall",
                mMidShort1Top,
                mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_RIGHT));
    
public voidtestSearchFromRightButton()

        assertNull("going up from mRightTall",
                mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_UP));
        assertNull("going down from mRightTall",
                mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_DOWN));
        assertEquals("going left from mRightTall",
                mMidShort2Bottom,
                mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_LEFT));
        assertNull("going right from mRightTall",
                mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_RIGHT));