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.

TooltipPosition.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.vaadin.tests.components;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.shared.ui.ContentMode;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.UI;
  6. import com.vaadin.ui.VerticalLayout;
  7. /**
  8. * This UI is used for testing that a tooltip is not positioned partially
  9. * outside the browser window when there is enough space to display it.
  10. *
  11. * @author Vaadin Ltd
  12. */
  13. public class TooltipPosition extends AbstractReindeerTestUI {
  14. public static final int NUMBER_OF_BUTTONS = 5;
  15. @Override
  16. protected void setup(VaadinRequest request) {
  17. // These tooltip delay settings can be removed once #13854 is resolved.
  18. getTooltipConfiguration().setOpenDelay(0);
  19. getTooltipConfiguration().setQuickOpenDelay(0);
  20. getTooltipConfiguration().setCloseTimeout(1000);
  21. VerticalLayout layout = new VerticalLayout();
  22. layout.setSpacing(true);
  23. layout.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight(),
  24. Unit.PIXELS);
  25. addComponent(layout);
  26. for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
  27. Button button = new Button("Button");
  28. button.setDescription(generateTooltipText(), ContentMode.HTML);
  29. layout.addComponent(button);
  30. }
  31. }
  32. private String generateTooltipText() {
  33. StringBuilder result = new StringBuilder();
  34. for (int i = 0; i < 50; i++) {
  35. result.append("This is the line ").append(i)
  36. .append(" of the long tooltip text.<br>");
  37. }
  38. return result.toString();
  39. }
  40. @Override
  41. public String getTestDescription() {
  42. return "The tooltips of the buttons should not be clipped when there is enough space to display them.";
  43. }
  44. @Override
  45. public Integer getTicketNumber() {
  46. return 15129;
  47. }
  48. }