]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged some changes from 6.7 to 6.8
authorHenri Sara <henri.sara@itmill.com>
Wed, 16 Nov 2011 10:39:05 +0000 (10:39 +0000)
committerHenri Sara <henri.sara@itmill.com>
Wed, 16 Nov 2011 10:39:05 +0000 (10:39 +0000)
svn changeset:22016/svn branch:6.8

WebContent/statictestfiles/EmbedSizeHostPage.html [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/VView.java
tests/integration_tests.xml
tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java [new file with mode: 0644]

diff --git a/WebContent/statictestfiles/EmbedSizeHostPage.html b/WebContent/statictestfiles/EmbedSizeHostPage.html
new file mode 100644 (file)
index 0000000..06dfd5d
--- /dev/null
@@ -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&#46;vaadin&#46;tests&#46;integration&#46;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>
index af87610944c7ba83ee54f8033ded7ed2d7c445d4..cd9f0c903c37976e25a8e160b5c940c9df1f110c 100644 (file)
@@ -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;
     }
index 834c5fe6082d9288a273cd1b4096b163a3eddb7e..46b6653a23ea839e282534ec0a110f9f24773ea8 100644 (file)
@@ -9,7 +9,7 @@
        <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
diff --git a/tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java b/tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java
new file mode 100644 (file)
index 0000000..479af4a
--- /dev/null
@@ -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);
+    }
+
+}