@SmallTest public void testGoingLeftFromRightButtonGoesToCenter() { assertEquals("center should be next focus from right", mCenterButton, mFocusFinder.findNextFocus(mRoot, mRightButton, View.FOCUS_LEFT)); } }
/** * The name 'test preconditions' is a convention to signal that if this * test doesn't pass, the test case was not set up properly and it might * explain any and all failures in other tests. This is not guaranteed * to run before other tests, as junit uses reflection to find the tests. */ @SmallTest public void testPreconditions() { assertNotNull(mLeftButton); assertTrue("center button should be right of left button", mLeftButton.getRight() < mCenterButton.getLeft()); assertTrue("right button should be right of center button", mCenterButton.getRight() < mRightButton.getLeft()); }
@Override protected void setUp() throws Exception { super.setUp(); mFocusFinder = FocusFinder.getInstance(); // inflate the layout final Context context = getContext(); final LayoutInflater inflater = LayoutInflater.from(context); mRoot = (ViewGroup) inflater.inflate(R.layout.focus_2, null); // manually measure it, and lay it out mRoot.measure(500, 500); mRoot.layout(0, 0, 500, 500); mLeftButton = (Button) mRoot.findViewById(R.id.leftButton); mCenterButton = (Button) mRoot.findViewById(R.id.centerButton); mRightButton = (Button) mRoot.findViewById(R.id.rightButton); }
@Override protected void setUp() throws Exception { super.setUp(); mFocusFinder = FocusFinder.getInstance(); // inflate the layout final Context context = getContext(); final LayoutInflater inflater = LayoutInflater.from(context); mRoot = (ViewGroup) inflater.inflate(R.layout.focus_2, null); // manually measure it, and lay it out mRoot.measure(500, 500); mRoot.layout(0, 0, 500, 500); mLeftButton = (Button) mRoot.findViewById(R.id.leftButton); mCenterButton = (Button) mRoot.findViewById(R.id.centerButton); mRightButton = (Button) mRoot.findViewById(R.id.rightButton); }
/** * The name 'test preconditions' is a convention to signal that if this * test doesn't pass, the test case was not set up properly and it might * explain any and all failures in other tests. This is not guaranteed * to run before other tests, as junit uses reflection to find the tests. */ @SmallTest public void testPreconditions() { assertNotNull(mLeftButton); assertTrue("center button should be right of left button", mLeftButton.getRight() < mCenterButton.getLeft()); assertTrue("right button should be right of center button", mCenterButton.getRight() < mRightButton.getLeft()); }
@SmallTest public void testGoingRightFromLeftButtonJumpsOverCenterToRight() { assertEquals("right should be next focus from left", mRightButton, mFocusFinder.findNextFocus(mRoot, mLeftButton, View.FOCUS_RIGHT)); }
@SmallTest public void testGoingLeftFromRightButtonGoesToCenter() { assertEquals("center should be next focus from right", mCenterButton, mFocusFinder.findNextFocus(mRoot, mRightButton, View.FOCUS_LEFT)); } }
@SmallTest public void testGoingRightFromLeftButtonJumpsOverCenterToRight() { assertEquals("right should be next focus from left", mRightButton, mFocusFinder.findNextFocus(mRoot, mLeftButton, View.FOCUS_RIGHT)); }