Methods Summary |
---|
public void | setUp()
super.setUp();
final RequestFocus a = getActivity();
mHandler = a.getHandler();
mTopLeftButton = (Button) a.findViewById(R.id.topLeftButton);
mBottomLeftButton = (Button) a.findViewById(R.id.bottomLeftButton);
mTopRightButton = (Button) a.findViewById(R.id.topRightButton);
mBottomRightButton = (Button) a.findViewById(R.id.bottomRightButton);
|
public void | testPostedRequestFocus()
mHandler.post(new Runnable() { public void run() {
mBottomLeftButton.requestFocus();
}});
synchronized(this) {
try {
wait(500);
} catch (InterruptedException e) {
// Don't care.
}
}
assertTrue("Focus should move to bottom left", mBottomLeftButton.hasFocus());
|
public void | testSetUpConditions()
assertNotNull(mHandler);
assertNotNull(mTopLeftButton);
assertNotNull(mTopRightButton);
assertNotNull(mBottomLeftButton);
assertNotNull(mBottomRightButton);
assertTrue("requestFocus() should work from onCreate.", mBottomRightButton.hasFocus());
|
public void | testWrongThreadRequestFocusFails()
try {
mTopRightButton.requestFocus();
fail("requestFocus from wrong thread should raise exception.");
} catch (AndroidRuntimeException e) {
// Expected. The actual exception is not public, so we can't catch it.
assertEquals("android.view.ViewRoot$CalledFromWrongThreadException",
e.getClass().getName());
}
|