use of com.vaadin.flow.template.angular.AngularTemplate in project flow by vaadin.
the class ClientDelegteHandlersTest method attach_handlersContainsAllTemplateMethods.
@Test
public void attach_handlersContainsAllTemplateMethods() {
UI ui = new UI();
AngularTemplate template = new ChildTemplateWithMultipleMethods();
ui.add(template);
ClientDelegateHandlers feature = template.getElement().getNode().getFeature(ClientDelegateHandlers.class);
Assert.assertEquals(3, feature.size());
Set<String> methods = getDeclaredMethods(ChildTemplateWithMultipleMethods.class).collect(Collectors.toCollection(HashSet::new));
methods.add(getDeclaredMethods(Template1.class).findFirst().get());
for (int i = 0; i < feature.size(); i++) {
methods.remove(feature.get(i));
}
Assert.assertTrue("Feature doesn't contain methods: " + methods.toString(), methods.isEmpty());
}
use of com.vaadin.flow.template.angular.AngularTemplate in project flow by vaadin.
the class EventRpcHandlerTest method templateChildElementEventListener.
@Test
public void templateChildElementEventListener() throws Exception {
UI ui = new UI();
AngularTemplate t = new InlineTemplate("<root><child></child></root>");
Element element = t.getElement().getChild(0);
ui.add(t);
AtomicInteger invoked = new AtomicInteger(0);
element.addEventListener("test-event", e -> {
invoked.incrementAndGet();
});
sendElementEvent(element, ui, "test-event", null);
Assert.assertEquals(1, invoked.get());
}
use of com.vaadin.flow.template.angular.AngularTemplate in project flow by vaadin.
the class EventRpcHandlerTest method templateRootElementEventListener.
@Test
public void templateRootElementEventListener() throws Exception {
UI ui = new UI();
AngularTemplate t = new InlineTemplate("<root><child></child></root>");
Element element = t.getElement();
ui.add(t);
AtomicInteger invoked = new AtomicInteger(0);
element.addEventListener("test-event", e -> {
invoked.incrementAndGet();
});
sendElementEvent(element, ui, "test-event", null);
Assert.assertEquals(1, invoked.get());
}
use of com.vaadin.flow.template.angular.AngularTemplate in project flow by vaadin.
the class ClientDelegteHandlersTest method attach_twoMethodsWithTheSameName_ExceptionIsThrown.
@Test
public void attach_twoMethodsWithTheSameName_ExceptionIsThrown() {
UI ui = new UI();
AngularTemplate template = new ChildTemplateWithOverriddenMethod();
ui.add(template);
}
use of com.vaadin.flow.template.angular.AngularTemplate in project flow by vaadin.
the class ClientDelegteHandlersTest method attach_handlersContainsOnlyOneTemplateMethod.
@Test
public void attach_handlersContainsOnlyOneTemplateMethod() {
UI ui = new UI();
AngularTemplate template = new ChildTemplateWithOverriddenMethod();
ui.add(template);
ClientDelegateHandlers feature = template.getElement().getNode().getFeature(ClientDelegateHandlers.class);
Assert.assertEquals(1, feature.size());
Assert.assertEquals(getDeclaredMethods(ChildTemplateWithOverriddenMethod.class).findFirst().get(), feature.get(0));
}
Aggregations