use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testUpdatePropertyBindingTemplate.
public void testUpdatePropertyBindingTemplate() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
templateNode.addProperty("prop", TestBinding.createBinding(ModelValueBindingProvider.TYPE, MODEL_KEY));
NodeMap map = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
map.getProperty(MODEL_KEY).setValue("foo");
Node domNode = createElement(templateNode);
Reactive.flush();
map.getProperty(MODEL_KEY).setValue("bar");
Reactive.flush();
assertEquals("bar", WidgetUtil.getJsProperty(domNode, "prop"));
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testBindOverrideNode_properties_afterBind.
public void testBindOverrideNode_properties_afterBind() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
int id = 68;
StateNode overrideNode = createSimpleOverrideNode(id);
Element element = createElement(templateNode, id);
NodeMap props = overrideNode.getMap(NodeFeatures.ELEMENT_PROPERTIES);
props.getProperty("foo").setValue("bar");
Reactive.flush();
assertEquals("bar", WidgetUtil.getJsProperty(element, "foo"));
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testJSExpresisonsWithSubProperties.
public void testJSExpresisonsWithSubProperties() {
JsonObject beanType = Json.createObject();
beanType.put(MODEL_KEY, "String");
JsonObject modelType = Json.createObject();
modelType.put(MODEL_KEY, beanType);
setModelType(stateNode, modelType);
// create binding with expression : : key.key ? key.key+'@bar.com'
// :'foo'
TestTextTemplate templateNode = TestTextTemplate.create(TestBinding.createTextValueBinding(MODEL_KEY + "." + MODEL_KEY + " ? " + MODEL_KEY + "." + MODEL_KEY + "+'@bar.com' : 'foo'"));
Node domNode = createText(templateNode);
NodeMap parentMap = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
StateNode childNode = new StateNode(458, stateNode.getTree());
NodeMap childMap = childNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
parentMap.getProperty(MODEL_KEY).setValue(childNode);
childMap.getProperty(MODEL_KEY).setValue(null);
Reactive.flush();
assertEquals("foo", domNode.getTextContent());
childMap.getProperty(MODEL_KEY).setValue("value");
Reactive.flush();
assertEquals("value@bar.com", domNode.getTextContent());
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testPropertyBindingTemplate.
public void testPropertyBindingTemplate() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
templateNode.addProperty("prop", TestBinding.createBinding(ModelValueBindingProvider.TYPE, MODEL_KEY));
NodeMap map = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
map.getProperty(MODEL_KEY).setValue("foo");
Node domNode = createElement(templateNode);
Reactive.flush();
assertEquals("foo", WidgetUtil.getJsProperty(domNode, "prop"));
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class InitialPropertiesHandlerTest method flushPropertyUpdates_updateIsNotInProgress_flushForEechProperty.
@Test
public void flushPropertyUpdates_updateIsNotInProgress_flushForEechProperty() {
Mockito.when(tree.isUpdateInProgress()).thenReturn(false);
StateNode node = new StateNode(1, tree);
NodeMap properties = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
MapProperty property1 = properties.getProperty("foo");
property1.setValue("bar");
MapProperty property2 = properties.getProperty("other");
property2.setValue("value");
handler.nodeRegistered(node);
Mockito.when(tree.getNode(node.getId())).thenReturn(node);
handler.flushPropertyUpdates();
property1.setValue("baz");
property2.setValue("foo");
handler.handlePropertyUpdate(property1);
handler.handlePropertyUpdate(property2);
AtomicInteger count = new AtomicInteger();
FlushListener listener = () -> count.incrementAndGet();
property1.addChangeListener(event -> Reactive.addFlushListener(listener));
property2.addChangeListener(event -> Reactive.addFlushListener(listener));
Reactive.flush();
Assert.assertEquals(2, count.get());
}
Aggregations