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.

MenuTooltipTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.components.menubar;
  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.remote.DesiredCapabilities;
  27. import com.vaadin.testbench.elements.MenuBarElement;
  28. import com.vaadin.tests.tb3.MultiBrowserTest;
  29. /**
  30. * Test to see if tooltips on menu items obscure other items on the menu.
  31. *
  32. * @author Vaadin Ltd
  33. */
  34. public class MenuTooltipTest extends MultiBrowserTest {
  35. @Override
  36. public List<DesiredCapabilities> getBrowsersToTest() {
  37. return getBrowsersExcludingIE();
  38. }
  39. @Test
  40. public void testToolTipDelay() throws InterruptedException {
  41. openTestURL();
  42. Coordinates elementCoordinates = getCoordinates($(MenuBarElement.class)
  43. .first());
  44. Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
  45. mouse.click(elementCoordinates);
  46. mouse.mouseMove(elementCoordinates, 15, 40);
  47. sleep(1000);
  48. assertThat(getTooltipElement().getLocation().getX(),
  49. is(lessThan(-1000)));
  50. sleep(3000);
  51. assertThat(getTooltipElement().getLocation().getX(),
  52. is(greaterThan(elementCoordinates.onPage().getX())));
  53. assertThat(getTooltipElement().getText(), is("TOOLTIP 1"));
  54. }
  55. }