use of com.vaadin.client.Registry in project flow by vaadin.
the class GwtBasicElementBinderTest method testAddTemplateChild.
public void testAddTemplateChild() {
final int templateId = 43;
TestElementTemplateNode templateNode = TestElementTemplateNode.create("child");
TemplateRegistry templates = new TemplateRegistry();
templates.register(templateId, templateNode);
Registry registry = new Registry() {
{
set(TemplateRegistry.class, templates);
set(ExistingElementMap.class, new ExistingElementMap());
}
};
StateTree stateTree = new StateTree(registry);
StateNode templateStateNode = new StateNode(345, stateTree);
templateStateNode.getMap(NodeFeatures.TEMPLATE).getProperty(NodeProperties.ROOT_TEMPLATE_ID).setValue(Double.valueOf(templateId));
StateNode parentElementNode = new StateNode(94, stateTree);
parentElementNode.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.TAG).setValue("div");
parentElementNode.getList(NodeFeatures.ELEMENT_CHILDREN).add(0, templateStateNode);
Element element = Browser.getDocument().createElement("div");
Binder.bind(parentElementNode, element);
Reactive.flush();
assertEquals(1, element.getChildElementCount());
assertEquals("CHILD", element.getFirstElementChild().getTagName());
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class GwtEventHandlerTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
Reactive.reset();
registry = new Registry() {
{
set(ConstantPool.class, new ConstantPool());
}
};
tree = new StateTree(registry) {
@Override
public void sendTemplateEventToServer(StateNode node, String methodName, JsArray<?> argValues) {
serverMethods.put(methodName, argValues);
serverRpcNodes.put(methodName, node);
}
};
node = new StateNode(0, tree);
// populate "element data" feature to be able to bind node as a plain
// element
node.getMap(NodeFeatures.ELEMENT_DATA);
element = Browser.getDocument().createElement("div");
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class GwtMultipleBindingTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
Reactive.reset();
registry = new Registry() {
{
set(ConstantPool.class, new ConstantPool());
set(ExistingElementMap.class, new ExistingElementMap());
}
};
tree = new StateTree(registry) {
@Override
public void sendTemplateEventToServer(StateNode node, String methodName, JsArray<?> argValues) {
}
};
node = new TestStateNode(tree);
// populate "element data" feature to be able to bind node as a plain
// element
node.getMap(NodeFeatures.ELEMENT_DATA);
element = Browser.getDocument().createElement("div");
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class GwtRouterLinkHandlerTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
invocations = JsCollections.array();
ServerConnector connector = new ServerConnector(null) {
@Override
public void sendNavigationMessage(String location, Object stateObject, boolean routerLinkEvent) {
invocations.push(location);
}
};
UILifecycle lifecycle = new UILifecycle();
lifecycle.setState(UIState.RUNNING);
registry = new Registry() {
{
set(UILifecycle.class, lifecycle);
set(ServerConnector.class, connector);
set(MessageHandler.class, new MessageHandler(this));
set(RequestResponseTracker.class, new RequestResponseTracker(this));
set(ScrollPositionHandler.class, new ScrollPositionHandler(this));
}
};
boundElement = Browser.getDocument().createDivElement();
Browser.getDocument().getBody().appendChild(boundElement);
RouterLinkHandler.bind(registry, boundElement);
}
use of com.vaadin.client.Registry in project flow by vaadin.
the class GwtStateTreeTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
registry = new Registry() {
{
set(ServerConnector.class, new TestServerConnector(this));
set(InitialPropertiesHandler.class, new InitialPropertiesHandler(this));
}
};
tree = new StateTree(registry);
}
Aggregations