String htmlParent = "Some <b>html</b>";
String textChild = "Child text";
String htmlChild = "Child <i>html</i>";
+ String htmlElementChild = "Child <span id='my-html-element'>element html</span>";
final Tree tree = new Tree("A tree");
tree.addItem(textParent);
tree.addItem(htmlParent);
tree.addItem(textChild);
tree.addItem(htmlChild);
-
+ tree.addItem(htmlElementChild);
tree.setParent(textChild, textParent);
tree.setParent(htmlChild, htmlParent);
tree.setChildrenAllowed(textChild, false);
tree.setChildrenAllowed(htmlChild, false);
+ tree.setChildrenAllowed(htmlElementChild, false);
final CheckBox toggle = new CheckBox("HTML content allowed",
tree.isHtmlContentAllowed());
"unchecked", toggle.getValue());
// Markup is seen as plain text
- assertTreeCaptionTexts("Just text", "Some <b>html</b>");
+ assertTreeCaptionTexts("Just text", "Some <b>html</b>",
+ "Child <span id='my-html-element'>element html</span>");
toggle.click();
- assertTreeCaptionTexts("Just text", "Some html");
+ assertTreeCaptionTexts("Just text", "Some html", "Child element html");
// Expand the HTML parent
findElements(By.className("v-tree-node")).get(1).click();
- assertTreeCaptionTexts("Just text", "Some html", "Child html");
+ assertTreeCaptionTexts("Just text", "Some html", "Child html",
+ "Child element html");
toggle.click();
assertTreeCaptionTexts("Just text", "Some <b>html</b>",
- "Child <i>html</i>");
+ "Child <i>html</i>",
+ "Child <span id='my-html-element'>element html</span>");
+
+ toggle.click();
+ findElements(By.id("my-html-element")).get(0).click();
+ assertHtmlElementSelected();
+
+ }
+
+ private void assertHtmlElementSelected() {
+ TreeElement tree = $(TreeElement.class).first();
+ Assert.assertEquals(tree.getValue(), "Child element html");
}
private void assertTreeCaptionTexts(String... captions) {