Search in sources :

Example 46 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class ComponentTest method wrappedComponentUsesElement.

@Test
public void wrappedComponentUsesElement() {
    Element div = new Element("div");
    div.setAttribute("id", "foo");
    Assert.assertEquals(Optional.of("foo"), div.as(TestDiv.class).getId());
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 47 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class ComponentTest method mapToComponentWithElementConstructor.

@Test
public void mapToComponentWithElementConstructor() {
    Element e = new Element("my-element");
    TestComponentWhichUsesElementConstructor c = Component.from(e, TestComponentWhichUsesElementConstructor.class);
    Assert.assertSame(e, c.getElement());
    Assert.assertSame(c, e.getComponent().get());
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 48 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class ComponentTest method synchronizePropertyElementConstructor.

@Test
public void synchronizePropertyElementConstructor() {
    SynchronizePropertyUsingElementConstructor component = new SynchronizePropertyUsingElementConstructor();
    component.customInit();
    Element element = component.getElement();
    assertSynchronizedProperties(element, "foo");
    assertSynchronizedPropertiesEvents(element, "change");
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 49 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class ComponentTest method defaultGetChildrenMultiple.

@Test
public void defaultGetChildrenMultiple() {
    // parent
    // * level1
    // ** child1
    // ** child2
    Element level1 = ElementFactory.createDiv("Level1");
    parentDivComponent.getElement().appendChild(level1);
    level1.appendChild(child1SpanComponent.getElement());
    level1.appendChild(child2InputComponent.getElement());
    assertChildren(parentDivComponent, child1SpanComponent, child2InputComponent);
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Example 50 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class ComponentTest method mapToComponentWhichCreatesComponentInConstructor.

@Test
public void mapToComponentWhichCreatesComponentInConstructor() {
    Element e = new Element("div");
    TestComponentWhichCreatesComponentInConstructor c = Component.from(e, TestComponentWhichCreatesComponentInConstructor.class);
    Element buttonElement = c.getElement().getChild(0);
    Assert.assertEquals(e, c.getElement());
    Assert.assertNotEquals(e, buttonElement);
    Assert.assertEquals("button", buttonElement.getTag());
}
Also used : Element(com.vaadin.flow.dom.Element) Test(org.junit.Test)

Aggregations

Element (com.vaadin.flow.dom.Element)377 Test (org.junit.Test)322 UI (com.vaadin.flow.component.UI)42 StateNode (com.vaadin.flow.internal.StateNode)32 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)29 Style (com.vaadin.flow.dom.Style)25 StreamResource (com.vaadin.flow.server.StreamResource)20 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)19 ArrayList (java.util.ArrayList)14 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)13 JsonObject (elemental.json.JsonObject)12 WeakReference (java.lang.ref.WeakReference)12 URI (java.net.URI)11 ElementPropertyMap (com.vaadin.flow.internal.nodefeature.ElementPropertyMap)10 Registration (com.vaadin.flow.shared.Registration)10 JsonValue (elemental.json.JsonValue)10 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)9 ChildElementConsumer (com.vaadin.flow.dom.ChildElementConsumer)8 AttachExistingElementFeature (com.vaadin.flow.internal.nodefeature.AttachExistingElementFeature)8