Search in sources :

Example 86 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class UITextFieldIntegrationTest method testTextVieldValue.

@Test
void testTextVieldValue() {
    TestModelObjectWithString modelObject = new TestModelObjectWithString();
    TextField textField = createFirstComponent(modelObject);
    assertThat(textField.getMaxLength(), is(MAX_LENGTH));
    assertThat(textField.getWidth(), is("42em"));
    assertThat(textField.getValue(), is(""));
    TestUiUtil.setUserOriginatedValue(textField, "asdf");
    assertThat(modelObject.getValue(), is("asdf"));
    modelObject.setValue("fdsa");
    getBindingContext().modelChanged();
    assertThat(textField.getValue(), is("fdsa"));
    // clearing textfield results in ""
    TestUiUtil.setUserOriginatedValue(textField, textField.getEmptyValue());
    assertThat(modelObject.getValue(), is(emptyString()));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 87 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class UITextFieldIntegrationTest method testNullInputIfRequired.

@Test
@Override
void testNullInputIfRequired() {
    TextField textField = getDynamicComponent();
    getDefaultPmo().setRequired(true);
    modelChanged();
    assertThat(textField.isRequiredIndicatorVisible(), is(true));
    TestUiUtil.setUserOriginatedValue(textField, "something");
    assertThat(getDefaultModelObject().getValue(), is("something"));
    // clearing textfield results in ""
    TestUiUtil.setUserOriginatedValue(textField, textField.getEmptyValue());
    assertThat(getDefaultModelObject().getValue(), is(emptyString()));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 88 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class FormItemComponentWrapperTest method testSetTooltip.

@Test
void testSetTooltip() {
    TextField formTextField = new TextField();
    LabelComponentFormItem formItem = new LabelComponentFormItem(formTextField, new Label("SomeText"));
    FormItemComponentWrapper wrapper = new FormItemComponentWrapper(formItem);
    wrapper.setTooltip("testTip");
    assertThat(getTitleAttribute(wrapper), is("testTip"));
    wrapper.setTooltip("<script>");
    assertThat(getTitleAttribute(wrapper), is(""));
    wrapper.setTooltip("<div> some text </div>");
    assertThat(getTitleAttribute(wrapper), is(" some text "));
    wrapper.setTooltip("<div> some text <br> with page break</div> ");
    assertThat(getTitleAttribute(wrapper), is(" some text \n with page break "));
}
Also used : Label(com.vaadin.flow.component.html.Label) TextField(com.vaadin.flow.component.textfield.TextField) LabelComponentFormItem(org.linkki.core.vaadin.component.base.LabelComponentFormItem) Test(org.junit.jupiter.api.Test)

Example 89 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class LabelComponentWrapperTest method testSetLabel_Null.

@Test
public void testSetLabel_Null() {
    TextField component = new TextField();
    LabelComponentWrapper wrapper = new LabelComponentWrapper(component, WrapperType.FIELD);
    wrapper.setLabel(null);
    assertThat(component.getElement().hasProperty("label"), is(false));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 90 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class LabelComponentWrapperTest method testSetLabel.

@Test
public void testSetLabel() {
    TextField component = new TextField();
    LabelComponentWrapper wrapper = new LabelComponentWrapper(component, WrapperType.FIELD);
    wrapper.setLabel("Label Text");
    assertThat(component.getElement().getProperty("label"), is("Label Text"));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Aggregations

TextField (com.vaadin.flow.component.textfield.TextField)227 Test (org.junit.jupiter.api.Test)61 Button (com.vaadin.flow.component.button.Button)54 Div (com.vaadin.flow.component.html.Div)38 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)32 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)29 Binder (com.vaadin.flow.data.binder.Binder)29 GeneratedVaadinTextField (com.vaadin.flow.component.textfield.GeneratedVaadinTextField)28 Element (com.vaadin.flow.dom.Element)26 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)23 Route (com.vaadin.flow.router.Route)21 Component (com.vaadin.flow.component.Component)16 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)15 BinderCrudEditor (com.vaadin.flow.component.crud.BinderCrudEditor)15 Grid (com.vaadin.flow.component.grid.Grid)15 Span (com.vaadin.flow.component.html.Span)15 List (java.util.List)15 EmailField (com.vaadin.flow.component.textfield.EmailField)14 TextArea (com.vaadin.flow.component.textfield.TextArea)14 Test (org.junit.Test)14