use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarView method createProgressBarWithThemeVariant.
private void createProgressBarWithThemeVariant() {
ProgressBar progressBar = new ProgressBar();
progressBar.setId("progress-bar-theme-variant");
progressBar.setValue(0.345);
progressBar.addThemeVariants(ProgressBarVariant.LUMO_ERROR);
NativeButton removeVariantButton = new NativeButton("Remove theme variant", e -> progressBar.removeThemeVariants(ProgressBarVariant.LUMO_ERROR));
removeVariantButton.setId("remove-theme-variant-button");
addCard("Progress Bar Theme Variant", progressBar, removeVariantButton);
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarView method createProgressBarWithCustomBounds.
private void createProgressBarWithCustomBounds() {
ProgressBar progressBar = new ProgressBar(10, 100, 20);
NativeButton progressButton = new NativeButton("Make progress", e -> {
double value = progressBar.getValue() + 10;
if (value > progressBar.getMax()) {
value = progressBar.getMin();
}
progressBar.setValue(value);
});
progressBar.setId("custom-progress-bar");
progressButton.setId("progress-button");
addCard("Progress bar with custom bounds", progressBar, progressButton);
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarTest method setValueShouldUpdateValueToMin.
@Test
public void setValueShouldUpdateValueToMin() {
double min = 10;
double max = 100;
double value = 42;
ProgressBar progressBar = new ProgressBar(min, max, value);
assertThat("initial value is wrong", progressBar.getValue(), is(value));
progressBar.setValue(min);
assertThat("min is wrong", progressBar.getMin(), is(min));
assertThat("max is wrong", progressBar.getMax(), is(max));
assertThat("updated value is wrong", progressBar.getValue(), is(min));
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarTest method setValueShouldUpdateValue.
@Test
public void setValueShouldUpdateValue() {
double min = 10;
double max = 100;
double value = 25;
ProgressBar progressBar = new ProgressBar(min, max);
assertThat("initial value is wrong", progressBar.getValue(), is(min));
progressBar.setValue(value);
assertThat("min is wrong", progressBar.getMin(), is(min));
assertThat("max is wrong", progressBar.getMax(), is(max));
assertThat("updated value is wrong", progressBar.getValue(), is(value));
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarTest method setValueShouldThrowIfValueGreaterThanMax.
@Test
public void setValueShouldThrowIfValueGreaterThanMax() {
double min = 10.0;
double max = 100.0;
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(String.format("value must be between min ('%s') and max ('%s')", min, max));
ProgressBar progressBar = new ProgressBar(min, max);
progressBar.setValue(101);
}
Aggregations