use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class MapSyncRpcHandlerTest method syncJSON_jsonIsNotListItemAndNotPropertyValue_propertySetToJSON.
@Test
public void syncJSON_jsonIsNotListItemAndNotPropertyValue_propertySetToJSON() throws Exception {
// Let's use element's ElementPropertyMap for testing.
TestComponent component = new TestComponent();
Element element = component.getElement();
UI ui = new UI();
ui.add(component);
StateNode node = element.getNode();
TestComponent anotherComonent = new TestComponent();
StateNode anotherNode = anotherComonent.getElement().getNode();
ElementPropertyMap.getModel(node).setUpdateFromClientFilter(name -> true);
// Use the model node id for JSON object which represents a value to
// update
JsonObject json = Json.createObject();
json.put("nodeId", anotherNode.getId());
// send sync request
sendSynchronizePropertyEvent(element, ui, "foo", json);
Serializable testPropertyValue = node.getFeature(ElementPropertyMap.class).getProperty("foo");
Assert.assertNotSame(anotherNode, testPropertyValue);
Assert.assertTrue(testPropertyValue instanceof JsonValue);
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class CustomElementRegistryInitializerTest method creatingElementsWhenMultipleRegisteredCustomTagNamesInRegistryGetCorrectComponentWired.
@Test
public void creatingElementsWhenMultipleRegisteredCustomTagNamesInRegistryGetCorrectComponentWired() throws ServletException {
customElementRegistryInitializer.onStartup(Stream.of(ValidCustomElement.class, ValidExtendingElement.class, CustomPolymerElement.class).collect(Collectors.toSet()), null);
Element customElement = new Element("custom-element");
Assert.assertTrue("CustomElement didn't have a Component", customElement.getComponent().isPresent());
Assert.assertEquals("CustomElement got unexpected Component", ValidCustomElement.class, customElement.getComponent().get().getClass());
Element polymerElement = new Element("custom-polymer-element");
Assert.assertTrue("PolymerElement didn't have a Component", polymerElement.getComponent().isPresent());
Assert.assertEquals("PolymerElement got unexpected Component", CustomPolymerElement.class, polymerElement.getComponent().get().getClass());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class AngularTemplateIncludeBuilderTest method templateWithInclude.
@Test
public void templateWithInclude() {
// <div>
// <span>Main template</span>
// @include sub.html@
// </div>
// <div>
// <span>Sub template</span>
// </div>
IncludeTemplate template = new IncludeTemplate();
ElementTemplateNode parentTemplateNode = ((TemplateElementStateProvider) template.getElement().getStateProvider()).getTemplateNode();
Element element = template.getElement();
Assert.assertEquals("div", element.getTag());
List<Element> children = filterOutTextChildren(element);
Assert.assertEquals("span", children.get(0).getTag());
Assert.assertEquals("Main template", element.getChild(1).getTextRecursively());
Element subTemplateElement = children.get(1);
Assert.assertEquals("div", subTemplateElement.getTag());
// template node should have the main template as the parent #1176
ElementTemplateNode includedTemplateNode = ((TemplateElementStateProvider) subTemplateElement.getStateProvider()).getTemplateNode();
Assert.assertEquals(parentTemplateNode, includedTemplateNode.getParent().get());
Element span = filterOutTextChildren(subTemplateElement).get(0);
Assert.assertEquals("span", span.getTag());
Assert.assertEquals("Sub template", span.getTextRecursively());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class AngularTemplateNodeTest method childElementLookup.
@Test
public void childElementLookup() {
TemplateNode templateNode = parse("<span><div id='foo'><div></span>");
Element div = getElement(templateNode).getChild(0);
Element foundDiv = templateNode.findElement(div.getNode(), "foo").get();
Assert.assertEquals(div, foundDiv);
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class AngularTemplateNodeTest method singleElementLookup.
@Test
public void singleElementLookup() {
TemplateNode templateNode = parse("<div id='foo'><div>");
Element div = getElement(templateNode);
Element foundDiv = templateNode.findElement(div.getNode(), "foo").get();
Assert.assertEquals(div, foundDiv);
}
Aggregations