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.

ResponsiveUITest.java 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package com.vaadin.tests.extensions;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.interactions.Actions;
  7. import org.openqa.selenium.support.ui.ExpectedConditions;
  8. import com.vaadin.testbench.By;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public class ResponsiveUITest extends MultiBrowserTest {
  11. @Before
  12. public void setUp() throws Exception {
  13. // We need this in order to ensure that the initial width-range is
  14. // 401px-600px
  15. testBench().resizeViewPortTo(1024, 768);
  16. }
  17. // JQuery style selector
  18. private WebElement $(String cssSelector) {
  19. return getDriver().findElement(By.cssSelector(cssSelector));
  20. }
  21. @Test
  22. public void testResizingSplitPanelReflowsLayout() throws Exception {
  23. openTestURL();
  24. // IE sometimes has trouble waiting long enough.
  25. waitUntil(ExpectedConditions.presenceOfElementLocated(
  26. By.cssSelector(".v-csslayout-grid.first")), 30);
  27. assertEquals("401px-600px",
  28. $(".v-csslayout-grid.first").getAttribute("width-range"));
  29. assertEquals("501px-",
  30. $(".v-csslayout-grid.second").getAttribute("width-range"));
  31. moveSplitter(200);
  32. assertEquals("601-800",
  33. $(".v-csslayout-grid.first").getAttribute("width-range"));
  34. assertEquals("501px-",
  35. $(".v-csslayout-grid.second").getAttribute("width-range"));
  36. moveSplitter(-350);
  37. assertEquals("201px-400px",
  38. $(".v-csslayout-grid.first").getAttribute("width-range"));
  39. assertEquals("301px-400px",
  40. $(".v-csslayout-grid.second").getAttribute("width-range"));
  41. compareScreen("responsive");
  42. moveSplitter(-200);
  43. assertEquals("-200px",
  44. $(".v-csslayout-grid.first").getAttribute("width-range"));
  45. moveSplitter(-100);
  46. assertEquals("0-100px",
  47. $(".v-csslayout-grid.second").getAttribute("width-range"));
  48. }
  49. private void moveSplitter(int xOffset) {
  50. new Actions(getDriver()).clickAndHold($(".v-splitpanel-hsplitter"))
  51. .moveByOffset(xOffset, 0).release().build().perform();
  52. }
  53. @Test
  54. public void testResizingWindowReflowsLayout() throws Exception {
  55. openTestURL();
  56. waitUntilLoadingIndicatorNotVisible();
  57. assertEquals("401px-600px",
  58. $(".v-csslayout-grid.first").getAttribute("width-range"));
  59. assertEquals("501px-",
  60. $(".v-csslayout-grid.second").getAttribute("width-range"));
  61. testBench().resizeViewPortTo(1224, 768);
  62. waitUntilLoadingIndicatorNotVisible();
  63. assertEquals("601-800",
  64. $(".v-csslayout-grid.first").getAttribute("width-range"));
  65. assertEquals("501px-",
  66. $(".v-csslayout-grid.second").getAttribute("width-range"));
  67. testBench().resizeViewPortTo(674, 768);
  68. waitUntilLoadingIndicatorNotVisible();
  69. assertEquals("201px-400px",
  70. $(".v-csslayout-grid.first").getAttribute("width-range"));
  71. assertEquals("301px-400px",
  72. $(".v-csslayout-grid.second").getAttribute("width-range"));
  73. }
  74. }