Discover custom ViewModels and validate Computed bindings in shared hosts
This commit is contained in:
@@ -482,6 +482,84 @@ public final class ProjectionHostChecks {
|
||||
await(() -> fx(() -> source(pane).getText().equals(full)));
|
||||
}
|
||||
|
||||
private static void viewModelBindings(
|
||||
DesignerPane pane, DocumentSession document, String original) throws Exception {
|
||||
bindingTab(pane, "Discover targets");
|
||||
click(pane, "Discover bindings");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
((ComboBox<de.neitzel.fxdesigner.protocol.BindingMetadata.Attribute>)
|
||||
pane.lookup("#binding-path"))
|
||||
.getItems().stream().anyMatch(a -> a.path().equals("badge"))));
|
||||
check(
|
||||
fx(
|
||||
() ->
|
||||
((ListView<de.neitzel.fxdesigner.protocol.BindingMetadata.Computed>)
|
||||
pane.lookup("#computed-methods"))
|
||||
.getItems().stream().anyMatch(m -> m.method().equals("#greeting"))),
|
||||
"Computed inventory missing");
|
||||
check(documentText(document).equals(original), "ViewModel discovery altered FXML");
|
||||
String invalid = original.replace("method=\"#greeting\"", "method=\"#invalidComputed\"");
|
||||
check(!invalid.equals(original), "Computed fixture missing");
|
||||
set(document, invalid);
|
||||
await(() -> fx(() -> source(pane).getText().equals(invalid)));
|
||||
bindingTab(pane, "Direct bindings");
|
||||
click(pane, "Render drafts");
|
||||
await(() -> bindingStatus(pane, "Computed return type"));
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
pane.lookupAll(".label").stream()
|
||||
.anyMatch(
|
||||
n ->
|
||||
n instanceof Label l
|
||||
&& l.getText() != null
|
||||
&& l.getText().startsWith("Preview blocked:"))));
|
||||
document
|
||||
.save(document.snapshot().toCompletableFuture().get().revision())
|
||||
.toCompletableFuture()
|
||||
.get();
|
||||
check(
|
||||
java.nio.file.Files.readString(
|
||||
java.nio.file.Path.of(document.snapshot().toCompletableFuture().get().document()))
|
||||
.equals(invalid),
|
||||
"Invalid Computed draft could not be saved");
|
||||
click(pane, "Undo");
|
||||
await(() -> documentText(document).equals(original));
|
||||
click(pane, "Redo");
|
||||
await(() -> documentText(document).equals(invalid));
|
||||
click(pane, "Undo");
|
||||
await(() -> documentText(document).equals(original));
|
||||
String replacement =
|
||||
java.nio.file.Files.readString(
|
||||
java.nio.file.Path.of(document.snapshot().toCompletableFuture().get().document())
|
||||
.resolveSibling("Replacement.fxml"));
|
||||
set(document, replacement);
|
||||
await(() -> fx(() -> source(pane).getText().equals(replacement)));
|
||||
bindingTab(pane, "Discover targets");
|
||||
click(pane, "Discover bindings");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
((Label) pane.lookup("#binding-status"))
|
||||
.getText()
|
||||
.contains("fixture.components.ReplacementViewModel")));
|
||||
check(
|
||||
fx(
|
||||
() ->
|
||||
((ComboBox<de.neitzel.fxdesigner.protocol.BindingMetadata.Attribute>)
|
||||
pane.lookup("#binding-path"))
|
||||
.getItems().stream().noneMatch(a -> a.path().equals("name"))),
|
||||
"Replacement inherited Model attributes");
|
||||
check(documentText(document).equals(replacement), "Replacement discovery altered FXML");
|
||||
set(document, original);
|
||||
await(() -> fx(() -> source(pane).getText().equals(original)));
|
||||
}
|
||||
|
||||
public static void run(DesignerPane pane, DocumentSession document) throws Exception {
|
||||
String original = document.snapshot().toCompletableFuture().get().text();
|
||||
// The same real application, now with nested, fully-qualified Component declarations.
|
||||
@@ -810,6 +888,7 @@ public final class ProjectionHostChecks {
|
||||
|
||||
set(document, original);
|
||||
await(() -> fx(() -> source(pane).getText().equals(original) && object(pane, "card") != null));
|
||||
viewModelBindings(pane, document, original);
|
||||
document
|
||||
.save(document.snapshot().toCompletableFuture().get().revision())
|
||||
.toCompletableFuture()
|
||||
|
||||
Reference in New Issue
Block a user