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 9.2KB

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