You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BinderValidatorErrorLevelTest.java 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.vaadin.tests.binder;
  2. import java.io.IOException;
  3. import java.util.Locale;
  4. import org.junit.Assert;
  5. import org.junit.Test;
  6. import com.vaadin.shared.ui.ErrorLevel;
  7. import com.vaadin.testbench.By;
  8. import com.vaadin.testbench.elements.TextFieldElement;
  9. import com.vaadin.tests.tb3.SingleBrowserTest;
  10. public class BinderValidatorErrorLevelTest extends SingleBrowserTest {
  11. @Test
  12. public void testErrorLevelStyleNames() throws IOException {
  13. openTestURL();
  14. for (ErrorLevel l : ErrorLevel.values()) {
  15. TextFieldElement textField = $(TextFieldElement.class)
  16. .caption(l.name()).first();
  17. // Screenshot the whole slot
  18. compareScreen(textField.findElement(By.xpath("..")),
  19. l.name().toLowerCase(Locale.ROOT));
  20. Assert.assertTrue("Error style for " + l.name() + " not present",
  21. textField.getAttribute("class")
  22. .contains("v-textfield-error-"
  23. + l.name().toLowerCase(Locale.ROOT)));
  24. textField.setValue("long enough text");
  25. Assert.assertFalse("Error style for " + l.name() + " still present",
  26. textField.getAttribute("class")
  27. .contains("v-textfield-error-"
  28. + l.name().toLowerCase(Locale.ROOT)));
  29. textField.setValue("foo");
  30. Assert.assertTrue(
  31. "Error style for " + l.name() + " should be present again.",
  32. textField.getAttribute("class")
  33. .contains("v-textfield-error-"
  34. + l.name().toLowerCase(Locale.ROOT)));
  35. }
  36. }
  37. }