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.

TableItemDescriptionGeneratorUITest.java 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. package com.vaadin.tests.components.table;
  2. import java.util.List;
  3. import org.junit.Test;
  4. import org.openqa.selenium.interactions.Actions;
  5. import com.vaadin.testbench.By;
  6. import com.vaadin.testbench.TestBenchElement;
  7. import com.vaadin.testbench.elements.CheckBoxElement;
  8. import com.vaadin.testbench.elements.TableElement;
  9. import com.vaadin.tests.tb3.TooltipTest;
  10. import static org.junit.Assert.assertEquals;
  11. /**
  12. * Tests Table tooltips with various settings.
  13. *
  14. * @author Vaadin Ltd
  15. */
  16. public class TableItemDescriptionGeneratorUITest extends TooltipTest {
  17. @Test
  18. public void testDescriptions() throws Exception {
  19. openTestURL();
  20. checkTooltipNotPresent();
  21. TableElement table = $(TableElement.class).first();
  22. List<CheckBoxElement> checkboxes = $(CheckBoxElement.class).all();
  23. assertEquals(3, checkboxes.size());
  24. // check text description
  25. TestBenchElement cell_1_0 = table.getCell(1, 0);
  26. cell_1_0.showTooltip();
  27. checkTooltip("Cell description item 1, Text");
  28. // move somewhere without a description
  29. checkboxes.get(2).showTooltip();
  30. checkTooltipNotPresent();
  31. // check button description
  32. TestBenchElement cell_1_1 = table.getCell(1, 1);
  33. cell_1_1.showTooltip();
  34. checkTooltip("Button 1 description");
  35. // move somewhere without a description
  36. checkboxes.get(2).showTooltip();
  37. checkTooltipNotPresent();
  38. // check textfield's description
  39. TestBenchElement cell_1_2 = table.getCell(1, 2);
  40. cell_1_2.showTooltip();
  41. checkTooltip("Textfield's own description");
  42. // move somewhere without a description
  43. checkboxes.get(2).showTooltip();
  44. checkTooltipNotPresent();
  45. // uncheck component tooltips
  46. checkboxes.get(0).findElement(By.tagName("input")).click();
  47. // check text description
  48. cell_1_0 = table.getCell(1, 0);
  49. cell_1_0.showTooltip();
  50. checkTooltip("Cell description item 1, Text");
  51. // move somewhere without a description
  52. checkboxes.get(2).showTooltip();
  53. checkTooltipNotPresent();
  54. // check button description
  55. cell_1_1 = table.getCell(1, 1);
  56. cell_1_1.showTooltip();
  57. checkTooltip("Cell description item 1, Component");
  58. // move somewhere without a description
  59. new Actions(getDriver()).moveToElement(checkboxes.get(2)).perform();
  60. sleep(1000);
  61. checkTooltipNotPresent();
  62. // check textfield's description
  63. cell_1_2 = table.getCell(1, 2);
  64. cell_1_2.showTooltip();
  65. checkTooltip("Cell description item 1, Generated component");
  66. // move somewhere without a description
  67. checkboxes.get(2).showTooltip();
  68. checkTooltipNotPresent();
  69. // check component tooltips
  70. checkboxes.get(0).findElement(By.tagName("input")).click();
  71. // uncheck cell tooltips
  72. checkboxes.get(1).findElement(By.tagName("input")).click();
  73. // check text description
  74. cell_1_0 = table.getCell(1, 0);
  75. cell_1_0.showTooltip();
  76. checkTooltip("Row description item 1");
  77. // move somewhere without a description
  78. checkboxes.get(2).showTooltip();
  79. checkTooltipNotPresent();
  80. // check button description
  81. cell_1_1 = table.getCell(1, 1);
  82. cell_1_1.showTooltip();
  83. checkTooltip("Button 1 description");
  84. // move somewhere without a description
  85. checkboxes.get(2).showTooltip();
  86. checkTooltipNotPresent();
  87. // check textfield's description
  88. cell_1_2 = table.getCell(1, 2);
  89. cell_1_2.showTooltip();
  90. checkTooltip("Textfield's own description");
  91. // move somewhere without a description
  92. checkboxes.get(2).showTooltip();
  93. checkTooltipNotPresent();
  94. // uncheck component tooltips
  95. checkboxes.get(0).findElement(By.tagName("input")).click();
  96. // check text description
  97. cell_1_0 = table.getCell(1, 0);
  98. cell_1_0.showTooltip();
  99. checkTooltip("Row description item 1");
  100. // move somewhere without a description
  101. checkboxes.get(2).showTooltip();
  102. checkTooltipNotPresent();
  103. // check button description
  104. cell_1_1 = table.getCell(1, 1);
  105. cell_1_1.showTooltip();
  106. checkTooltip("Row description item 1");
  107. // move somewhere without a description
  108. checkboxes.get(2).showTooltip();
  109. checkTooltipNotPresent();
  110. // check textfield's description
  111. cell_1_2 = table.getCell(1, 2);
  112. cell_1_2.showTooltip();
  113. checkTooltip("Row description item 1");
  114. // move somewhere without a description
  115. checkboxes.get(2).showTooltip();
  116. checkTooltipNotPresent();
  117. }
  118. @Test
  119. public void testPosition() throws Exception {
  120. openTestURL();
  121. TableElement table = $(TableElement.class).first();
  122. List<CheckBoxElement> checkboxes = $(CheckBoxElement.class).all();
  123. assertEquals(3, checkboxes.size());
  124. TestBenchElement cell_3_0 = table.getCell(3, 0);
  125. // move to the center of the cell
  126. new Actions(getDriver()).moveToElement(cell_3_0).perform();
  127. sleep(1000);
  128. // ensure the tooltip is present
  129. checkTooltip("Cell description item 3, Text");
  130. clearTooltip();
  131. // move outside the cell
  132. new Actions(getDriver()).moveToElement(checkboxes.get(2)).perform();
  133. // move to the corner of the cell
  134. moveToCorner(cell_3_0);
  135. sleep(1000);
  136. // ensure the tooltip is present
  137. checkTooltip("Cell description item 3, Text");
  138. clearTooltip();
  139. // uncheck cell tooltips
  140. checkboxes.get(1).findElement(By.tagName("input")).click();
  141. TestBenchElement cell_1_1 = table.getCell(1, 1);
  142. // move to the center of the cell
  143. new Actions(getDriver()).moveToElement(cell_1_1).perform();
  144. sleep(1000);
  145. // ensure the tooltip is present
  146. checkTooltip("Button 1 description");
  147. clearTooltip();
  148. // move to the corner of the element, outside of the button
  149. moveToCorner(cell_1_1);
  150. sleep(1000);
  151. // ensure the tooltip is present
  152. checkTooltip("Row description item 1");
  153. clearTooltip();
  154. // check cell tooltips
  155. checkboxes.get(1).findElement(By.tagName("input")).click();
  156. TestBenchElement cell_4_2 = table.getCell(4, 2);
  157. // move to the center of the cell
  158. new Actions(getDriver()).moveToElement(cell_4_2).perform();
  159. sleep(1000);
  160. // ensure the tooltip is present
  161. checkTooltip("Textfield's own description");
  162. clearTooltip();
  163. // move to the corner of the element, outside of the textfield
  164. moveToCorner(cell_4_2);
  165. sleep(1000);
  166. // ensure the tooltip is present
  167. checkTooltip("Cell description item 4, Generated component");
  168. clearTooltip();
  169. }
  170. private void moveToCorner(TestBenchElement cell) {
  171. new Actions(getDriver())
  172. .moveToElement(cell, getXOffset(cell, 0), getYOffset(cell, 0))
  173. .perform();
  174. }
  175. }