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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.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. waitUntil(ExpectedConditions.presenceOfElementLocated(
  46. By.cssSelector(".v-csslayout-width-and-height")), 30);
  47. // set the theme programmatically
  48. $(ButtonElement.class).caption("Set theme").first().click();
  49. waitUntil(ExpectedConditions
  50. .presenceOfElementLocated(By.xpath("//div[@width-range]")), 30);
  51. // Verify both width-range and height-range.
  52. assertEquals("600px-",
  53. $(CssLayoutElement.class).first().getAttribute("width-range"));
  54. assertEquals("500px-",
  55. $(CssLayoutElement.class).first().getAttribute("height-range"));
  56. // Resize
  57. testBench().resizeViewPortTo(550, 450);
  58. // Verify updated width-range and height-range.
  59. assertEquals("0-599px",
  60. $(CssLayoutElement.class).first().getAttribute("width-range"));
  61. assertEquals("0-499px",
  62. $(CssLayoutElement.class).first().getAttribute("height-range"));
  63. }
  64. }