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.

InlineDateFieldReadOnlyTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.vaadin.tests.components.datefield;
  2. import com.vaadin.tests.tb3.MultiBrowserTest;
  3. import org.junit.Test;
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.WebElement;
  6. import java.util.List;
  7. import static junit.framework.TestCase.assertEquals;
  8. import static junit.framework.TestCase.assertFalse;
  9. public class InlineDateFieldReadOnlyTest extends MultiBrowserTest {
  10. @Test
  11. public void minutesAndSecondsAreRenderedCorrectly() {
  12. openTestURL();
  13. WebElement divTime = findElement(By.className("v-datefield-time"));
  14. List<WebElement> labels = divTime.findElements(By.className("v-label"));
  15. assertEquals(5, labels.size());
  16. // At positions 1 and 3 the delimeter label is set
  17. assertEquals(InlineDateFieldReadOnly.HOUR,
  18. convertToInt(labels.get(0).getText()));
  19. assertEquals(InlineDateFieldReadOnly.MIN,
  20. convertToInt(labels.get(2).getText()));
  21. assertEquals(InlineDateFieldReadOnly.SEC,
  22. convertToInt(labels.get(4).getText()));
  23. }
  24. private int convertToInt(String value) {
  25. int converted = -1;
  26. try {
  27. converted = Integer.valueOf(value).intValue();
  28. } catch (NumberFormatException e) {
  29. assertFalse(
  30. "NumberFormatException is thrown! Conversion was not possible",
  31. e instanceof NumberFormatException);
  32. }
  33. return converted;
  34. }
  35. }