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 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.shared.ui.ContentMode;
  19. import com.vaadin.ui.Button;
  20. import com.vaadin.ui.UI;
  21. import com.vaadin.ui.VerticalLayout;
  22. /**
  23. * This UI is used for testing that a tooltip is not positioned partially
  24. * outside the browser window when there is enough space to display it.
  25. *
  26. * @author Vaadin Ltd
  27. */
  28. public class TooltipPosition extends AbstractReindeerTestUI {
  29. public static final int NUMBER_OF_BUTTONS = 5;
  30. @Override
  31. protected void setup(VaadinRequest request) {
  32. // These tooltip delay settings can be removed once #13854 is resolved.
  33. getTooltipConfiguration().setOpenDelay(0);
  34. getTooltipConfiguration().setQuickOpenDelay(0);
  35. getTooltipConfiguration().setCloseTimeout(1000);
  36. VerticalLayout layout = new VerticalLayout();
  37. layout.setSpacing(true);
  38. layout.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight(),
  39. Unit.PIXELS);
  40. addComponent(layout);
  41. for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
  42. Button button = new Button("Button");
  43. button.setDescription(generateTooltipText(), ContentMode.HTML);
  44. layout.addComponent(button);
  45. }
  46. }
  47. private String generateTooltipText() {
  48. StringBuilder result = new StringBuilder();
  49. for (int i = 0; i < 50; i++) {
  50. result.append("This is the line ").append(i)
  51. .append(" of the long tooltip text.<br>");
  52. }
  53. return result.toString();
  54. }
  55. @Override
  56. public String getTestDescription() {
  57. return "The tooltips of the buttons should not be clipped when there is enough space to display them.";
  58. }
  59. @Override
  60. public Integer getTicketNumber() {
  61. return 15129;
  62. }
  63. }