Choose a compatible HtmlViewer for the Archiver media button
This commit is contained in:
@@ -70,7 +70,11 @@ class FormDocumentTest {
|
||||
@Test
|
||||
void emptyGridAndNamedListsKeepReferencesAndRejectCycles() throws Exception {
|
||||
assertEquals(
|
||||
9, FormDocument.TYPES.values().stream().filter(n -> n.startsWith("de.neitzel.")).count());
|
||||
9,
|
||||
doc().palette().stream()
|
||||
.map(FormDocument.TYPES::get)
|
||||
.filter(n -> n.startsWith("de.neitzel."))
|
||||
.count());
|
||||
for (String type :
|
||||
List.of(
|
||||
"Label",
|
||||
@@ -168,4 +172,34 @@ class FormDocumentTest {
|
||||
assertEquals(2, doc().size(slot("", "items")));
|
||||
assertFalse(source.contains("<items>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mediaReferenceChecksTypeAndDeclarationOrderAndPreservesHtmlBinding() throws Exception {
|
||||
source =
|
||||
"""
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import de.neitzel.archiver.ui.HtmlMediaButton?>
|
||||
<?import de.neitzel.fx.control.HtmlViewer?>
|
||||
<?import de.neitzel.fx.view.*?>
|
||||
<HBox xmlns:fx="http://javafx.com/fxml/1">
|
||||
<fx:define><BindingList><DirectBinding control="article" property="html" path="html" direction="view"/></BindingList></fx:define>
|
||||
<HtmlViewer fx:id="article"/>
|
||||
<Label fx:id="unrelated"/>
|
||||
<HtmlMediaButton fx:id="media" viewer="$unrelated"/>
|
||||
<HtmlViewer fx:id="later"/>
|
||||
</HBox>
|
||||
""";
|
||||
assertTrue(doc().palette().contains("HtmlMediaButton"));
|
||||
assertEquals(List.of("$article"), doc().viewerTargets(item("media")));
|
||||
assertTrue(new ReferenceDocument(source).referenceErrors().getFirst().contains("$unrelated"));
|
||||
assertThrows(IllegalArgumentException.class, () -> set("media", "viewer", "$later"));
|
||||
assertThrows(IllegalArgumentException.class, () -> set("media", "viewer", "$missing"));
|
||||
set("media", "viewer", "$article");
|
||||
assertTrue(new ReferenceDocument(source).referenceErrors().isEmpty());
|
||||
assertTrue(
|
||||
source.contains(
|
||||
"<DirectBinding control=\"article\" property=\"html\" path=\"html\""
|
||||
+ " direction=\"view\"/>"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user