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.5KB

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