Skip to content

Instantly share code, notes, and snippets.

@oddbjornkvalsund
Created November 10, 2014 11:26
Show Gist options
  • Save oddbjornkvalsund/aa6864986323440af804 to your computer and use it in GitHub Desktop.
Save oddbjornkvalsund/aa6864986323440af804 to your computer and use it in GitHub Desktop.
package focusbug;
import javafx.scene.Parent;
import javafx.scene.control.TextField;
import org.junit.Test;
import org.loadui.testfx.GuiTest;
import static org.hamcrest.Matchers.is;
import static org.loadui.testfx.Assertions.verifyThat;
public class FocusBugTest extends GuiTest {
@Override
protected Parent getRootNode() {
return new FocusBug().getRootNode();
}
@Test
public void testPopup() {
final TextField mainTextField = find("#mainTextField");
focusEnterTextAndVerifyText(mainTextField);
click("#clickMeButton");
target(findStageByTitle("Popup"));
final TextField popupTextField = find("#popupTextField");
focusEnterTextAndVerifyText(popupTextField);
}
private void focusEnterTextAndVerifyText(TextField textField) {
textField.requestFocus();
verifyThat(textField.isFocused(), is(true));
type("Hello");
verifyThat(textField.getText(), is("Hello"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment