/*
 * Copyright 2000-2013 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.orderedlayout;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;

import com.vaadin.tests.tb3.MultiBrowserTest;

/**
 * Tests hovering over caption in nested layout
 */
public class NestedLayoutCaptionHoverTest extends MultiBrowserTest {

    @Test
    public void testTooltipInNestedLayout() throws Exception {
        openTestURL();

        WebElement caption = getDriver().findElement(
                By.className("v-captiontext"));

        assertEquals("inner layout", caption.getText());

        // Hover over the caption
        Coordinates coords = ((Locatable) caption).getCoordinates();
        ((HasInputDevices) getDriver()).getMouse().mouseMove(coords);
        sleep(1000);

        // Verify that there's no error notification
        WebElement error = vaadinElement("Root/VNotification[0]");
        assertNull("No error should be found", error);
    }

}

@@ -726,19 +726,56 @@
 t.assert
-Nul
+True;%0Aimport static org.junit.Assert.fai
 l;%0A%0Aimpo
@@ -824,16 +824,67 @@
 ium.By;%0A
+import org.openqa.selenium.NoSuchElementException;%0A
 import o
@@ -1719,180 +1719,396 @@
     
-// Verify that there's no error notification%0A        WebElement error = vaadinElement(%22Root/VNotification%5B0%5D%22);%0A        assertNull(%22No error should be found%22, error);%0A    %7D%0A
+String selector = %22Root/VNotification%5B0%5D%22;%0A        try %7B%0A            // Verify that there's no error notification%0A            vaadinElement(selector);%0A            fail(%22No error notification should be found%22);%0A        %7D catch (NoSuchElementException e) %7B%0A            // Exception caught. Verify it's the right one.%0A            assertTrue(e.getMessage().contains(selector));%0A        %7D%0A    %7D
 %0A%7D%0A

Fix NestedLayoutCaptionHoverTest to work with TB 3.1.3