aboutsummaryrefslogtreecommitdiffstats
path: root/server/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/src')
-rw-r--r--server/tests/src/com/vaadin/server/MockServletContext.java327
-rw-r--r--server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java37
-rw-r--r--server/tests/src/com/vaadin/tests/design/DeclarativeTestBase.java8
-rw-r--r--server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java46
-rw-r--r--server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java60
-rw-r--r--server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java46
-rw-r--r--server/tests/src/com/vaadin/tests/design/local-ids.html4
-rw-r--r--server/tests/src/com/vaadin/tests/server/ClassesSerializableTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java8
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/colorpicker/AbstractColorPickerDeclarativeTest.java87
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewDeclarativeTest.java74
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java153
12 files changed, 833 insertions, 19 deletions
diff --git a/server/tests/src/com/vaadin/server/MockServletContext.java b/server/tests/src/com/vaadin/server/MockServletContext.java
index 031c83ae90..45ec700c40 100644
--- a/server/tests/src/com/vaadin/server/MockServletContext.java
+++ b/server/tests/src/com/vaadin/server/MockServletContext.java
@@ -24,12 +24,21 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Map;
import java.util.Set;
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+import javax.servlet.ServletRegistration.Dynamic;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
/**
*
@@ -56,7 +65,7 @@ public class MockServletContext implements ServletContext {
*/
@Override
public int getMajorVersion() {
- return 2;
+ return 3;
}
/*
@@ -66,7 +75,7 @@ public class MockServletContext implements ServletContext {
*/
@Override
public int getMinorVersion() {
- return 4;
+ return 0;
}
/*
@@ -153,8 +162,7 @@ public class MockServletContext implements ServletContext {
*/
@Override
public Enumeration getServlets() {
- // TODO Auto-generated method stub
- return null;
+ return Collections.enumeration(Collections.EMPTY_SET);
}
/*
@@ -301,4 +309,315 @@ public class MockServletContext implements ServletContext {
return null;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getContextPath()
+ */
+ @Override
+ public String getContextPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getEffectiveMajorVersion()
+ */
+ @Override
+ public int getEffectiveMajorVersion() {
+ return 3;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getEffectiveMinorVersion()
+ */
+ @Override
+ public int getEffectiveMinorVersion() {
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#setInitParameter(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public boolean setInitParameter(String name, String value) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addServlet(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public Dynamic addServlet(String servletName, String className) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addServlet(java.lang.String,
+ * javax.servlet.Servlet)
+ */
+ @Override
+ public Dynamic addServlet(String servletName, Servlet servlet) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addServlet(java.lang.String,
+ * java.lang.Class)
+ */
+ @Override
+ public Dynamic addServlet(String servletName,
+ Class<? extends Servlet> servletClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#createServlet(java.lang.Class)
+ */
+ @Override
+ public <T extends Servlet> T createServlet(Class<T> clazz)
+ throws ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * javax.servlet.ServletContext#getServletRegistration(java.lang.String)
+ */
+ @Override
+ public ServletRegistration getServletRegistration(String servletName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getServletRegistrations()
+ */
+ @Override
+ public Map<String, ? extends ServletRegistration> getServletRegistrations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addFilter(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(
+ String filterName, String className) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addFilter(java.lang.String,
+ * javax.servlet.Filter)
+ */
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(
+ String filterName, Filter filter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addFilter(java.lang.String,
+ * java.lang.Class)
+ */
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(
+ String filterName, Class<? extends Filter> filterClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#createFilter(java.lang.Class)
+ */
+ @Override
+ public <T extends Filter> T createFilter(Class<T> clazz)
+ throws ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getFilterRegistration(java.lang.String)
+ */
+ @Override
+ public FilterRegistration getFilterRegistration(String filterName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getFilterRegistrations()
+ */
+ @Override
+ public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getSessionCookieConfig()
+ */
+ @Override
+ public SessionCookieConfig getSessionCookieConfig() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#setSessionTrackingModes(java.util.Set)
+ */
+ @Override
+ public void setSessionTrackingModes(
+ Set<SessionTrackingMode> sessionTrackingModes) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getDefaultSessionTrackingModes()
+ */
+ @Override
+ public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getEffectiveSessionTrackingModes()
+ */
+ @Override
+ public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addListener(java.lang.String)
+ */
+ @Override
+ public void addListener(String className) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addListener(java.util.EventListener)
+ */
+ @Override
+ public <T extends EventListener> void addListener(T t) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#addListener(java.lang.Class)
+ */
+ @Override
+ public void addListener(Class<? extends EventListener> listenerClass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#createListener(java.lang.Class)
+ */
+ @Override
+ public <T extends EventListener> T createListener(Class<T> clazz)
+ throws ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getJspConfigDescriptor()
+ */
+ @Override
+ public JspConfigDescriptor getJspConfigDescriptor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getClassLoader()
+ */
+ @Override
+ public ClassLoader getClassLoader() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#declareRoles(java.lang.String[])
+ */
+ @Override
+ public void declareRoles(String... roleNames) {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git a/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java b/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java
new file mode 100644
index 0000000000..f7dbd0c97e
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2014 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.design;
+
+import org.junit.Test;
+
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.GridLayout;
+
+public class AbstractComponentSetResponsiveTest extends
+ DeclarativeTestBase<GridLayout> {
+
+ @Test
+ public void testResponsiveFlag() {
+ GridLayout gl = new GridLayout();
+ gl.setResponsive(true);
+
+ String design = "<v-grid-layout responsive='true' />";
+
+ testWrite(design, gl);
+ testRead(design, gl);
+ }
+
+}
diff --git a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBase.java b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBase.java
index cba981c947..10f1e5c711 100644
--- a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBase.java
+++ b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBase.java
@@ -24,6 +24,7 @@ import java.util.Map;
import org.junit.Assert;
+import com.vaadin.shared.Connector;
import com.vaadin.ui.Component;
import com.vaadin.ui.Flash;
@@ -59,6 +60,11 @@ public abstract class DeclarativeTestBase<T extends Component> extends
if (readMethod == null || writeMethod == null) {
continue;
}
+ if (Connector.class.isAssignableFrom(c)
+ && readMethod.getName().equals("getParent")) {
+ // Hack to break cycles in the connector hierarchy
+ continue;
+ }
try {
c.getDeclaredMethod(readMethod.getName());
} catch (Exception e) {
@@ -99,7 +105,6 @@ public abstract class DeclarativeTestBase<T extends Component> extends
}
}
});
-
}
@Override
@@ -118,5 +123,4 @@ public abstract class DeclarativeTestBase<T extends Component> extends
}
return comp;
}
-
}
diff --git a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java
index 8dc32e00d6..4cb627d035 100644
--- a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java
+++ b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java
@@ -32,6 +32,8 @@ import org.junit.Assert;
import com.vaadin.ui.Component;
import com.vaadin.ui.declarative.Design;
+import com.vaadin.ui.declarative.DesignContext;
+import com.vaadin.ui.declarative.ShouldWriteDataDelegate;
public abstract class DeclarativeTestBaseBase<T extends Component> {
public interface EqualsAsserter<TT> {
@@ -47,10 +49,21 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
}
}
- protected String write(T object) {
+ protected String write(T object, boolean writeData) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- Design.write(object, outputStream);
+
+ DesignContext dc = new DesignContext();
+ if (writeData) {
+ dc.setShouldWriteDataDelegate(new ShouldWriteDataDelegate() {
+ @Override
+ public boolean shouldWriteData(Component component) {
+ return true;
+ }
+ });
+ }
+ dc.setRootComponent(object);
+ Design.write(dc, outputStream);
return outputStream.toString("UTF-8");
} catch (Exception e) {
throw new RuntimeException(e);
@@ -71,12 +84,21 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
return;
}
- if (o1 instanceof Collection && o2 instanceof Collection) {
-
- } else {
+ if (!(o1 instanceof Collection && o2 instanceof Collection)) {
Assert.assertEquals(o1.getClass(), o2.getClass());
}
+ if (o1 instanceof Object[]) {
+ Object[] a1 = ((Object[]) o1);
+ Object[] a2 = ((Object[]) o2);
+ Assert.assertEquals(message + ": array length", a1.length,
+ a2.length);
+ for (int i = 0; i < a1.length; i++) {
+ assertEquals(message, a1[i], a2[i]);
+ }
+ return;
+ }
+
List<EqualsAsserter<Object>> comparators = getComparators(o1);
if (!comparators.isEmpty()) {
for (EqualsAsserter<Object> ec : comparators) {
@@ -113,7 +135,9 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
protected abstract <TT> EqualsAsserter<TT> getComparator(Class<TT> c);
private boolean isVaadin(Class<?> c) {
- return c.getPackage().getName().startsWith("com.vaadin");
+ return c.getPackage() != null
+ && c.getPackage().getName().startsWith("com.vaadin");
+
}
public void testRead(String design, T expected) {
@@ -121,7 +145,11 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
}
public void testWrite(String design, T expected) {
- String written = write(expected);
+ testWrite(design, expected, false);
+ }
+
+ public void testWrite(String design, T expected, boolean writeData) {
+ String written = write(expected, writeData);
Element producedElem = Jsoup.parse(written).body().child(0);
Element comparableElem = Jsoup.parse(design).body().child(0);
@@ -132,6 +160,10 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
Assert.assertEquals(comparable, produced);
}
+ protected Element createElement(Component c) {
+ return new DesignContext().createElement(c);
+ }
+
private String elementToHtml(Element producedElem) {
StringBuilder stringBuilder = new StringBuilder();
elementToHtml(producedElem, stringBuilder);
diff --git a/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java b/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
new file mode 100644
index 0000000000..c3d7e6d8cf
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2014 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.design;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+import org.junit.Test;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.declarative.Design;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Tests that setting local id via DesignContext works as intended.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class DesignContextLocalIdTest {
+
+ @Test
+ public void testSetLocalId() throws FileNotFoundException {
+ DesignContext ctx = Design.read(new FileInputStream(
+ "server/tests/src/com/vaadin/tests/design/local-ids.html"),
+ new VerticalLayout());
+ TextField tf = (TextField) ctx.getComponentByLocalId("foo");
+ Button b = (Button) ctx.getComponentByLocalId("bar");
+ // A duplicate id should be handled by removing the id from the old
+ // component.
+ ctx.setComponentLocalId(b, "foo");
+ assertEquals("Found the wrong component by local id.", ctx
+ .getComponentByLocalId("foo").getClass(), Button.class);
+ assertEquals("Found the wrong component by local id.",
+ ctx.getComponentByLocalId("bar"), null);
+ // Set an id also for the text field.
+ ctx.setComponentLocalId(tf, "bar");
+ assertEquals("Found the wrong component by local id.", ctx
+ .getComponentByLocalId("foo").getClass(), Button.class);
+ assertEquals("Found the wrong component by local id.", ctx
+ .getComponentByLocalId("bar").getClass(), TextField.class);
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
index 05b2484767..681b9d80a3 100644
--- a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
+++ b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
@@ -24,10 +24,14 @@ import java.util.Date;
import java.util.HashSet;
import java.util.TimeZone;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import com.vaadin.data.util.converter.Converter.ConversionException;
import com.vaadin.event.ShortcutAction;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.event.ShortcutAction.ModifierKey;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.FileResource;
import com.vaadin.server.Resource;
@@ -203,10 +207,8 @@ public class DesignFormatterTest {
@Test
public void testShortcutActionNoCaption() {
- ShortcutAction action = new ShortcutAction(null,
- ShortcutAction.KeyCode.D, new int[] {
- ShortcutAction.ModifierKey.ALT,
- ShortcutAction.ModifierKey.CTRL });
+ ShortcutAction action = new ShortcutAction(null, KeyCode.D, new int[] {
+ ModifierKey.ALT, ModifierKey.CTRL });
String formatted = formatter.format(action);
assertEquals("alt-ctrl-d", formatted);
@@ -216,6 +218,23 @@ public class DesignFormatterTest {
}
@Test
+ public void testInvalidShortcutAction() {
+ assertInvalidShortcut("-");
+ assertInvalidShortcut("foo");
+ assertInvalidShortcut("atl-ctrl");
+ assertInvalidShortcut("-a");
+ }
+
+ protected void assertInvalidShortcut(String shortcut) {
+ try {
+ formatter.parse(shortcut, ShortcutAction.class);
+ Assert.fail("Invalid shortcut '" + shortcut + "' should throw");
+ } catch (ConversionException e) {
+ // expected
+ }
+ }
+
+ @Test
public void testTimeZone() {
TimeZone zone = TimeZone.getTimeZone("GMT+2");
String formatted = formatter.format(zone);
@@ -227,6 +246,25 @@ public class DesignFormatterTest {
assertEquals(zone, result);
}
+ @Test
+ public void testExternalResource() {
+ String url = "://example.com/my%20icon.png?a=b";
+
+ for (String scheme : new String[] { "http", "https", "ftp", "ftps" }) {
+ Resource resource = formatter.parse(scheme + url, Resource.class);
+
+ assertTrue(scheme + " url should be parsed as ExternalResource",
+ resource instanceof ExternalResource);
+ assertEquals("parsed ExternalResource", scheme + url,
+ ((ExternalResource) resource).getURL());
+
+ String formatted = formatter.format(new ExternalResource(scheme
+ + url));
+
+ assertEquals("formatted ExternalResource", scheme + url, formatted);
+ }
+ }
+
/**
* A static method to allow comparison two different actions.
*
diff --git a/server/tests/src/com/vaadin/tests/design/local-ids.html b/server/tests/src/com/vaadin/tests/design/local-ids.html
new file mode 100644
index 0000000000..638d004124
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/design/local-ids.html
@@ -0,0 +1,4 @@
+<v-vertical-layout>
+ <v-text-field caption="Enter your name" _id="foo"/>
+ <v-button _id="bar">Say hello</v-button>
+</v-vertical-layout>
diff --git a/server/tests/src/com/vaadin/tests/server/ClassesSerializableTest.java b/server/tests/src/com/vaadin/tests/server/ClassesSerializableTest.java
index 0de8fd6aab..9603032ce5 100644
--- a/server/tests/src/com/vaadin/tests/server/ClassesSerializableTest.java
+++ b/server/tests/src/com/vaadin/tests/server/ClassesSerializableTest.java
@@ -16,7 +16,6 @@ import java.util.jar.JarFile;
import junit.framework.TestCase;
-import org.junit.Ignore;
import org.junit.Test;
public class ClassesSerializableTest extends TestCase {
@@ -80,6 +79,7 @@ public class ClassesSerializableTest extends TestCase {
"com\\.vaadin\\.external\\..*", //
"com\\.vaadin\\.util\\.WeakValueMap.*", //
"com\\.vaadin\\.themes\\.valoutil\\.BodyStyleName", //
+ "com\\.vaadin\\.server\\.communication\\.JSR356WebsocketInitializer.*", //
};
/**
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java
index 61128a1803..b3867a7a3a 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java
@@ -137,12 +137,18 @@ public class AbstractSelectDeclarativeTest extends
}
@Test
- public void testWriteInlineData() {
+ public void testWriteInlineDataIgnored() {
// No data is written by default
testWrite(stripOptionTags(getDesignForInlineData()),
getExpectedComponentForInlineData());
}
+ @Test
+ public void testWriteInlineData() {
+ testWrite(getDesignForInlineData(),
+ getExpectedComponentForInlineData(), true);
+ }
+
private String getDesignForInlineData() {
return "<v-list-select>\n"
+ " <option icon='http://some.url/icon.png'>Value 1</option>\n" //
diff --git a/server/tests/src/com/vaadin/tests/server/component/colorpicker/AbstractColorPickerDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/colorpicker/AbstractColorPickerDeclarativeTest.java
new file mode 100644
index 0000000000..59b2efdc42
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/colorpicker/AbstractColorPickerDeclarativeTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2000-2014 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.server.component.colorpicker;
+
+import org.junit.Test;
+
+import com.vaadin.shared.ui.colorpicker.Color;
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.AbstractColorPicker;
+import com.vaadin.ui.AbstractColorPicker.PopupStyle;
+import com.vaadin.ui.ColorPicker;
+import com.vaadin.ui.ColorPickerArea;
+
+public class AbstractColorPickerDeclarativeTest extends
+ DeclarativeTestBase<AbstractColorPicker> {
+
+ @Test
+ public void testAllAbstractColorPickerFeatures() {
+ String design = "<v-color-picker color='#fafafa' default-caption-enabled='true' position='100,100'"
+ + " popup-style='simple' rgb-visibility='false' hsv-visibility='false'"
+ + " history-visibility=false textfield-visibility=false />";
+ ColorPicker colorPicker = new ColorPicker();
+ int colorInt = Integer.parseInt("fafafa", 16);
+ colorPicker.setColor(new Color(colorInt));
+ colorPicker.setDefaultCaptionEnabled(true);
+ colorPicker.setPosition(100, 100);
+ colorPicker.setPopupStyle(PopupStyle.POPUP_SIMPLE);
+ colorPicker.setRGBVisibility(false);
+ colorPicker.setHSVVisibility(false);
+ colorPicker.setSwatchesVisibility(true);
+ colorPicker.setHistoryVisibility(false);
+ colorPicker.setTextfieldVisibility(false);
+
+ testWrite(design, colorPicker);
+ testRead(design, colorPicker);
+ }
+
+ @Test
+ public void testEmptyColorPicker() {
+ String design = "<v-color-picker />";
+ ColorPicker colorPicker = new ColorPicker();
+ testRead(design, colorPicker);
+ testWrite(design, colorPicker);
+ }
+
+ @Test
+ public void testAllAbstractColorPickerAreaFeatures() {
+ String design = "<v-color-picker-area color='#fafafa' default-caption-enabled='true' position='100,100'"
+ + " popup-style='simple' rgb-visibility='false' hsv-visibility='false'"
+ + " history-visibility=false textfield-visibility=false />";
+ AbstractColorPicker colorPicker = new ColorPickerArea();
+ int colorInt = Integer.parseInt("fafafa", 16);
+ colorPicker.setColor(new Color(colorInt));
+ colorPicker.setDefaultCaptionEnabled(true);
+ colorPicker.setPosition(100, 100);
+ colorPicker.setPopupStyle(PopupStyle.POPUP_SIMPLE);
+ colorPicker.setRGBVisibility(false);
+ colorPicker.setHSVVisibility(false);
+ colorPicker.setSwatchesVisibility(true);
+ colorPicker.setHistoryVisibility(false);
+ colorPicker.setTextfieldVisibility(false);
+
+ testWrite(design, colorPicker);
+ testRead(design, colorPicker);
+ }
+
+ @Test
+ public void testEmptyColorPickerArea() {
+ String design = "<v-color-picker-area />";
+ AbstractColorPicker colorPicker = new ColorPickerArea();
+ testRead(design, colorPicker);
+ testWrite(design, colorPicker);
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewDeclarativeTest.java
new file mode 100644
index 0000000000..8bad68f5b9
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewDeclarativeTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2000-2014 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.server.component.popupview;
+
+import org.junit.Test;
+
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.declarative.DesignContext;
+
+public class PopupViewDeclarativeTest extends DeclarativeTestBase<PopupView> {
+
+ @Test
+ public void testEmptyPopupView() {
+ PopupView component = new PopupView();
+ Component popup = component.getContent().getPopupComponent();
+ String design = "<v-popup-view><popup-content>"
+ + new DesignContext().createElement(popup)
+ + "</popup-content></v-popup-view>";
+ testWrite(design, component);
+ testRead(design, component);
+ }
+
+ @Test
+ public void testVisiblePopupDesign() {
+ final VerticalLayout verticalLayout = new VerticalLayout();
+ verticalLayout.setWidth("300px");
+ verticalLayout.setHeight("400px");
+
+ PopupView component = new PopupView("Click <u>here</u> to open",
+ verticalLayout);
+ component.setHideOnMouseOut(true);
+ component.setPopupVisible(true);
+ // hide-on-mouse-out is true by default. not seen in design
+ String design = "<v-popup-view popup-visible='true'>" //
+ + "Click <u>here</u> to open"
+ + "<popup-content>"
+ + new DesignContext().createElement(verticalLayout)
+ + "</popup-content>" //
+ + "</v-popup-view>";
+ testWrite(design, component);
+ testRead(design, component);
+ }
+
+ @Test
+ public void testHideOnMouseOutDisabled() {
+ final Label label = new Label("Foo");
+ PopupView component = new PopupView("Click Me!", label);
+ component.setHideOnMouseOut(false);
+ String design = "<v-popup-view hide-on-mouse-out='false'>" //
+ + "Click Me!"
+ + "<popup-content>"
+ + new DesignContext().createElement(label) + "</popup-content>" //
+ + "</v-popup-view>";
+ testWrite(design, component);
+ testRead(design, component);
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java
new file mode 100644
index 0000000000..1ab0011442
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2000-2014 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.server.component.window;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.event.ShortcutAction.ModifierKey;
+import com.vaadin.shared.ui.window.WindowMode;
+import com.vaadin.shared.ui.window.WindowRole;
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.declarative.DesignException;
+
+/**
+ * Tests declarative support for implementations of {@link Window}.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class WindowDeclarativeTest extends DeclarativeTestBase<Window> {
+
+ @Test
+ public void testDefault() {
+ String design = "<v-window>";
+
+ Window expected = new Window();
+
+ testRead(design, expected);
+ testWrite(design, expected);
+ }
+
+ @Test
+ public void testFeatures() {
+
+ String design = "<v-window position='100,100' window-mode='maximized' "
+ + "center modal=true resizable=false resize-lazy=true closable=false draggable=false "
+ + "close-shortcut='ctrl-alt-escape' "
+ + "assistive-prefix='Hello' assistive-postfix='World' assistive-role='alertdialog' "
+ + "tab-stop-enabled=true "
+ + "tab-stop-top-assistive-text='Do not move above the window' "
+ + "tab-stop-bottom-assistive-text='End of window'>"
+ + "</v-window>";
+
+ Window expected = new Window();
+
+ expected.setPositionX(100);
+ expected.setPositionY(100);
+ expected.setWindowMode(WindowMode.MAXIMIZED);
+
+ expected.center();
+ expected.setModal(!expected.isModal());
+ expected.setResizable(!expected.isResizable());
+ expected.setResizeLazy(!expected.isResizeLazy());
+ expected.setClosable(!expected.isClosable());
+ expected.setDraggable(!expected.isDraggable());
+
+ expected.setCloseShortcut(KeyCode.ESCAPE, ModifierKey.CTRL,
+ ModifierKey.ALT);
+
+ expected.setAssistivePrefix("Hello");
+ expected.setAssistivePostfix("World");
+ expected.setAssistiveRole(WindowRole.ALERTDIALOG);
+ expected.setTabStopEnabled(!expected.isTabStopEnabled());
+ expected.setTabStopTopAssistiveText("Do not move above the window");
+ expected.setTabStopBottomAssistiveText("End of window");
+
+ testRead(design, expected);
+ testWrite(design, expected);
+ }
+
+ @Test
+ public void testInvalidPosition() {
+ assertInvalidPosition("");
+ assertInvalidPosition("1");
+ assertInvalidPosition("100,100.1");
+ assertInvalidPosition("x");
+ assertInvalidPosition("2,foo");
+ // Should be invalid, not checked currently
+ // assertInvalidPosition("1,2,3");
+ }
+
+ protected void assertInvalidPosition(String position) {
+ try {
+ read("<v-window position='" + position + "'>");
+ Assert.fail("Invalid position '" + position + "' should throw");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testChildContent() {
+
+ String design = "<v-window>" + createElement(new Button("OK"))
+ + "</v-window>";
+
+ Window expected = new Window();
+ expected.setContent(new Button("OK"));
+
+ testRead(design, expected);
+ testWrite(design, expected);
+ }
+
+ @Test(expected = DesignException.class)
+ public void testMultipleContentChildren() {
+
+ String design = "<v-window>" + createElement(new Label("Hello"))
+ + createElement(new Button("OK")) + "</v-window>";
+
+ read(design);
+ }
+
+ @Test
+ public void testAssistiveDescription() {
+
+ Label assistive1 = new Label("Assistive text");
+ Label assistive2 = new Label("More assistive text");
+
+ String design = "<v-window>"
+ + createElement(assistive1).attr(":assistive-description", "")
+ + createElement(new Button("OK"))
+ + createElement(assistive2).attr(":assistive-description", "");
+
+ Window expected = new Window();
+ expected.setContent(new Button("OK"));
+ expected.setAssistiveDescription(assistive1, assistive2);
+
+ testRead(design, expected);
+
+ String written = "<v-window>" + createElement(new Button("OK"))
+ + createElement(assistive1).attr(":assistive-description", "")
+ + createElement(assistive2).attr(":assistive-description", "");
+
+ testWrite(written, expected);
+ }
+}