use of com.vaadin.client.Registry in project flow by vaadin.
the class ExecuteJavaScriptProcessorTest method execute_nodeParameterIsHidden.
@Test
public void execute_nodeParameterIsHidden() {
CollectingExecuteJavaScriptProcessor processor = new CollectingExecuteJavaScriptProcessor();
Registry registry = processor.getRegistry();
StateNode node = new StateNode(31, registry.getStateTree());
processor.isBound = false;
registry.getStateTree().registerNode(node);
JsonArray json = JsonUtils.createArray(Json.create(JsonCodec.NODE_TYPE), Json.create(node.getId()));
JsonArray invocation = Stream.of(json, Json.create("$0")).collect(JsonUtils.asArray());
processor.execute(JsonUtils.createArray(invocation));
Assert.assertEquals(0, processor.nodeParametersList.size());
// emulate binding
JsElement element = new JsElement() {
};
node.setDomNode(element);
processor.isBound = true;
Reactive.flush();
Assert.assertEquals(1, processor.nodeParametersList.size());
Assert.assertEquals(1, processor.nodeParametersList.get(0).size());
JsMap<Object, StateNode> map = processor.nodeParametersList.get(0);
StateNode stateNode = map.get(element);
Assert.assertEquals(node, stateNode);
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class ExecuteJavaScriptProcessorTest method isBound_hasElementHasNoFeatureAndBoundParent_bound.
@Test
public void isBound_hasElementHasNoFeatureAndBoundParent_bound() {
TestJsProcessor processor = new TestJsProcessor();
Registry registry = processor.getRegistry();
StateNode node = new StateNode(37, registry.getStateTree());
StateNode parent = new StateNode(43, registry.getStateTree());
node.setParent(parent);
// emulate binding
JsElement element = new JsElement() {
};
node.setDomNode(element);
parent.setDomNode(element);
Assert.assertTrue(processor.isBound(node));
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class ExecuteJavaScriptProcessorTest method execute_nodeParameterIsVirtualChildAwaitingInit.
@Test
public void execute_nodeParameterIsVirtualChildAwaitingInit() {
CollectingExecuteJavaScriptProcessor processor = new CollectingExecuteJavaScriptProcessor();
Registry registry = processor.getRegistry();
StateNode node = new StateNode(11, registry.getStateTree());
JsonObject object = Json.createObject();
object.put(NodeProperties.TYPE, NodeProperties.INJECT_BY_ID);
node.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.PAYLOAD).setValue(object);
registry.getStateTree().registerNode(node);
JsonArray json = JsonUtils.createArray(Json.create(JsonCodec.NODE_TYPE), Json.create(node.getId()));
JsonArray invocation = Stream.of(json, Json.create("$0")).collect(JsonUtils.asArray());
processor.execute(JsonUtils.createArray(invocation));
// The invocation has not been executed
Assert.assertEquals(0, processor.nodeParametersList.size());
// emulate binding
JsElement element = new JsElement() {
};
node.setDomNode(element);
Reactive.flush();
Assert.assertEquals(1, processor.nodeParametersList.size());
Assert.assertEquals(1, processor.nodeParametersList.get(0).size());
JsMap<Object, StateNode> map = processor.nodeParametersList.get(0);
StateNode stateNode = map.get(element);
Assert.assertEquals(node, stateNode);
}
Aggregations