Edit control properties and verify controller event handlers in IntelliJ
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
package de.neitzel.fxdesigner.target;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import de.neitzel.fxdesigner.protocol.BindingMetadata;
|
||||
import java.util.List;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.Event;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ActionEventHandlersTest {
|
||||
public static class Parent {
|
||||
@FXML
|
||||
private void inherited(Event event) {}
|
||||
|
||||
public void replaced(KeyEvent event) {}
|
||||
|
||||
private void hidden() {}
|
||||
}
|
||||
|
||||
public static class Controller extends Parent {
|
||||
@FXML
|
||||
private void submit(ActionEvent event) {}
|
||||
|
||||
public void replaced(ActionEvent event) {}
|
||||
|
||||
public void clear() {}
|
||||
|
||||
public void mixed() {}
|
||||
|
||||
public void mixed(KeyEvent event) {}
|
||||
|
||||
public void keys(KeyEvent event) {}
|
||||
|
||||
public static void helper() {}
|
||||
|
||||
public void initialize() {}
|
||||
|
||||
Controller() {
|
||||
throw new AssertionError("Discovery constructed a controller");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void reportsOnlyAccessibleSignaturesCallableForActionEvents() throws Exception {
|
||||
var xml =
|
||||
"<?import javafx.scene.control.TextField?><TextField xmlns:fx=\"http://javafx.com/fxml/1\""
|
||||
+ " fx:controller=\""
|
||||
+ Controller.class.getName()
|
||||
+ "\"/>";
|
||||
var result = BindingDiscovery.inspect(xml, "", "view", getClass().getClassLoader());
|
||||
var wire = result.encode();
|
||||
assertEquals(
|
||||
List.of("#clear", "#inherited", "#replaced", "#submit"),
|
||||
BindingMetadata.decode(wire).actionEventHandlers().orElseThrow());
|
||||
wire.remove("actionEvents");
|
||||
assertTrue(BindingMetadata.decode(wire).actionEventHandlers().isEmpty());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user