use of com.vaadin.client.Registry in project flow by vaadin.
the class ExecuteJavaScriptProcessorTest method isBound_hasElementHasFeatureAndBound_bound.
@Test
public void isBound_hasElementHasFeatureAndBound_bound() {
TestJsProcessor processor = new TestJsProcessor();
Registry registry = processor.getRegistry();
StateNode node = new StateNode(37, registry.getStateTree());
// emulate binding
JsElement element = new JsElement() {
};
node.setDomNode(element);
node.getMap(NodeFeatures.VISIBILITY_DATA).getProperty(NodeProperties.VISIBILITY_BOUND_PROPERTY).setValue(true);
Assert.assertTrue(processor.isBound(node));
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class GwtDomApiTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
registry = new Registry() {
{
UILifecycle uiLifecycle = new UILifecycle();
uiLifecycle.setState(UIState.RUNNING);
set(UILifecycle.class, uiLifecycle);
set(RequestResponseTracker.class, new RequestResponseTracker(this));
set(MessageHandler.class, new MessageHandler(this));
set(ServerRpcQueue.class, new ServerRpcQueue(this));
set(DependencyLoader.class, new DependencyLoader(this));
set(ResourceLoader.class, new ResourceLoader(this, false));
}
};
registry.getRequestResponseTracker().startRequest();
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class GwtTemplateBinderTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
registry = new Registry() {
{
set(TemplateRegistry.class, new TemplateRegistry());
set(ConstantPool.class, new ConstantPool());
set(ExistingElementMap.class, new ExistingElementMap());
set(InitialPropertiesHandler.class, new InitialPropertiesHandler(this));
set(StateTree.class, new StateTree(this) {
@Override
public void sendTemplateEventToServer(StateNode node, String methodName, JsArray<?> argValues) {
serverMethods.put(methodName, argValues);
serverRpcNodes.put(methodName, node);
}
});
}
};
tree = registry.getStateTree();
/**
* This state node is ALWAYS a template !!!
*/
stateNode = new StateNode(0, tree) {
@Override
public boolean hasFeature(int id) {
if (id == NodeFeatures.TEMPLATE) {
return true;
}
return super.hasFeature(id);
}
};
// Use the most common model structure by default
JsonObject modelType = Json.createObject();
modelType.put(MODEL_KEY, "String");
setModelType(stateNode, modelType);
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class ExecuteJavaScriptProcessorTest method isBound_noElement_notBound.
@Test
public void isBound_noElement_notBound() {
TestJsProcessor processor = new TestJsProcessor();
Registry registry = processor.getRegistry();
StateNode node = new StateNode(37, registry.getStateTree());
Assert.assertFalse(processor.isBound(node));
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class ExecuteJavaScriptProcessorTest method execute_nodeParametersAreCorrectlyPassed.
@Test
public void execute_nodeParametersAreCorrectlyPassed() {
Registry registry = new Registry() {
{
StateTree tree = new StateTree(this);
set(StateTree.class, tree);
set(ExistingElementMap.class, new ExistingElementMap());
}
};
CollectingExecuteJavaScriptProcessor processor = new CollectingExecuteJavaScriptProcessor(registry);
StateNode node = new StateNode(10, registry.getStateTree());
registry.getStateTree().registerNode(node);
JsElement element = new JsElement() {
};
node.setDomNode(element);
JsonArray json = JsonUtils.createArray(Json.create(JsonCodec.NODE_TYPE), Json.create(node.getId()));
JsonArray invocation = Stream.of(json, Json.create("$0")).collect(JsonUtils.asArray());
// JRE impl of the array uses
processor.execute(JsonUtils.createArray(invocation));
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