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.

TreeContextClickTest.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.contextclick;
  17. import static org.junit.Assert.assertEquals;
  18. import java.util.List;
  19. import org.junit.Test;
  20. import org.openqa.selenium.WebElement;
  21. import org.openqa.selenium.interactions.Actions;
  22. import com.vaadin.testbench.By;
  23. import com.vaadin.v7.testbench.elements.TreeElement;
  24. public class TreeContextClickTest extends AbstractContextClickTest {
  25. @Test
  26. public void testContextClickOnItem() {
  27. openTestURL();
  28. addOrRemoveTypedListener();
  29. List<WebElement> nodes = $(TreeElement.class).first()
  30. .findElements(By.className("v-tree-node"));
  31. contextClick(nodes.get(1));
  32. assertEquals("1. ContextClickEvent: Bar", getLogRow(0));
  33. contextClick(nodes.get(0));
  34. assertEquals("2. ContextClickEvent: Foo", getLogRow(0));
  35. }
  36. @Test
  37. public void testContextClickOnSubItem() {
  38. openTestURL();
  39. addOrRemoveTypedListener();
  40. List<WebElement> nodes = $(TreeElement.class).first()
  41. .findElements(By.className("v-tree-node"));
  42. new Actions(getDriver()).moveToElement(nodes.get(1), 10, 10).click()
  43. .perform();
  44. nodes = $(TreeElement.class).first()
  45. .findElements(By.className("v-tree-node"));
  46. contextClick(nodes.get(2));
  47. assertEquals("1. ContextClickEvent: Baz", getLogRow(0));
  48. }
  49. @Test
  50. public void testContextClickOnEmptyArea() {
  51. openTestURL();
  52. addOrRemoveTypedListener();
  53. contextClick($(TreeElement.class).first(), 20, 100);
  54. assertEquals("1. ContextClickEvent: null", getLogRow(0));
  55. }
  56. }