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.

AdjacentElementsWithTooltipsTest.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2000-2014 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.tooltip;
  17. import static org.hamcrest.Matchers.greaterThan;
  18. import static org.hamcrest.Matchers.is;
  19. import static org.hamcrest.Matchers.lessThan;
  20. import static org.junit.Assert.assertThat;
  21. import java.util.List;
  22. import org.junit.Test;
  23. import org.openqa.selenium.interactions.HasInputDevices;
  24. import org.openqa.selenium.interactions.Mouse;
  25. import org.openqa.selenium.interactions.internal.Coordinates;
  26. import org.openqa.selenium.internal.Locatable;
  27. import org.openqa.selenium.remote.DesiredCapabilities;
  28. import com.vaadin.testbench.elements.ButtonElement;
  29. import com.vaadin.tests.tb3.MultiBrowserTest;
  30. /**
  31. * Test to see if tooltips obey quickOpenDelay when moving between directly
  32. * adjacent elements.
  33. *
  34. * @author Vaadin Ltd
  35. */
  36. public class AdjacentElementsWithTooltipsTest extends MultiBrowserTest {
  37. @Override
  38. public List<DesiredCapabilities> getBrowsersToTest() {
  39. return getBrowsersExcludingIE();
  40. }
  41. @Test
  42. public void tooltipsHaveQuickOpenDelay() throws InterruptedException {
  43. openTestURL();
  44. Coordinates button0Coordinates = getButtonCoordinates("Button 0");
  45. Coordinates button1Coordinates = getButtonCoordinates("Button 1");
  46. Mouse mouse = getMouse();
  47. mouse.mouseMove(button0Coordinates, 10, 10);
  48. sleep(1000);
  49. assertThat(getTooltipElement().getLocation().x, is(greaterThan(0)));
  50. mouse.mouseMove(button1Coordinates, 10, 10);
  51. assertThat(getTooltipElement().getLocation().x, is(lessThan(-1000)));
  52. sleep(1000);
  53. assertThat(getTooltipElement().getLocation().x,
  54. is(greaterThan(button1Coordinates.onPage().x)));
  55. }
  56. private Coordinates getButtonCoordinates(String caption) {
  57. return getCoordinates(getButton(caption));
  58. }
  59. private ButtonElement getButton(String caption) {
  60. return $(ButtonElement.class).caption(caption).first();
  61. }
  62. }