ConfigurationContext extends GraphicalContext<BorderPane> { ChoiceBox<String> buildQuitKeyChooser( Configuration configuration ) { ChoiceBox<String> choiceBox = new ChoiceBox<>(); choiceBox.setPrefWidth(PREF_WIDTH); choiceBox.setPrefHeight(PREF_HEIGHT); choiceBox.getItems().addAll("Q", "W", "E", "R", "T", "Y"); choiceBox.getSelectionModel().select(configuration.getQuitKeyProperty().getValue()); choiceBox.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> configuration.getQuitKeyProperty().setValue(newValue)); return choiceBox; } ConfigurationContext(GazePlay gazePlay); @Override ObservableList<Node> getChildren();  }
@Test void shouldBuildQuitKeyChooser() throws InterruptedException { Platform.runLater(() -> { ConfigurationContext context = new ConfigurationContext(mockGazePlay); StringProperty quitProperty = new SimpleStringProperty("Y"); when(mockConfig.getQuitKeyProperty()).thenReturn(quitProperty); ChoiceBox<String> result = context.buildQuitKeyChooser(mockConfig); assertEquals(6, result.getItems().size()); result.setValue("Q"); assertEquals("Q", quitProperty.getValue()); }); TestingUtils.waitForRunLater(); }