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.

ComboBoxAtBottomEdgeWithinHorizontalLayoutTest.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.vaadin.tests.components.combobox;
  2. import org.junit.Test;
  3. import org.openqa.selenium.WebElement;
  4. import com.vaadin.testbench.By;
  5. import com.vaadin.testbench.elements.ComboBoxElement;
  6. import com.vaadin.tests.tb3.MultiBrowserTest;
  7. public class ComboBoxAtBottomEdgeWithinHorizontalLayoutTest
  8. extends MultiBrowserTest {
  9. @Test
  10. public void ensurePopupInView() {
  11. openTestURL();
  12. ComboBoxElement cb = $(ComboBoxElement.class).first();
  13. cb.openPopup();
  14. WebElement popup = cb.getSuggestionPopup();
  15. int cbBottom = cb.getLocation().getY() + cb.getSize().getHeight();
  16. int popupBottom = popup.getLocation().getY()
  17. + popup.getSize().getHeight();
  18. assertGreaterOrEqual(String.format(
  19. "Popup should not open below the ComboBox at the "
  20. + "bottom edge of the viewport. ComboBox: %s, Popup: %s",
  21. cbBottom, popupBottom), cbBottom, popupBottom);
  22. }
  23. @Test
  24. public void ensurePopupPositionUpdatesWhenFiltered() {
  25. openTestURL();
  26. ComboBoxElement cb = $(ComboBoxElement.class).first();
  27. cb.openPopup();
  28. WebElement popup = cb.getSuggestionPopup();
  29. int initialTop = popup.getLocation().getY();
  30. // filter a bit
  31. cb.findElement(By.vaadin("#textbox")).sendKeys("2");
  32. int updatedTop = popup.getLocation().getY();
  33. assertLessThan(String.format(
  34. "Popup should be repositioned when "
  35. + "filtered. Initial: %s, Updated: %s",
  36. initialTop, updatedTop), initialTop, updatedTop);
  37. int cbBottom = cb.getLocation().getY() + cb.getSize().getHeight();
  38. assertGreaterOrEqual(String.format(
  39. "Popup should still open above the ComboBox when "
  40. + "filtered a bit. ComboBox: %s, Popup: %s",
  41. cbBottom, updatedTop), cbBottom, updatedTop);
  42. // filter more
  43. cb.clear();
  44. cb.findElement(By.vaadin("#textbox")).sendKeys("1");
  45. popup = cb.getSuggestionPopup();
  46. updatedTop = popup.getLocation().getY();
  47. assertLessThanOrEqual(String.format(
  48. "Popup should open below the ComboBox when "
  49. + "filtered down to one result. ComboBox: %s, Popup: %s",
  50. cbBottom, updatedTop), cbBottom, updatedTop);
  51. }
  52. }