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.

SetThemeAndResponsiveLayoutTest.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2000-2014 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.extensions;
  17. import static org.junit.Assert.assertEquals;
  18. import java.util.List;
  19. import org.junit.Before;
  20. import org.junit.Test;
  21. import org.openqa.selenium.remote.DesiredCapabilities;
  22. import org.openqa.selenium.support.ui.ExpectedConditions;
  23. import org.openqa.selenium.support.ui.WebDriverWait;
  24. import com.vaadin.testbench.By;
  25. import com.vaadin.testbench.elements.ButtonElement;
  26. import com.vaadin.testbench.elements.CssLayoutElement;
  27. import com.vaadin.tests.tb3.MultiBrowserTest;
  28. public class SetThemeAndResponsiveLayoutTest extends MultiBrowserTest {
  29. @Before
  30. public void setUp() throws Exception {
  31. // We need this in order to ensure that the initial width-range is
  32. // width: 600px- and height: 500px-
  33. testBench().resizeViewPortTo(1024, 768);
  34. }
  35. @Override
  36. public List<DesiredCapabilities> getBrowsersToTest() {
  37. // Seems like stylesheet onload is not fired on PhantomJS
  38. // https://github.com/ariya/phantomjs/issues/12332
  39. return getBrowsersExcludingPhantomJS();
  40. }
  41. @Test
  42. public void testWidthAndHeightRanges() throws Exception {
  43. openTestURL();
  44. // IE sometimes has trouble waiting long enough.
  45. new WebDriverWait(getDriver(), 30).until(ExpectedConditions
  46. .presenceOfElementLocated(By
  47. .cssSelector(".v-csslayout-width-and-height")));
  48. // set the theme programmatically
  49. $(ButtonElement.class).caption("Set theme").first().click();
  50. new WebDriverWait(getDriver(), 30).until(ExpectedConditions
  51. .presenceOfElementLocated(By.xpath("//div[@width-range]")));
  52. // Verify both width-range and height-range.
  53. assertEquals("600px-",
  54. $(CssLayoutElement.class).first().getAttribute("width-range"));
  55. assertEquals("500px-",
  56. $(CssLayoutElement.class).first().getAttribute("height-range"));
  57. // Resize
  58. testBench().resizeViewPortTo(550, 450);
  59. // Verify updated width-range and height-range.
  60. assertEquals("0-599px",
  61. $(CssLayoutElement.class).first().getAttribute("width-range"));
  62. assertEquals("0-499px",
  63. $(CssLayoutElement.class).first().getAttribute("height-range"));
  64. }
  65. }