summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java109
-rw-r--r--uitest/src/com/vaadin/tests/components/textarea/TextDisappearsOnBlur.java29
-rw-r--r--uitest/src/com/vaadin/tests/components/textfield/TextChangeListenerLosesFocus.java69
-rw-r--r--uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.html27
-rw-r--r--uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.java85
-rw-r--r--uitest/test.xml1
-rw-r--r--uitest/vaadin-server.xml3
7 files changed, 322 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
index ad372bd5bc..070cd2834d 100644
--- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
+++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
@@ -22,9 +22,20 @@ import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
@@ -163,6 +174,25 @@ public class DevelopmentServerLauncher {
webappcontext.setWar(serverArgs.get("webroot"));
server.setHandler(webappcontext);
+ // --slowdown=/run/APP/PUBLISHED/*,/other/path/asd.jpg
+ // slows down specified paths
+ if (serverArgs.containsKey("slowdown")) {
+ String[] paths = serverArgs.get("slowdown").split(",");
+ for (String p : paths) {
+ System.out.println("Slowing down: " + p);
+ webappcontext.addFilter(SlowFilter.class, p, 1);
+ }
+ }
+ // --cache=/run/APP/PUBLISHED/*,/other/path/asd.jpg
+ // caches specified paths
+ if (serverArgs.containsKey("cache")) {
+ String[] paths = serverArgs.get("cache").split(",");
+ for (String p : paths) {
+ System.out.println("Enabling cache for: " + p);
+ webappcontext.addFilter(CacheFilter.class, p, 1);
+ }
+ }
+
try {
server.start();
@@ -243,4 +273,83 @@ public class DevelopmentServerLauncher {
return map;
}
+ /**
+ * Sleeps for 2-5 seconds when serving resources that matches given
+ * pathSpec. --slowdown=/run/APP/PUBLISHED/*,/other/path/asd.jpg
+ */
+ public static class SlowFilter implements Filter {
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+
+ String path = ((HttpServletRequest) request).getPathInfo();
+ long delay = Math.round(Math.random() * 3000) + 2000;
+ System.out.println("Delaying " + path + " for " + delay);
+
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ System.out.println("Delay interrupted for " + path);
+ } finally {
+ System.out.println("Resuming " + path);
+ }
+
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+ }
+
+ }
+
+ /**
+ * Adds "Expires" and "Cache-control" headers when serving resources that
+ * match given pathSpec, in order to cache resource for CACHE_MINUTES.
+ * --cache=/run/APP/PUBLISHED/*,/other/path/asd.jpg
+ */
+ public static class CacheFilter implements Filter {
+
+ private static final int CACHE_MINUTES = 1;
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+
+ String path = ((HttpServletRequest) request).getPathInfo();
+ System.out.println("Caching " + path + " for " + CACHE_MINUTES
+ + " minutes");
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.MINUTE, CACHE_MINUTES);
+
+ String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z")
+ .format(calendar.getTime());
+
+ ((HttpServletResponse) response).setHeader("Expires", expires);
+ ((HttpServletResponse) response).setHeader("Cache-Control",
+ "max-age=" + (CACHE_MINUTES * 60));
+
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+ }
+
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/components/textarea/TextDisappearsOnBlur.java b/uitest/src/com/vaadin/tests/components/textarea/TextDisappearsOnBlur.java
new file mode 100644
index 0000000000..2d2cf29e9e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/textarea/TextDisappearsOnBlur.java
@@ -0,0 +1,29 @@
+package com.vaadin.tests.components.textarea;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.TextArea;
+
+public class TextDisappearsOnBlur extends TestBase {
+
+ @Override
+ protected void setup() {
+ TextArea ta = new TextArea();
+ addComponent(ta);
+
+ // All three are required for the bug to manifest
+ ta.setMaxLength(50);
+ ta.setImmediate(true);
+ ta.setRequired(true);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Text disappears from TextArea in IE 6-8 when focus changes";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11396;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/textfield/TextChangeListenerLosesFocus.java b/uitest/src/com/vaadin/tests/components/textfield/TextChangeListenerLosesFocus.java
new file mode 100644
index 0000000000..25ca46333a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/textfield/TextChangeListenerLosesFocus.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2012 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.textfield;
+
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+
+public class TextChangeListenerLosesFocus extends TestBase {
+
+ private final TextChangeListener listener = new TextChangeListener() {
+ public void textChange(TextChangeEvent event) {
+ final String value = event.getText();
+ if (value.length() > 2) {
+ ((Field) event.getComponent())
+ .setValue("Updated by TextChangeListener");
+ }
+ }
+ };
+
+ @Override
+ protected void setup() {
+ TestUtils.injectCSS(getMainWindow(),
+ ".v-textfield-focus, .v-textarea-focus { "
+ + " background: #E8F0FF !important }");
+
+ AbstractTextField field = new TextField();
+ field.setDebugId("test-textfield");
+ field.setInputPrompt("Enter at least 3 characters");
+ field.addListener(listener);
+ addComponent(field);
+
+ field = new TextArea();
+ field.setDebugId("test-textarea");
+ field.setInputPrompt("Enter at least 3 characters");
+ field.addListener(listener);
+ addComponent(field);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Updating a focused TextField overwrites the focus stylename";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11623;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.html b/uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.html
new file mode 100644
index 0000000000..3132bdd16d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.html
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8070/" />
+<title>MarginWithExpandRatio</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">MarginWithExpandRatio</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/MarginWithExpandRatio?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>no-overflow</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.java b/uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.java
new file mode 100644
index 0000000000..f6ee26e86f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/layouts/MarginWithExpandRatio.java
@@ -0,0 +1,85 @@
+/*
+ * 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.layouts;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+
+public class MarginWithExpandRatio extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TestUtils.injectCSS(this,
+ ".hugemargin { margin: 10px 20px !important; }");
+
+ HorizontalLayout hl = new HorizontalLayout();
+ addLayoutTest(hl);
+ hl.setExpandRatio(hl.getComponent(0), 1.0f);
+ hl.setExpandRatio(hl.getComponent(2), 0.5f);
+ VerticalLayout vl = new VerticalLayout();
+ addLayoutTest(vl);
+ vl.setExpandRatio(vl.getComponent(0), 1.0f);
+ vl.setExpandRatio(vl.getComponent(2), 0.5f);
+
+ GridLayout gl = new GridLayout(2, 1);
+ addLayoutTest(gl);
+ gl.setColumnExpandRatio(0, 1.0f);
+ gl.setRowExpandRatio(0, 1.0f);
+ gl.setColumnExpandRatio(1, 0.5f);
+ gl.setRowExpandRatio(1, 0.5f);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Layout content overflows if CSS margin used with expand ratio";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11553;
+ }
+
+ private void addLayoutTest(Layout l) {
+ l.setSizeFull();
+
+ Label lbl = new Label("First (expand ratio 1)");
+ lbl.setSizeUndefined();
+ l.addComponent(lbl);
+
+ lbl = new Label("Second (margin 10px)");
+ lbl.setSizeUndefined();
+ lbl.addStyleName("hugemargin");
+ l.addComponent(lbl);
+
+ lbl = new Label("Third (margin+xr)");
+ lbl.setSizeUndefined();
+ lbl.addStyleName("hugemargin");
+ l.addComponent(lbl);
+
+ Panel p = new Panel(l.getClass().getSimpleName(), l);
+ p.setWidth("600px");
+ p.setHeight("200px");
+ addComponent(p);
+ }
+}
diff --git a/uitest/test.xml b/uitest/test.xml
index 5ff39c425d..8228bd9d70 100644
--- a/uitest/test.xml
+++ b/uitest/test.xml
@@ -182,6 +182,7 @@
<sequential>
<ant antfile="${test.xml.dir}/vaadin-server.xml" target="wait-for-startup" />
<antcall inheritall="true" inheritrefs="true" target="run-and-clean-up" />
+ <echo message="All TestBench tests have been run" />
</sequential>
</parallel>
</target>
diff --git a/uitest/vaadin-server.xml b/uitest/vaadin-server.xml
index e02fab8564..5741d78525 100644
--- a/uitest/vaadin-server.xml
+++ b/uitest/vaadin-server.xml
@@ -8,7 +8,7 @@
<ivy:resolve file="${dir}/ivy.xml" />
<ivy:cachepath pathid="classpath.jetty" conf="jetty-run" />
- <java classname="org.mortbay.jetty.runner.Runner" fork="yes">
+ <java classname="org.mortbay.jetty.runner.Runner" fork="yes" output="${vaadin.basedir}/result/jetty.java.out" resultproperty="resultCode">
<arg value="--port" />
<arg value="8888" />
<arg value="--out" />
@@ -19,6 +19,7 @@
<classpath refid="classpath.jetty" />
<jvmarg value="-ea" />
</java>
+ <echo message="Jetty process ended with result code ${resultCode}" />
</target>