use of com.vaadin.flow.component.textfield.TextField in project testbench by vaadin.
the class ComponentQueryTest method id_noMatchingComponent_throws.
@Test
void id_noMatchingComponent_throws() {
Element rootElement = getCurrentView().getElement();
rootElement.appendChild(new TextField().getElement());
TextField textField = new TextField();
textField.setId("myId");
rootElement.appendChild(textField.getElement());
ComponentQuery<TextField> query = $view(TextField.class);
Assertions.assertThrows(NoSuchElementException.class, () -> query.id("test"));
}
use of com.vaadin.flow.component.textfield.TextField in project testbench by vaadin.
the class ComponentQueryTest method atIndex_outOfUpperBound_throws.
@Test
void atIndex_outOfUpperBound_throws() {
Element rootElement = getCurrentView().getElement();
rootElement.appendChild(new TextField().getElement(), new TextField().getElement(), new TextField().getElement());
ComponentQuery<TextField> query = $(TextField.class);
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> query.atIndex(4));
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> query.atIndex(100));
}
use of com.vaadin.flow.component.textfield.TextField in project testbench by vaadin.
the class ComponentQueryTest method thenOnFirst_firstNotFound_throws.
@Test
void thenOnFirst_firstNotFound_throws() {
Div div = new Div(new TextField());
div.setVisible(false);
UI.getCurrent().getElement().appendChild(div.getElement());
ComponentQuery<Div> query = $(Div.class);
Assertions.assertThrows(NoSuchElementException.class, () -> query.thenOnFirst(TextField.class));
}
use of com.vaadin.flow.component.textfield.TextField in project testbench by vaadin.
the class ComponentQueryTest method atIndex_exactMatch_getsComponent.
@Test
void atIndex_exactMatch_getsComponent() {
Element root = getCurrentView().getElement();
TextField textField = new TextField();
root.appendChild(textField.getElement());
Button button = new Button();
root.appendChild(button.getElement());
ComponentQuery<TextField> textFieldQuery = $(TextField.class);
Assertions.assertSame(textField, textFieldQuery.atIndex(1).getComponent(), "Expecting query to find TextField component, but got different instance");
ComponentQuery<Button> buttonQuery = $(Button.class);
Assertions.assertSame(button, buttonQuery.atIndex(1).getComponent(), "Expecting query to find Button component, but got different instance");
}
use of com.vaadin.flow.component.textfield.TextField in project vaadin-spinkit by mcollovati.
the class DemoUI method spinnerSizesContainer.
private Component spinnerSizesContainer() {
List<Spinner> spinners = EnumSet.complementOf(EnumSet.of(SpinnerSize.DEFAULT)).stream().map(size -> {
Spinner s = createSpinner(SpinnerType.PLANE);
s.setSize(size);
s.setTitle(size.name());
return s;
}).collect(Collectors.toList());
List<SpinnerType> spinnerTypes = Stream.of(SpinnerType.values()).filter(t -> !t.isAlias()).collect(Collectors.toList());
ComboBox<SpinnerType> selector = new ComboBox<>("Select spinner type", spinnerTypes);
selector.setPreventInvalidInput(true);
selector.setValue(SpinnerType.ROTATING_PLANE);
selector.addValueChangeListener(e -> spinners.forEach(s -> s.setType(selector.getValue())));
TextField baseSize = new TextField("Base size (--sk-size)", "40px");
baseSize.addValueChangeListener(e -> spinners.forEach(s -> s.setBaseSize(e.getValue())));
FlexibleGridLayout spinnersContainer = new FlexibleGridLayout().withColumns(Repeat.RepeatMode.AUTO_FILL, new Length("25%")).withPadding(true).withSpacing(true).withItems(spinners.stream().map(s -> spinnerWithName(s, Spinner::getSize)).toArray(Component[]::new));
for (SpinnerSize size : EnumSet.complementOf(EnumSet.of(SpinnerSize.DEFAULT))) {
Spinner spinner = new Spinner(SpinnerType.PLANE);
spinner.setSize(size);
spinner.setTitle(size.name());
spinners.add(spinner);
}
VerticalLayout commands = new VerticalLayout();
commands.setSizeUndefined();
commands.setAlignItems(FlexComponent.Alignment.START);
commands.setMargin(false);
commands.setSpacing(true);
commands.add(selector, baseSize);
VHorizontalLayout layout = new VHorizontalLayout(commands, spinnersContainer);
layout.setSizeFull();
layout.setMargin(true);
layout.setSpacing(true);
layout.setFlexGrow(1, spinnersContainer);
return layout;
}
Aggregations