Selaa lähdekoodia

Fixed tooltips for sub-windows (#19073)

The subwindows tooltip is now also shown in header and footer of the
subwindow. Added also tests for the feature.

Change-Id: I933dad9e8530ce20b930fe22caf9e79a3ad3e3d2
tags/7.7.0.alpha3
Pontus Boström 8 vuotta sitten
vanhempi
commit
dfcc4949ca

+ 19
- 6
client/src/main/java/com/vaadin/client/ui/VWindow.java Näytä tiedosto

@@ -997,21 +997,35 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
event.preventDefault();

headerDragPending = event;
} else if ((type == Event.ONMOUSEMOVE || type == Event.ONTOUCHMOVE)
bubble = false;
} else if (type == Event.ONMOUSEMOVE
&& headerDragPending != null) {
// ie won't work unless this is set here
dragging = true;
onDragEvent(headerDragPending);
onDragEvent(event);
headerDragPending = null;
bubble = false;
} else if (type != Event.ONMOUSEMOVE) {
// The event can propagate to the parent in case it is a
// mouse move event. This is needed for tooltips to work in
// header and footer, see Ticket #19073
headerDragPending = null;
bubble = false;
} else {
headerDragPending = null;
}
bubble = false;
}
if (type == Event.ONCLICK) {
activateOnClick();
}
} else if (footer.isOrHasChild(target) && !dragging) {
onDragEvent(event);
if (type != Event.ONMOUSEMOVE) {
// This is needed for tooltips to work in header and footer, see
// Ticket #19073
bubble = false;
}
} else if (dragging || !contents.isOrHasChild(target)) {
onDragEvent(event);
bubble = false;
@@ -1031,11 +1045,10 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,

if (!bubble) {
event.stopPropagation();
} else {
// Super.onBrowserEvent takes care of Handlers added by the
// ClickEventHandler
super.onBrowserEvent(event);
}
// Super.onBrowserEvent takes care of Handlers added by the
// ClickEventHandler
super.onBrowserEvent(event);
}

private void activateOnClick() {

+ 46
- 0
uitest/src/main/java/com/vaadin/tests/components/window/ToolTipInWindow.java Näytä tiedosto

@@ -0,0 +1,46 @@
/*
* Copyright 2000-2015 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.window;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;

/**
* Test to demonstrate that tooltips are shown for both Window header and
* content
*
* @author Vaadin Ltd
*/
public class ToolTipInWindow extends AbstractTestUI {

Window window;

@Override
protected void setup(VaadinRequest request) {

window = new Window("Caption", new Label("A label content"));
window.setPositionX(300);
window.setPositionY(200);
window.setWidth("200px");
window.setHeight("200px");
window.setDescription("Tooltip");
addWindow(window);

}

}

+ 77
- 0
uitest/src/test/java/com/vaadin/tests/components/window/ToolTipInWindowTest.java Näytä tiedosto

@@ -0,0 +1,77 @@
/*
* Copyright 2000-2015 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.window;

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

import java.util.List;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.vaadin.tests.tb3.MultiBrowserTest;

public class ToolTipInWindowTest extends MultiBrowserTest {

@Test
public void testToolTipInHeader() throws Exception {

openTestURL();

WebElement header = driver.findElement(By
.className("v-window-outerheader"));
new Actions(driver).moveToElement(
driver.findElement(By.className("v-ui")), 0, 0).perform();
sleep(500);
new Actions(driver).moveToElement(header).perform();
sleep(1100);

WebElement ttip = findElement(By.className("v-tooltip"));
assertNotNull(ttip);
assertEquals("Tooltip", ttip.getText());

}

@Test
public void testToolTipInContent() throws Exception {

openTestURL();

WebElement header = driver.findElement(By
.className("v-window-contents"));
new Actions(driver).moveToElement(
driver.findElement(By.className("v-ui")), 0, 300).perform();
sleep(500);
new Actions(driver).moveToElement(header).perform();
sleep(1000);

WebElement ttip = findElement(By.className("v-tooltip"));
assertNotNull(ttip);
assertEquals("Tooltip", ttip.getText());

}

@Override
public List<DesiredCapabilities> getBrowsersToTest() {
// Test with the same browsers as in the other tooltip tests
return getBrowsersExcludingIE();
}

}

Loading…
Peruuta
Tallenna