/** * 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. */ @MediumTest public void testPreconditions() { 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()); assertTrue("left button should be focused", mLeftButton.isFocused()); }
/** * 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. */ @MediumTest public void testPreconditions() { 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()); assertTrue("left button should be focused", mLeftButton.isFocused()); }
@MediumTest public void testGoingRightFromLeftButtonJumpsOverCenterToRight() { sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT); assertTrue("right button should be focused", mRightButton.isFocused()); }
@MediumTest public void testGoingRightFromLeftButtonJumpsOverCenterToRight() { sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT); assertTrue("right button should be focused", mRightButton.isFocused()); }
@MediumTest public void testGoingLeftFromRightButtonGoesToCenter() { // Give right button focus by having it request focus. We post it // to the UI thread because we are not running on the same thread, and // any direct api calls that change state must be made from the UI thread. // This is in contrast to instrumentation calls that send events that are // processed through the framework and eventually find their way to // affecting the ui thread. getActivity().runOnUiThread(new Runnable() { public void run() { mRightButton.requestFocus(); } }); // wait for the request to go through getInstrumentation().waitForIdleSync(); assertTrue(mRightButton.isFocused()); sendKeys(KeyEvent.KEYCODE_DPAD_LEFT); assertTrue("center button should be focused", mCenterButton.isFocused()); } }
@MediumTest public void testGoingLeftFromRightButtonGoesToCenter() { // Give right button focus by having it request focus. We post it // to the UI thread because we are not running on the same thread, and // any direct api calls that change state must be made from the UI thread. // This is in contrast to instrumentation calls that send events that are // processed through the framework and eventually find their way to // affecting the ui thread. getActivity().runOnUiThread(new Runnable() { public void run() { mRightButton.requestFocus(); } }); // wait for the request to go through getInstrumentation().waitForIdleSync(); assertTrue(mRightButton.isFocused()); sendKeys(KeyEvent.KEYCODE_DPAD_LEFT); assertTrue("center button should be focused", mCenterButton.isFocused()); } }