Search in sources :

Example 6 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerTest method testSetStep_dividesEvenly_matchesGetter.

@Test
public void testSetStep_dividesEvenly_matchesGetter() {
    TimePicker timePicker = new TimePicker();
    assertEquals("Invalid default step", Duration.ofHours(1), timePicker.getStep());
    timePicker.setStep(Duration.ofSeconds(1));
    assertEquals("Invalid step returned", Duration.ofSeconds(1), timePicker.getStep());
    timePicker.setStep(Duration.ofMillis(1));
    assertEquals("Invalid step returned", Duration.ofMillis(1), timePicker.getStep());
    timePicker.setStep(Duration.ofMillis(10));
    assertEquals("Invalid step returned", Duration.ofMillis(10), timePicker.getStep());
    timePicker.setStep(Duration.ofMillis(100));
    assertEquals("Invalid step returned", Duration.ofMillis(100), timePicker.getStep());
    timePicker.setStep(Duration.ofMillis(1000));
    assertEquals("Invalid step returned", Duration.ofSeconds(1), timePicker.getStep());
    // the next 3 would be broken in the web component
    // https://github.com/vaadin/vaadin-time-picker/issues/79
    timePicker.setStep(Duration.ofMinutes(40));
    assertEquals("Invalid step returned", Duration.ofMinutes(40), timePicker.getStep());
    timePicker.setStep(Duration.ofMinutes(45));
    assertEquals("Invalid step returned", Duration.ofMinutes(45), timePicker.getStep());
    timePicker.setStep(Duration.ofMinutes(90));
    assertEquals("Invalid step returned", Duration.ofMinutes(90), timePicker.getStep());
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) GeneratedVaadinTimePicker(com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker) Test(org.junit.Test)

Example 7 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerTest method setMaxTime_getMax.

@Test
public void setMaxTime_getMax() {
    TimePicker timePicker = new TimePicker();
    final String max = "12:00";
    LocalTime maxTime = LocalTime.parse(max);
    timePicker.setMaxTime(maxTime);
    assertEquals(maxTime, timePicker.getMax());
    assertEquals(maxTime, timePicker.getMaxTime());
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) GeneratedVaadinTimePicker(com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker) LocalTime(java.time.LocalTime) Test(org.junit.Test)

Example 8 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerTest method timePicker_basicCases.

@Test
public void timePicker_basicCases() {
    TimePicker picker = new TimePicker();
    assertEquals(null, picker.getValue());
    assertFalse(picker.getElement().hasProperty("value"));
    picker.setValue(LocalTime.of(5, 30));
    assertEquals("05:30", picker.getElement().getProperty("value"));
    picker.getElement().setProperty("value", "07:40");
    assertEquals(LocalTime.of(7, 40), picker.getValue());
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) GeneratedVaadinTimePicker(com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker) Test(org.junit.Test)

Example 9 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerTest method testSetStep_lessThan0Ms_throwsException.

@Test(expected = IllegalArgumentException.class)
public void testSetStep_lessThan0Ms_throwsException() {
    TimePicker timePicker = new TimePicker();
    timePicker.setStep(Duration.ofNanos(500_000));
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) GeneratedVaadinTimePicker(com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker) Test(org.junit.Test)

Example 10 with TimePicker

use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.

the class TimePickerTest method testSetStep_secondsNotDivideEvenly_throwsException.

@Test(expected = IllegalArgumentException.class)
public void testSetStep_secondsNotDivideEvenly_throwsException() {
    TimePicker timePicker = new TimePicker();
    timePicker.setStep(Duration.ofSeconds(11));
}
Also used : TimePicker(com.vaadin.flow.component.timepicker.TimePicker) GeneratedVaadinTimePicker(com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker) Test(org.junit.Test)

Aggregations

TimePicker (com.vaadin.flow.component.timepicker.TimePicker)35 Test (org.junit.Test)23 GeneratedVaadinTimePicker (com.vaadin.flow.component.timepicker.GeneratedVaadinTimePicker)20 Div (com.vaadin.flow.component.html.Div)5 NativeButton (com.vaadin.flow.component.html.NativeButton)3 LocalTime (java.time.LocalTime)3 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)2 DatePicker (com.vaadin.flow.component.datepicker.DatePicker)2 Span (com.vaadin.flow.component.html.Span)2 TextField (com.vaadin.flow.component.textfield.TextField)2 Duration (java.time.Duration)2 Locale (java.util.Locale)2 HasLabel (com.vaadin.flow.component.HasLabel)1 ComboBox (com.vaadin.flow.component.combobox.ComboBox)1 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 RichTextEditor (com.vaadin.flow.component.richtexteditor.RichTextEditor)1 Select (com.vaadin.flow.component.select.Select)1 IntegerField (com.vaadin.flow.component.textfield.IntegerField)1 Binder (com.vaadin.flow.data.binder.Binder)1