use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.
the class GwtTemplateBinderTest method testUnregisterOverrideNode.
public void testUnregisterOverrideNode() {
int id = 83;
StateNode overrideNode = createSimpleOverrideNode(id, 2);
// Must register so that we can fire an unregister event later on
tree.registerNode(stateNode);
tree.registerNode(overrideNode);
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
MapProperty idProperty = overrideNode.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("id");
idProperty.setValue("override");
Element element = createElement(templateNode, id);
Reactive.flush();
tree.unregisterNode(stateNode);
tree.unregisterNode(overrideNode);
Reactive.flush();
// Updating override node after unregistering the nodes should not
// cause the element to update
idProperty.setValue("new");
Reactive.flush();
assertEquals("override", element.getId());
}
use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.
the class GwtTemplateBinderTest method testClassNameBinding.
public void testClassNameBinding() {
MapProperty property = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP).getProperty(MODEL_KEY);
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
templateNode.addClassName("static", "true");
templateNode.addClassName("dynamic", TestBinding.createBinding(ModelValueBindingProvider.TYPE, MODEL_KEY));
Element element = createElement(templateNode);
property.setValue(Boolean.TRUE);
Reactive.flush();
assertEquals("static dynamic", element.getClassName());
property.setValue(Boolean.FALSE);
Reactive.flush();
assertEquals("static", element.getClassName());
// Test that the evaluation logic is based on thruthishness instead of
// strict boolean evaluation
// trueish value
property.setValue("yes");
Reactive.flush();
assertEquals("static dynamic", element.getClassName());
// falseish value
property.setValue("");
Reactive.flush();
assertEquals("static", element.getClassName());
// trueish value
property.setValue(Double.valueOf(1));
Reactive.flush();
assertEquals("static dynamic", element.getClassName());
property.removeValue();
Reactive.flush();
assertEquals("static", element.getClassName());
}
use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.
the class GwtPolymerModelTest method testInitialUpdateModelProperty_propertyIsUpdatable_propertyIsSynced.
public void testInitialUpdateModelProperty_propertyIsUpdatable_propertyIsSynced() {
addMockMethods(element);
String propertyName = "black";
String propertyValue = "coffee";
setModelProperty(node, propertyName, propertyValue);
node.setNodeData(new UpdatableModelProperties(JsCollections.array(propertyName)));
Binder.bind(node, element);
Reactive.flush();
assertEquals("Expected to have property with name " + propertyName + " defined after initial binding", propertyValue, WidgetUtil.getJsProperty(element, propertyName));
String newPropertyValue = "bubblegum";
emulatePolymerPropertyChange(element, propertyName, newPropertyValue);
Reactive.flush();
assertEquals("Expected to have property with name " + propertyName + " updated from client side", newPropertyValue, WidgetUtil.getJsProperty(element, propertyName));
MapProperty property = node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty(propertyName);
assertEquals(newPropertyValue, property.getValue());
assertEquals(newPropertyValue, tree.synchronizedProperties.get(node).get(propertyName));
}
use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.
the class PollConfiguratorTest method listensToProperty.
@Test
public void listensToProperty() {
PollConfigurator.observe(stateTree.getRootNode(), new Poller(registry) {
@Override
public void setInterval(int interval) {
pollerSetIntervalCalled.incrementAndGet();
pollerInterval.set(interval);
}
});
Assert.assertEquals(-2, pollerInterval.get());
Assert.assertEquals(0, pollerSetIntervalCalled.get());
MapProperty pollIntervalProperty = stateTree.getRootNode().getMap(NodeFeatures.POLL_CONFIGURATION).getProperty(PollConfigurationMap.POLL_INTERVAL_KEY);
pollIntervalProperty.setValue(100.0);
Assert.assertEquals(100, pollerInterval.get());
Assert.assertEquals(1, pollerSetIntervalCalled.get());
pollIntervalProperty.setValue(-1.0);
Assert.assertEquals(-1, pollerInterval.get());
Assert.assertEquals(2, pollerSetIntervalCalled.get());
}
use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.
the class StateTreeTest method sendNodePropertySyncToServer_notInitialProperty_propertyIsSent.
@Test
public void sendNodePropertySyncToServer_notInitialProperty_propertyIsSent() {
tree.registerNode(node);
NodeMap map = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
MapProperty property = new MapProperty("foo", map);
property.setValue("bar");
connector.clear();
tree.sendNodePropertySyncToServer(property);
connector.assertMessage(node, "foo", "bar");
}
Aggregations