use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class ComponentTest method mapToComponentWhichHasComponentField.
@Test
public void mapToComponentWhichHasComponentField() {
Element e = new Element("div");
TestComponentWhichHasComponentField c = Component.from(e, TestComponentWhichHasComponentField.class);
Element buttonElement = c.getElement().getChild(0);
Assert.assertEquals(e, c.getElement());
Assert.assertNotEquals(e, buttonElement);
Assert.assertEquals("button", buttonElement.getTag());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class ComponentTest method setElementTwice.
@Test(expected = IllegalStateException.class)
public void setElementTwice() {
Component c = new Component(null) {
};
Element element = ElementFactory.createDiv();
Component.setElement(c, element);
Component.setElement(c, element);
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class ComponentTest method synchronizePropertyWithPropertyName.
@Test
public void synchronizePropertyWithPropertyName() {
SynchronizePropertyOnChangeGivenPropertyComponent component = new SynchronizePropertyOnChangeGivenPropertyComponent();
Element element = component.getElement();
assertSynchronizedProperties(element, "bar");
assertSynchronizedPropertiesEvents(element, "change");
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class ComponentTest method wrappedComponentGetChildren.
@Test(expected = IllegalStateException.class)
public void wrappedComponentGetChildren() {
Element div = new Element("div");
Element button = new Element("button");
div.appendChild(button);
button.as(TestButton.class);
div.as(TestDiv.class).getChildren();
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class CompositeTest method testOnAttachOnDetachAndEventsOrder.
@Test
public void testOnAttachOnDetachAndEventsOrder() {
List<Integer> triggered = new ArrayList<>();
Component component = new Component(new Element("div")) {
@Override
protected void onAttach(AttachEvent attachEvent) {
triggered.add(1);
}
@Override
protected void onDetach(DetachEvent detachEvent) {
triggered.add(-1);
}
};
component.addAttachListener(event -> triggered.add(2));
component.addDetachListener(event -> triggered.add(-2));
Composite<Component> compositeInsideComposite = new Composite<Component>() {
@Override
protected Component initContent() {
return component;
}
@Override
protected void onAttach(AttachEvent attachEvent) {
triggered.add(3);
}
@Override
protected void onDetach(DetachEvent detachEvent) {
triggered.add(-3);
}
};
compositeInsideComposite.addAttachListener(event -> triggered.add(4));
compositeInsideComposite.addDetachListener(event -> triggered.add(-4));
Composite<Component> composite = new Composite<Component>() {
@Override
protected Component initContent() {
return compositeInsideComposite;
}
@Override
protected void onAttach(AttachEvent attachEvent) {
triggered.add(5);
}
@Override
protected void onDetach(DetachEvent detachEvent) {
triggered.add(-5);
}
};
composite.addAttachListener(event -> triggered.add(6));
composite.addDetachListener(event -> triggered.add(-6));
UI ui = new UI();
ui.add(composite);
TestUtil.assertArrays(triggered.toArray(), new Integer[] { 1, 2, 3, 4, 5, 6 });
triggered.clear();
ui.remove(composite);
TestUtil.assertArrays(triggered.toArray(), new Integer[] { -1, -2, -3, -4, -5, -6 });
TestLayout container = createTestLayout();
ui.add(container, composite);
triggered.clear();
container.addComponent(composite);
TestUtil.assertArrays(triggered.toArray(), new Integer[] { -1, -2, -3, -4, -5, -6, 1, 2, 3, 4, 5, 6 });
}
Aggregations