use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class AddDivUI method addDiv.
private void addDiv() {
Element bodyElement = getElement();
Element div = ElementFactory.createDiv("Hello world at " + System.currentTimeMillis() + " (" + msgId++ + ")");
bodyElement.insertChild(0, div);
if (msgId % 100 == 0) {
System.out.println("Pushed id " + msgId + " to " + ip);
}
// FIXME Enable when remove works
// while (bodyElement.getChildCount() > 20) {
// bodyElement.removeChild(20);
// }
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class EventUtilTest method getImplementingComponents_elementHasVirtualChildren.
@Test
public void getImplementingComponents_elementHasVirtualChildren() throws Exception {
Element node = new Element("root");
node.appendChild(new Element("main"), new Element("menu"));
Element nested = new Element("nested");
nested.appendChild(new Element("nested-child"), new Element("nested-child-2"));
node.getStateProvider().appendVirtualChild(node.getNode(), nested, NodeProperties.TEMPLATE_IN_TEMPLATE, "");
Component.from(nested, EnterObserver.class);
List<Element> elements = new ArrayList<>();
EventUtil.inspectHierarchy(node, elements);
List<BeforeEnterObserver> listenerComponents = EventUtil.getImplementingComponents(elements.stream(), BeforeEnterObserver.class).collect(Collectors.toList());
Assert.assertEquals("Wrong amount of listener instances found", 1, listenerComponents.size());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class EventUtilTest method collectLocaleChangeObserverFromElement.
@Test
public void collectLocaleChangeObserverFromElement() throws Exception {
Element node = new Element("root");
node.appendChild(new Element("main"), new Element("menu"));
Element nested = new Element("nested-locale");
nested.appendChild(new Element("nested-child"), new Element("nested-child-2"));
node.appendChild(nested);
Component.from(nested, Locale.class);
List<LocaleChangeObserver> beforeNavigationObservers = EventUtil.collectLocaleChangeObservers(node);
Assert.assertEquals("Wrong amount of listener instances found", 1, beforeNavigationObservers.size());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class EventUtilTest method collectBeforeNavigationObserversFromElement.
@Test
public void collectBeforeNavigationObserversFromElement() throws Exception {
Element node = new Element("root");
node.appendChild(new Element("main"), new Element("menu"));
Element nested = new Element("nested");
nested.appendChild(new Element("nested-child"), new Element("nested-child-2"));
node.appendChild(nested);
Component.from(nested, LeaveObserver.class);
List<BeforeLeaveObserver> beforeNavigationObservers = EventUtil.collectBeforeLeaveObservers(node);
Assert.assertEquals("Wrong amount of listener instances found", 1, beforeNavigationObservers.size());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class InternalServerErrorTest method nonProductionMode_hasLogBinding_showStacktraceAndNoWarning.
@Test
public void nonProductionMode_hasLogBinding_showStacktraceAndNoWarning() {
Mockito.when(configuration.isProductionMode()).thenReturn(false);
InternalServerError testInstance = new InternalServerError() {
@Override
protected boolean hasLogBinding() {
return true;
}
};
testInstance.setErrorParameter(event, new ErrorParameter<>(new NullPointerException("foo")));
Assert.assertEquals("2 elements should be shown: exception text and exception stacktrace", 2, testInstance.getElement().getChildCount());
Element stacktrace = testInstance.getElement().getChild(1);
Assert.assertEquals("pre", stacktrace.getTag());
Assert.assertTrue(stacktrace.getText().contains(NullPointerException.class.getName()));
Assert.assertTrue(stacktrace.getText().contains("foo"));
}
Aggregations