@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.focus_2); } }
@Override protected void setUp() throws Exception { super.setUp(); final Focus2 a = getActivity(); // ensure a valid handle to the activity has been returned assertNotNull(a); mLeftButton = (Button) a.findViewById(R.id.leftButton); mCenterButton = (Button) a.findViewById(R.id.centerButton); mRightButton = (Button) a.findViewById(R.id.rightButton); }
@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()); } }
@Override protected void setUp() throws Exception { super.setUp(); final Focus2 a = getActivity(); // ensure a valid handle to the activity has been returned assertNotNull(a); mLeftButton = (Button) a.findViewById(R.id.leftButton); mCenterButton = (Button) a.findViewById(R.id.centerButton); mRightButton = (Button) a.findViewById(R.id.rightButton); }
@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()); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.focus_2); } }