/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.popupview;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.PopupViewElement;
import com.vaadin.testbench.elements.VerticalLayoutElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Resizing PopupView's popup component while it is visible should also resize
* the drop shadow of the overlay.
*
* @author Vaadin Ltd
*/
public class PopupViewResizeWhileOpenTest extends MultiBrowserTest {
@Test
public void testCustomPopupSizeAfterResize() {
openTestURL();
// Open PopupView
$(PopupViewElement.class).first().click();
// Sanity check
assertShadowSize();
// Resize
$(ButtonElement.class).first().click();
assertShadowSize();
}
private void assertShadowSize() {
Dimension shadowSize = getPopupShadow().getSize();
Dimension layoutSize = $(VerticalLayoutElement.class).id("content-vl")
.getSize();
assertThat(shadowSize.height, is(greaterThan(layoutSize.height)));
assertThat(shadowSize.height, is(lessThan(layoutSize.height + 10)));
assertThat(shadowSize.width, is(greaterThan(layoutSize.width)));
assertThat(shadowSize.width, is(lessThan(layoutSize.width + 10)));
}
private WebElement getPopupShadow() {
//Shadows with index 0: tooltip, index 1: popup
return findElements(By.className("v-shadow")).get(1);
}
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
return Collections.singletonList(Browser.IE8.getDesiredCapabilities());
}
}