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.

PopupViewResizeWhileOpenTest.java 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.components.popupview;
  17. import static org.hamcrest.MatcherAssert.assertThat;
  18. import static org.hamcrest.Matchers.greaterThan;
  19. import static org.hamcrest.Matchers.is;
  20. import static org.hamcrest.Matchers.lessThan;
  21. import java.util.List;
  22. import org.junit.Test;
  23. import org.openqa.selenium.By;
  24. import org.openqa.selenium.Dimension;
  25. import org.openqa.selenium.WebElement;
  26. import org.openqa.selenium.remote.DesiredCapabilities;
  27. import com.vaadin.testbench.elements.ButtonElement;
  28. import com.vaadin.testbench.elements.PopupViewElement;
  29. import com.vaadin.testbench.elements.VerticalLayoutElement;
  30. import com.vaadin.testbench.parallel.Browser;
  31. import com.vaadin.tests.tb3.MultiBrowserTest;
  32. /**
  33. * Resizing PopupView's popup component while it is visible should also resize
  34. * the drop shadow of the overlay.
  35. *
  36. * @author Vaadin Ltd
  37. */
  38. public class PopupViewResizeWhileOpenTest extends MultiBrowserTest {
  39. @Test
  40. public void testCustomPopupSizeAfterResize() {
  41. openTestURL();
  42. // Open PopupView
  43. $(PopupViewElement.class).first().click();
  44. // Sanity check
  45. assertShadowSize();
  46. // Resize
  47. $(ButtonElement.class).first().click();
  48. assertShadowSize();
  49. }
  50. private void assertShadowSize() {
  51. Dimension shadowSize = getPopupShadow().getSize();
  52. Dimension layoutSize = $(VerticalLayoutElement.class).id("content-vl")
  53. .getSize();
  54. assertThat(shadowSize.height, is(greaterThan(layoutSize.height)));
  55. assertThat(shadowSize.height, is(lessThan(layoutSize.height + 10)));
  56. assertThat(shadowSize.width, is(greaterThan(layoutSize.width)));
  57. assertThat(shadowSize.width, is(lessThan(layoutSize.width + 10)));
  58. }
  59. private WebElement getPopupShadow() {
  60. // Shadows with index 0: tooltip, index 1: popup
  61. return findElements(By.className("v-shadow")).get(1);
  62. }
  63. @Override
  64. public List<DesiredCapabilities> getBrowsersToTest() {
  65. return getBrowserCapabilities(Browser.IE8);
  66. }
  67. }