public void should_give_focus_to_Component_and_wait_till_it_is_focused() {
showWindow();
assertThatButtonDoesNotHaveFocus();
window.button.waitToRequestFocus();
final CountDownLatch done = new CountDownLatch(1);
StopWatch stopWatch = startNewStopWatch();
new Thread() {
@Override
public void run() {
driver.focusAndWaitForFocusGain(window.button);
done.countDown();
}
}.start();
try {
done.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
stopWatch.stop();
assertThatButtonHasFocus();
assertThatWaited(stopWatch, TIME_TO_WAIT_FOR_FOCUS_GAIN);
}