--- /dev/null
+<!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>
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;
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;
private VLazyExecutor delayedResizeExecutor = new VLazyExecutor(200,
new ScheduledCommand() {
public void execute() {
- windowSizeMaybeChanged(getOffsetWidth(), getOffsetHeight());
+ windowSizeMaybeChanged(Window.getClientWidth(),
+ Window.getClientHeight());
}
});
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;
}
}
};
+ 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;
}
<fail unless="test.integration.antfile" message="test.integration.antfile must be set for integration tests to run"/>\r
\r
<!-- Test with these browsers -->\r
- <property name="test_browsers" value="winxp-firefox36" />\r
+ <property name="test_browsers" value="winxp-firefox-latest" />\r
\r
<!-- Path to key file. Default value -->\r
<property name="sshkey.file" value="id_dsa" />\r
<fileset dir="integration-testscripts" id="html-test-files" includes="GateIn-3/integration-test-GateIn-3.1.0-portlet2.html" />\r
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />\r
<antcall target="run-generic-integration-test">\r
+ <param name="test_browsers" value="winxp-firefox36" />\r
<param name="target-server" value="gatein3" />\r
</antcall>\r
</target>\r
<fileset dir="integration-testscripts" id="html-test-files" includes="eXo-3/integration-test-eXo-3.0.3-portlet2.html" />\r
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />\r
<antcall target="run-generic-integration-test">\r
+ <param name="test_browsers" value="winxp-firefox36" />\r
<param name="target-server" value="exo3" />\r
</antcall>\r
</target>\r
</fileset>\r
</scp>\r
\r
+ <!-- trycatch probably not needed any more as it just fails with the original message and doesn't do anything in the finally block -->\r
<trycatch property="error_message">\r
<try>\r
<!-- timeout in one hour (remote end should timeout in 55 minutes) -->\r
</antcall>\r
</then>\r
</if>\r
- </try>\r
- <catch>\r
- <fail message="${error_message}" />\r
- </catch>\r
- <finally>\r
+ \r
<!-- timeout in five minutes -->\r
<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" />\r
<antcall target="echo-prefix">\r
<param name="prefix" value="${target-server}: " />\r
<param name="message" value="${stop-output}" />\r
</antcall>\r
- </finally>\r
+ </try>\r
+ <catch>\r
+ <fail message="${error_message}" />\r
+ </catch>\r
</trycatch>\r
</target>\r
\r
--- /dev/null
+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);
+ }
+
+}