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.

ValoThemeUITest.java 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. package com.vaadin.tests.themes.valo;
  2. import org.junit.Test;
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebElement;
  5. import com.vaadin.testbench.elements.ButtonElement;
  6. import com.vaadin.testbench.elements.CheckBoxElement;
  7. import com.vaadin.testbench.elements.CssLayoutElement;
  8. import com.vaadin.testbench.elements.LabelElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. import com.vaadin.v7.testbench.elements.TreeElement;
  11. public class ValoThemeUITest extends MultiBrowserTest {
  12. @Test
  13. public void labels() throws Exception {
  14. openTestURL("test");
  15. open("Labels");
  16. compareScreen("labels");
  17. }
  18. @Test
  19. public void buttonsLinks() throws Exception {
  20. openTestURL("test");
  21. open("Buttons & Links", "Buttons");
  22. compareScreen("buttonsLinks_with_disabled");
  23. }
  24. @Test
  25. public void textFields() throws Exception {
  26. openTestURL("test");
  27. open("Text Fields <span class=\"valo-menu-badge\">123</span>",
  28. "Text Fields");
  29. compareScreen("textFields");
  30. }
  31. @Test
  32. public void common() throws Exception {
  33. openTestURL("test");
  34. open("Common UI Elements");
  35. compareScreen("common");
  36. }
  37. @Test
  38. public void datefields() throws Exception {
  39. openTestURL("test");
  40. open("Date Fields");
  41. // Note that this can look broken in IE9 because of some browser
  42. // rendering issue... The problem seems to be in the customized
  43. // horizontal layout in the test app
  44. compareScreen("datefields-localdate-with-range");
  45. }
  46. @Test
  47. public void comboboxes() throws Exception {
  48. openTestURL("test");
  49. open("Combo Boxes");
  50. compareScreen("comboboxes");
  51. }
  52. @Test
  53. public void selects() throws Exception {
  54. openTestURL("test");
  55. open("Selects");
  56. compareScreen("selects");
  57. }
  58. @Test
  59. public void checkboxes() throws Exception {
  60. openTestURL("test");
  61. open("Check Boxes & Option Groups", "Check Boxes");
  62. compareScreen("checkboxes_with_readonly");
  63. }
  64. @Test
  65. public void sliders() throws Exception {
  66. openTestURL("test");
  67. open("Sliders & Progress Bars", "Sliders");
  68. compareScreen("sliders");
  69. }
  70. @Test
  71. public void colorpickers() throws Exception {
  72. openTestURL("test");
  73. open("Color Pickers");
  74. compareScreen("colorpickers");
  75. }
  76. @Test
  77. public void menubars() throws Exception {
  78. openTestURL("test");
  79. open("Menu Bars");
  80. compareScreen("menubars");
  81. }
  82. @Test
  83. public void trees() throws Exception {
  84. openTestURL("test");
  85. open("Trees");
  86. selectTreeNodeByCaption("Quid securi");
  87. compareScreen("trees");
  88. }
  89. private void selectTreeNodeByCaption(String string) {
  90. WebElement e = $(TreeElement.class).first().findElement(
  91. By.xpath("//div[@class='v-tree-node-caption']//span[text()='"
  92. + string + "']"));
  93. e.click();
  94. }
  95. @Test
  96. public void tables() throws Exception {
  97. openTestURL("test");
  98. open("Tables");
  99. check("Components in Cells");
  100. compareScreen("tables");
  101. }
  102. @Test
  103. public void treeTables() throws Exception {
  104. openTestURL("test");
  105. open("Tables");
  106. check("Hierarchical");
  107. check("Footer");
  108. compareScreen("treetables");
  109. }
  110. @Test
  111. public void dragging() throws Exception {
  112. openTestURL("test");
  113. open("Drag and Drop", "Dragging Components");
  114. compareScreen("dragging");
  115. }
  116. @Test
  117. public void panels() throws Exception {
  118. openTestURL("test");
  119. open("Panels", "Panels & Layout panels");
  120. compareScreen("panels");
  121. }
  122. @Test
  123. public void splitpanels() throws Exception {
  124. openTestURL("test");
  125. open("Split Panels");
  126. compareScreen("splitpanels");
  127. }
  128. @Test
  129. public void tabs() throws Exception {
  130. openTestURL("test");
  131. open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
  132. compareScreen("tabs");
  133. }
  134. @Test
  135. public void tabsClosable() throws Exception {
  136. openTestURL("test");
  137. open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
  138. check("Closable");
  139. check("Disable tabs");
  140. check("Overflow");
  141. compareScreen("tabs-closable-disabled");
  142. }
  143. @Test
  144. public void tabsClosableUnframed() throws Exception {
  145. openTestURL("test");
  146. open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
  147. check("Closable");
  148. // Framed option is checked by default so we are actually unchecking
  149. check("Framed");
  150. check("Overflow");
  151. compareScreen("tabs-closable-unframed");
  152. }
  153. @Test
  154. public void tabsAlignRight() throws Exception {
  155. openTestURL("test");
  156. open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
  157. check("Right-aligned tabs");
  158. compareScreen("tabs-align-right");
  159. }
  160. /**
  161. * workaround for http://dev.vaadin.com/ticket/13763
  162. */
  163. private void check(String caption) {
  164. click($(CheckBoxElement.class).caption(caption).first());
  165. }
  166. @Test
  167. public void tabsAlignCenter() throws Exception {
  168. openTestURL("test");
  169. open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
  170. check("Centered tabs");
  171. compareScreen("tabs-align-center");
  172. }
  173. @Test
  174. public void tabsIconsOnTop() throws Exception {
  175. openTestURL("test");
  176. open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
  177. check("Icons on top");
  178. compareScreen("tabs-icons-on-top");
  179. }
  180. @Test
  181. public void tabsEqualCompactPadded() throws Exception {
  182. openTestURL("test");
  183. open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
  184. check("Equal-width tabs");
  185. check("Padded tabbar");
  186. check("Compact");
  187. compareScreen("tabs-equal-compact-padded");
  188. }
  189. @Test
  190. public void accordions() throws Exception {
  191. openTestURL("test");
  192. open("Accordions");
  193. compareScreen("accordions");
  194. }
  195. @Test
  196. public void popupviews() throws Exception {
  197. openTestURL("test");
  198. open("Popup Views");
  199. scrollTo(500, 0);
  200. compareScreen("popupviews");
  201. }
  202. @Test
  203. public void calendar() throws Exception {
  204. openTestURL("test");
  205. scrollTo(500, 0);
  206. open("Calendar");
  207. compareScreen("calendar");
  208. }
  209. @Test
  210. public void forms() throws Exception {
  211. openTestURL("test");
  212. scrollTo(500, 0);
  213. open("Forms");
  214. compareScreen("forms");
  215. }
  216. private void open(String link) {
  217. open(link, link);
  218. }
  219. private void open(String link, String caption) {
  220. open(link, caption, 10);
  221. }
  222. // FIXME: Remove this once click works properly on IE...
  223. private void open(String link, String caption, int tries) {
  224. if (tries <= 0) {
  225. throw new RuntimeException(
  226. "Tried many times but was not able to click the link...");
  227. }
  228. $(ButtonElement.class).caption(link).first().click();
  229. CssLayoutElement content = wrap(CssLayoutElement.class,
  230. findElement(By.className("valo-content")));
  231. LabelElement captionElem = content.$(LabelElement.class).first();
  232. if (!captionElem.getText().equals(caption)) {
  233. // IE ... why you fail clicks
  234. System.err.println("Extra click needed on '" + link + "' on remote "
  235. + getDesiredCapabilities() + " " + getRemoteControlName());
  236. open(link, caption, tries - 1);
  237. } else {
  238. // Done opening, scroll left panel to the top again for consistency
  239. scrollTo(0, 0);
  240. }
  241. }
  242. private void scrollTo(int top, int left) {
  243. CssLayoutElement testMenu = $(CssLayoutElement.class).id("testMenu");
  244. testBenchElement(testMenu).scroll(top);
  245. testBenchElement(testMenu).scrollLeft(left);
  246. }
  247. @Override
  248. protected boolean requireWindowFocusForIE() {
  249. return true;
  250. }
  251. @Override
  252. protected boolean usePersistentHoverForIE() {
  253. return false;
  254. }
  255. }