Search in sources :

Example 81 with TextField

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

the class UIIntegerFieldIntegrationTest method testSetValue_WithPrimitiveIntegerInModelObject_RevertsForNull.

@Test
void testSetValue_WithPrimitiveIntegerInModelObject_RevertsForNull() {
    TextField textField = createFirstComponent(new TestModelObjectWithPrimitiveInteger());
    TestUiUtil.setUserOriginatedValue(textField, formatter.format(1));
    assertThat(textField.getValue(), is(formatter.format(1)));
    TestUiUtil.setUserOriginatedValue(textField, "");
    // field reverts to last valid value
    assertThat(textField.getValue(), is(formatter.format(1)));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 82 with TextField

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

the class UIIntegerFieldIntegrationTest method testSetValue_WithObjectIntegerInModelObject.

@Test
void testSetValue_WithObjectIntegerInModelObject() {
    TestModelObjectWithObjectInteger modelObject = new TestModelObjectWithObjectInteger();
    TextField textField = createFirstComponent(modelObject);
    assertThat(textField.getValue(), is(emptyString()));
    TestUiUtil.setUserOriginatedValue(textField, formatter.format(1));
    assertThat(modelObject.getValue(), is(1));
    modelObject.setValue(2);
    getBindingContext().modelChanged();
    assertThat(textField.getValue(), is(formatter.format(2)));
    TestUiUtil.setUserOriginatedValue(textField, textField.getEmptyValue());
    assertThat(getDefaultModelObject().getValue(), is(nullValue()));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 83 with TextField

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

the class UIIntegerFieldTest method testSetValue_WithPrimitiveIntegerInModelObject.

@Test
void testSetValue_WithPrimitiveIntegerInModelObject() {
    TextField textField = createIntegerTextField(new TestModelObjectWithPrimitiveInteger());
    Assertions.assertDoesNotThrow(() -> {
        TestUiUtil.setUserOriginatedValue(textField, "0");
    });
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 84 with TextField

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

the class UIIntegerFieldTest method testSetValue_WithObjectIntegerInModelObject.

@Test
void testSetValue_WithObjectIntegerInModelObject() {
    TextField textField = createIntegerTextField(new TestModelObjectWithObjectInteger());
    Assertions.assertDoesNotThrow(() -> {
        TestUiUtil.setUserOriginatedValue(textField, "");
        TestUiUtil.setUserOriginatedValue(textField, "0");
    });
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 85 with TextField

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

the class UIIntegerFieldTest method testSetValue_WithThousandSeparatorOnPrimitiveInteger_EN.

@Test
void testSetValue_WithThousandSeparatorOnPrimitiveInteger_EN() {
    UI.getCurrent().setLocale(Locale.ENGLISH);
    TextField textField = createIntegerTextField(new TestModelObjectWithPrimitiveInteger());
    TestUiUtil.setUserOriginatedValue(textField, "98765432");
    assertThat(textField.getValue(), is("98,765,432"));
}
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