/*
 * 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.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 = findElement(By.className("v-shadow")).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)));
    }

    @Override
    public List<DesiredCapabilities> getBrowsersToTest() {
        return Collections.singletonList(Browser.IE8.getDesiredCapabilities());
    }
}

@@ -975,16 +975,55 @@
 ension;%0A
+import org.openqa.selenium.WebElement;%0A
 import o
@@ -1892,44 +1892,23 @@
 e = 
-findElement(By.className(%22v-s
+getPopupS
 hadow
-%22)
+(
 ).ge
@@ -2327,24 +2327,191 @@
 )));%0A    %7D%0A%0A
+    private WebElement getPopupShadow() %7B%0A        //Shadows with index 0: tooltip, index 1: popup%0A        return findElements(By.className(%22v-shadow%22)).get(1);%0A    %7D%0A%0A
     @Overrid

Fix PopupViewResizeWhileOpenTest to use correct shadow.