svn changeset:22016/svn branch:6.8tags/7.0.0.alpha1
@@ -0,0 +1,43 @@ | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |||
<html xmlns="http://www.w3.org/1999/xhtml"> | |||
<head> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |||
<style type="text/css">html, body {height:100%;margin:0;}</style><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/VAADIN/themes/reindeer/favicon.ico" /><link rel="icon" type="image/vnd.microsoft.icon" href="/VAADIN/themes/reindeer/favicon.ico" /><title>com.vaadin.tests.integration.EmbedSizeTest</title> | |||
</head> | |||
<body scroll="auto" class="v-generated-body"> | |||
<script type="text/javascript"> | |||
//<![CDATA[ | |||
if(!vaadin || !vaadin.vaadinConfigurations) { | |||
if(!vaadin) { var vaadin = {}} | |||
vaadin.vaadinConfigurations = {}; | |||
if (!vaadin.themesLoaded) { vaadin.themesLoaded = {}; } | |||
vaadin.debug = true; | |||
document.write('<iframe tabIndex="-1" id="__gwt_historyFrame" style="position:absolute;width:0;height:0;border:0;overflow:hidden;" src="javascript:false"></iframe>'); | |||
document.write("<script language='javascript' src='/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/com.vaadin.terminal.gwt.DefaultWidgetSet.nocache.js?1321018813162'><\/script>"); | |||
} | |||
vaadin.vaadinConfigurations["runcomvaadintestsintegrationEmbedSizeTest-225840176"] = {appUri:'/run/com.vaadin.tests.integration.EmbedSizeTest', themeUri:"/VAADIN/themes/reindeer", versionInfo : {vaadinVersion:"9.9.9.INTERNAL-DEBUG-BUILD",applicationVersion:"NONVERSIONED"},"comErrMsg": {"caption":"Communication problem","message" : "Take note of any unsaved data, and <u>click here<\/u> to continue.","url" : null},"authErrMsg": {"caption":"Authentication problem","message" : "Take note of any unsaved data, and <u>click here<\/u> to continue.","url" : null}}; | |||
//]]> | |||
</script> | |||
<script type="text/javascript"> | |||
//<![CDATA[ | |||
if(!vaadin.themesLoaded['reindeer']) { | |||
var stylesheet = document.createElement('link'); | |||
stylesheet.setAttribute('rel', 'stylesheet'); | |||
stylesheet.setAttribute('type', 'text/css'); | |||
stylesheet.setAttribute('href', '/VAADIN/themes/reindeer/styles.css'); | |||
document.getElementsByTagName('head')[0].appendChild(stylesheet); | |||
vaadin.themesLoaded['reindeer'] = true; | |||
} | |||
//]]> | |||
</script> | |||
<script type="text/javascript"> | |||
//<![CDATA[ | |||
setTimeout('if (typeof com_vaadin_terminal_gwt_DefaultWidgetSet == "undefined") {alert("Failed to load the widgetset: /VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/com.vaadin.terminal.gwt.DefaultWidgetSet.nocache.js?1321018813162")};',15000); | |||
//]]> | |||
</script> | |||
<div style="width: 80%; border: 1px solid black"> | |||
<h1>Test page for resize events with embedded applications</h1> | |||
<div id="runcomvaadintestsintegrationEmbedSizeTest-225840176" class="v-app v-theme-reindeer v-app-EmbedSizeTest" ><div class="v-app-loading"></div></div> | |||
<noscript>You have to enable javascript in your browser to use an application built with Vaadin.</noscript></body> | |||
</div> | |||
</html> |
@@ -14,6 +14,7 @@ import com.google.gwt.core.client.Scheduler; | |||
import com.google.gwt.core.client.Scheduler.ScheduledCommand; | |||
import com.google.gwt.dom.client.DivElement; | |||
import com.google.gwt.dom.client.Document; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.Style; | |||
import com.google.gwt.dom.client.Style.Display; | |||
import com.google.gwt.event.dom.client.DomEvent.Type; | |||
@@ -23,7 +24,6 @@ import com.google.gwt.event.shared.EventHandler; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.google.gwt.user.client.Command; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Element; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.Timer; | |||
import com.google.gwt.user.client.Window; | |||
@@ -109,7 +109,8 @@ public class VView extends SimplePanel implements Container, ResizeHandler, | |||
private VLazyExecutor delayedResizeExecutor = new VLazyExecutor(200, | |||
new ScheduledCommand() { | |||
public void execute() { | |||
windowSizeMaybeChanged(getOffsetWidth(), getOffsetHeight()); | |||
windowSizeMaybeChanged(Window.getClientWidth(), | |||
Window.getClientHeight()); | |||
} | |||
}); | |||
@@ -576,25 +577,58 @@ public class VView extends SimplePanel implements Container, ResizeHandler, | |||
return getElement().getOffsetWidth() - getExcessWidth(); | |||
} | |||
// If not running standalone, we might be inside elements that don't | |||
// shrink with the browser window if our own components have | |||
// If not running standalone, there might be multiple Vaadin apps | |||
// that won't shrink with the browser window as the components have | |||
// calculated widths (#3125) | |||
Element layoutElement = ((Widget) layout).getElement(); | |||
Style layoutStyle = layoutElement.getStyle(); | |||
// Set display:none to the entire application to get a width not | |||
// influenced by the contents | |||
String originalDisplay = layoutStyle.getDisplay(); | |||
layoutStyle.setDisplay(Display.NONE); | |||
// Find all Vaadin applications on the page | |||
ArrayList<String> vaadinApps = new ArrayList<String>(); | |||
loadAppIdListFromDOM(vaadinApps); | |||
// Store original styles here so they can be restored | |||
ArrayList<String> originalDisplays = new ArrayList<String>( | |||
vaadinApps.size()); | |||
String ownAppId = connection.getConfiguration().getRootPanelId(); | |||
// Set display: none for all Vaadin apps | |||
for (int i = 0; i < vaadinApps.size(); i++) { | |||
String appId = vaadinApps.get(i); | |||
Element targetElement; | |||
if (appId.equals(ownAppId)) { | |||
// Only hide the contents of current application | |||
targetElement = ((Widget) layout).getElement(); | |||
} else { | |||
// Hide everything for other applications | |||
targetElement = Document.get().getElementById(appId); | |||
} | |||
Style layoutStyle = targetElement.getStyle(); | |||
originalDisplays.add(i, layoutStyle.getDisplay()); | |||
layoutStyle.setDisplay(Display.NONE); | |||
} | |||
int w = getElement().getOffsetWidth() - getExcessWidth(); | |||
// Then restore the old display style before returning | |||
if (originalDisplay.length() == 0) { | |||
layoutStyle.clearDisplay(); | |||
} else { | |||
layoutStyle.setDisplay(Display.valueOf(originalDisplay)); | |||
for (int i = 0; i < vaadinApps.size(); i++) { | |||
String appId = vaadinApps.get(i); | |||
Element targetElement; | |||
if (appId.equals(ownAppId)) { | |||
targetElement = ((Widget) layout).getElement(); | |||
} else { | |||
targetElement = Document.get().getElementById(appId); | |||
} | |||
Style layoutStyle = targetElement.getStyle(); | |||
String originalDisplay = originalDisplays.get(i); | |||
if (originalDisplay.length() == 0) { | |||
layoutStyle.clearDisplay(); | |||
} else { | |||
layoutStyle.setProperty("display", originalDisplay); | |||
} | |||
} | |||
return w; | |||
} | |||
@@ -611,6 +645,14 @@ public class VView extends SimplePanel implements Container, ResizeHandler, | |||
} | |||
}; | |||
private native static void loadAppIdListFromDOM(ArrayList<String> list) | |||
/*-{ | |||
var j; | |||
for(j in $wnd.vaadin.vaadinConfigurations) { | |||
list.@java.util.Collection::add(Ljava/lang/Object;)(j); | |||
} | |||
}-*/; | |||
public RenderSpace getAllocatedSpace(Widget child) { | |||
return myRenderSpace; | |||
} |
@@ -9,7 +9,7 @@ | |||
<fail unless="test.integration.antfile" message="test.integration.antfile must be set for integration tests to run"/> | |||
<!-- Test with these browsers --> | |||
<property name="test_browsers" value="winxp-firefox36" /> | |||
<property name="test_browsers" value="winxp-firefox-latest" /> | |||
<!-- Path to key file. Default value --> | |||
<property name="sshkey.file" value="id_dsa" /> | |||
@@ -231,6 +231,7 @@ | |||
<fileset dir="integration-testscripts" id="html-test-files" includes="GateIn-3/integration-test-GateIn-3.1.0-portlet2.html" /> | |||
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" /> | |||
<antcall target="run-generic-integration-test"> | |||
<param name="test_browsers" value="winxp-firefox36" /> | |||
<param name="target-server" value="gatein3" /> | |||
</antcall> | |||
</target> | |||
@@ -239,6 +240,7 @@ | |||
<fileset dir="integration-testscripts" id="html-test-files" includes="eXo-3/integration-test-eXo-3.0.3-portlet2.html" /> | |||
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" /> | |||
<antcall target="run-generic-integration-test"> | |||
<param name="test_browsers" value="winxp-firefox36" /> | |||
<param name="target-server" value="exo3" /> | |||
</antcall> | |||
</target> | |||
@@ -352,6 +354,7 @@ | |||
</fileset> | |||
</scp> | |||
<!-- trycatch probably not needed any more as it just fails with the original message and doesn't do anything in the finally block --> | |||
<trycatch property="error_message"> | |||
<try> | |||
<!-- timeout in one hour (remote end should timeout in 55 minutes) --> | |||
@@ -394,18 +397,17 @@ | |||
</antcall> | |||
</then> | |||
</if> | |||
</try> | |||
<catch> | |||
<fail message="${error_message}" /> | |||
</catch> | |||
<finally> | |||
<!-- timeout in five minutes --> | |||
<sshexec host="${target-host}" outputproperty="stop-output" timeout="300000" username="${user}" keyfile="${sshkey.file}" trust="yes" command="ant -f deploy.xml shutdown-and-cleanup" failonerror="false" /> | |||
<antcall target="echo-prefix"> | |||
<param name="prefix" value="${target-server}: " /> | |||
<param name="message" value="${stop-output}" /> | |||
</antcall> | |||
</finally> | |||
</try> | |||
<catch> | |||
<fail message="${error_message}" /> | |||
</catch> | |||
</trycatch> | |||
</target> | |||
@@ -0,0 +1,55 @@ | |||
package com.vaadin.tests.integration; | |||
import com.vaadin.tests.components.TestBase; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Button.ClickEvent; | |||
import com.vaadin.ui.CheckBox; | |||
import com.vaadin.ui.Window; | |||
import com.vaadin.ui.Window.ResizeEvent; | |||
public class EmbedSizeTest extends TestBase { | |||
private Log log = new Log(10); | |||
@Override | |||
protected void setup() { | |||
Window mainWindow = getMainWindow(); | |||
mainWindow.setSizeUndefined(); | |||
mainWindow.getContent().setSizeUndefined(); | |||
mainWindow.setImmediate(true); | |||
CheckBox lazyCheckBox = new CheckBox("Lazy resize", | |||
new Button.ClickListener() { | |||
public void buttonClick(ClickEvent event) { | |||
boolean resizeLazy = Boolean.TRUE == event.getButton() | |||
.getValue(); | |||
getMainWindow().setResizeLazy(resizeLazy); | |||
log.log("Resize lazy: " + resizeLazy); | |||
} | |||
}); | |||
lazyCheckBox.setValue(Boolean.FALSE); | |||
lazyCheckBox.setImmediate(true); | |||
addComponent(lazyCheckBox); | |||
addComponent(log); | |||
mainWindow.addListener(new Window.ResizeListener() { | |||
public void windowResized(ResizeEvent e) { | |||
Window window = e.getWindow(); | |||
log.log("Resize event: " + window.getWidth() + " x " | |||
+ window.getHeight()); | |||
} | |||
}); | |||
} | |||
@Override | |||
protected String getDescription() { | |||
return "Resizing the browser window should send consistent resize events to the server even when the application is embedded"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return Integer.valueOf(7923); | |||
} | |||
} |