use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ClientDelegteHandlersTest method attach_noFeature.
@Test
public void attach_noFeature() {
StateTree tree = new StateTree(new UI(), ElementChildrenList.class);
StateNode stateNode = new StateNode(ClientDelegateHandlers.class);
tree.getRootNode().getFeature(ElementChildrenList.class).add(stateNode);
Assert.assertEquals(0, stateNode.getFeature(ClientDelegateHandlers.class).size());
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ClientDelegteHandlersTest method attach_noComponent.
@Test
public void attach_noComponent() {
StateTree tree = new StateTree(new UI(), ElementChildrenList.class);
StateNode stateNode = new StateNode(ComponentMapping.class, ClientDelegateHandlers.class);
tree.getRootNode().getFeature(ElementChildrenList.class).add(stateNode);
Assert.assertEquals(0, stateNode.getFeature(ClientDelegateHandlers.class).size());
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ElementPropertyMapTest method listenerIsNotified.
private void listenerIsNotified(boolean clientEvent) {
ElementPropertyMap map = createSimplePropertyMap();
StateNode node = map.getNode();
AtomicReference<PropertyChangeEvent> event = new AtomicReference<>();
PropertyChangeListener listener = ev -> {
Assert.assertNull(event.get());
event.set(ev);
};
map.addPropertyChangeListener("foo", listener);
map.setProperty("foo", "bar", !clientEvent);
Assert.assertNull(event.get().getOldValue());
Assert.assertEquals("bar", event.get().getValue());
Assert.assertEquals("foo", event.get().getPropertyName());
Assert.assertEquals(Element.get(node), event.get().getSource());
Assert.assertEquals(clientEvent, event.get().isUserOriginated());
// listener is not called. Otherwise its assertion fails.
map.setProperty("bar", "foo");
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ElementPropertyMapTest method resolveModelList_modelListStateNodeHasReportedFeature.
@Test
public void resolveModelList_modelListStateNodeHasReportedFeature() {
ElementPropertyMap map = createSimplePropertyMap();
map.resolveModelList("foo");
StateNode stateNode = (StateNode) map.get("foo");
Assert.assertTrue(stateNode.isReportedFeature(ModelList.class));
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ElementPropertyMapTest method childPropertyUpdateFilter_setFilterAfterChild.
@Test
public void childPropertyUpdateFilter_setFilterAfterChild() {
ElementPropertyMap map = createSimplePropertyMap();
StateNode child = new StateNode(ElementPropertyMap.class);
ElementPropertyMap childModel = ElementPropertyMap.getModel(child);
map.put("foo", child);
map.setUpdateFromClientFilter("foo.bar"::equals);
Assert.assertTrue(childModel.mayUpdateFromClient("bar", "a"));
Assert.assertFalse(childModel.mayUpdateFromClient("baz", "a"));
}
Aggregations