aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebContent/VAADIN/themes/tests-valo/uiDependency.css0
-rw-r--r--WebContent/VAADIN/vaadinBootstrap.js8
-rw-r--r--buildhelpers/build.xml2
-rw-r--r--client/src/com/vaadin/client/ApplicationConfiguration.java11
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java128
-rw-r--r--client/src/com/vaadin/client/EventHelper.java55
-rw-r--r--client/src/com/vaadin/client/communication/AtmospherePushConnection.java4
-rw-r--r--client/src/com/vaadin/client/communication/Heartbeat.java3
-rw-r--r--client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java5
-rw-r--r--client/src/com/vaadin/client/extensions/ResponsiveConnector.java74
-rw-r--r--client/src/com/vaadin/client/ui/VNativeSelect.java17
-rw-r--r--client/src/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java21
-rw-r--r--client/tests/src/com/vaadin/client/ApplicationConnectionURLGenerationTest.java10
-rw-r--r--server/src/com/vaadin/data/fieldgroup/FieldGroup.java13
-rw-r--r--server/src/com/vaadin/server/BootstrapHandler.java112
-rw-r--r--server/src/com/vaadin/server/Constants.java1
-rw-r--r--server/src/com/vaadin/server/DefaultDeploymentConfiguration.java21
-rw-r--r--server/src/com/vaadin/server/DeploymentConfiguration.java9
-rw-r--r--server/src/com/vaadin/server/Page.java6
-rw-r--r--server/src/com/vaadin/server/VaadinRequest.java2
-rw-r--r--server/src/com/vaadin/server/communication/PortletBootstrapHandler.java16
-rw-r--r--server/src/com/vaadin/ui/NativeSelect.java3
-rw-r--r--server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java47
-rw-r--r--server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java534
-rw-r--r--server/tests/src/com/vaadin/server/AbstractDeploymentConfigurationTest.java5
-rw-r--r--server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java6
-rw-r--r--server/tests/src/com/vaadin/ui/NativeSelectTest.java54
-rw-r--r--shared/src/com/vaadin/shared/ApplicationConstants.java6
-rw-r--r--shared/src/com/vaadin/shared/VaadinUriResolver.java161
-rw-r--r--shared/src/com/vaadin/shared/util/SharedUtil.java41
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParameters.java36
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java35
-rw-r--r--uitest/src/com/vaadin/tests/components/AbstractTestUI.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java76
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java38
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java37
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/uiDependency.js24
-rw-r--r--uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java59
-rw-r--r--uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayoutTest.java76
39 files changed, 1235 insertions, 526 deletions
diff --git a/WebContent/VAADIN/themes/tests-valo/uiDependency.css b/WebContent/VAADIN/themes/tests-valo/uiDependency.css
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/WebContent/VAADIN/themes/tests-valo/uiDependency.css
diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js
index 53b213e110..89514dbcc2 100644
--- a/WebContent/VAADIN/vaadinBootstrap.js
+++ b/WebContent/VAADIN/vaadinBootstrap.js
@@ -136,7 +136,7 @@
params += extraParams;
}
- params += '&' + vaadin.getBrowserDetailsParameters(appId);
+ params += '&' + vaadin.getBrowserDetailsParameters(appId, getConfig('sendUrlsAsParameters'));
var r;
try {
@@ -270,7 +270,7 @@
ws.pendingApps = null;
}
},
- getBrowserDetailsParameters: function(parentElementId) {
+ getBrowserDetailsParameters: function(parentElementId, sendUrlsAsParameters) {
// Screen height and width
var params = 'v-sh=' + window.screen.height;
params += '&v-sw=' + window.screen.width;
@@ -327,7 +327,9 @@
}
// Location
- params += '&v-loc=' + encodeURIComponent(location.href);
+ if (sendUrlsAsParameters !== false) {
+ params += '&v-loc=' + encodeURIComponent(location.href);
+ }
// Window name
if (window.name) {
diff --git a/buildhelpers/build.xml b/buildhelpers/build.xml
index 159435811f..49c290e9f1 100644
--- a/buildhelpers/build.xml
+++ b/buildhelpers/build.xml
@@ -41,6 +41,7 @@
<antcall target="common.exec-buildhelper">
<param name="main.class" value="com.vaadin.buildhelpers.FetchReleaseNotesTickets" />
<param name="output" value="${output}" />
+ <param name="src" value="src" />
</antcall>
</target>
@@ -49,6 +50,7 @@
<antcall target="common.exec-buildhelper">
<param name="main.class" value="com.vaadin.buildhelpers.FetchReleaseNotesAuthors" />
<param name="output" value="${output}" />
+ <param name="src" value="src" />
</antcall>
<delete file="result/classes/com/vaadin/buildhelpers/authormap.properties" />
</target>
diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java
index d3be69443e..37d689c6d3 100644
--- a/client/src/com/vaadin/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/client/ApplicationConfiguration.java
@@ -276,8 +276,7 @@ public class ApplicationConfiguration implements EntryPoint {
* <code>false</code> if the path info goes after the service URL
*/
public boolean useServiceUrlPathParam() {
- return getJsoConfiguration(id).getConfigBoolean(
- ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER) == Boolean.TRUE;
+ return getServiceUrlParameterName() != null;
}
/**
@@ -289,12 +288,8 @@ public class ApplicationConfiguration implements EntryPoint {
* @return The parameter name, by default <code>v-resourcePath</code>
*/
public String getServiceUrlParameterName() {
- String prefix = getJsoConfiguration(id).getConfigString(
- ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE);
- if (prefix == null) {
- prefix = "";
- }
- return prefix + ApplicationConstants.V_RESOURCE_PATH;
+ return getJsoConfiguration(id).getConfigString(
+ ApplicationConstants.SERVICE_URL_PARAMETER_NAME);
}
public String getRootPanelId() {
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 6abaf28eda..117486ffdb 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -97,12 +97,14 @@ import com.vaadin.client.ui.window.WindowConnector;
import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.JsonConstants;
+import com.vaadin.shared.VaadinUriResolver;
import com.vaadin.shared.Version;
import com.vaadin.shared.communication.LegacyChangeVariablesInvocation;
import com.vaadin.shared.communication.MethodInvocation;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
+import com.vaadin.shared.util.SharedUtil;
import elemental.json.Json;
import elemental.json.JsonArray;
@@ -480,6 +482,33 @@ public class ApplicationConnection implements HasHandlers {
private boolean tooltipInitialized = false;
+ private final VaadinUriResolver uriResolver = new VaadinUriResolver() {
+ @Override
+ protected String getVaadinDirUrl() {
+ return getConfiguration().getVaadinDirUrl();
+ }
+
+ @Override
+ protected String getServiceUrlParameterName() {
+ return getConfiguration().getServiceUrlParameterName();
+ }
+
+ @Override
+ protected String getServiceUrl() {
+ return getConfiguration().getServiceUrl();
+ }
+
+ @Override
+ protected String getThemeUri() {
+ return ApplicationConnection.this.getThemeUri();
+ }
+
+ @Override
+ protected String encodeQueryStringParameterValue(String queryString) {
+ return URL.encodeQueryString(queryString);
+ }
+ };
+
public static class MultiStepDuration extends Duration {
private int previousStep = elapsedMillis();
@@ -829,10 +858,10 @@ public class ApplicationConnection implements HasHandlers {
+ ApplicationConstants.UIDL_PATH + '/');
if (extraParams != null && extraParams.length() > 0) {
- uri = addGetParameters(uri, extraParams);
+ uri = SharedUtil.addGetParameters(uri, extraParams);
}
- uri = addGetParameters(uri, UIConstants.UI_ID_PARAMETER + "="
- + configuration.getUIId());
+ uri = SharedUtil.addGetParameters(uri, UIConstants.UI_ID_PARAMETER
+ + "=" + configuration.getUIId());
doUidlRequest(uri, payload);
@@ -3240,67 +3269,7 @@ public class ApplicationConnection implements HasHandlers {
* @return translated URI ready for browser
*/
public String translateVaadinUri(String uidlUri) {
- if (uidlUri == null) {
- return null;
- }
- if (uidlUri.startsWith("theme://")) {
- final String themeUri = getThemeUri();
- if (themeUri == null) {
- VConsole.error("Theme not set: ThemeResource will not be found. ("
- + uidlUri + ")");
- }
- uidlUri = themeUri + uidlUri.substring(7);
- }
-
- if (uidlUri.startsWith(ApplicationConstants.PUBLISHED_PROTOCOL_PREFIX)) {
- // getAppUri *should* always end with /
- // substring *should* always start with / (published:///foo.bar
- // without published://)
- uidlUri = ApplicationConstants.APP_PROTOCOL_PREFIX
- + ApplicationConstants.PUBLISHED_FILE_PATH
- + uidlUri
- .substring(ApplicationConstants.PUBLISHED_PROTOCOL_PREFIX
- .length());
- // Let translation of app:// urls take care of the rest
- }
- if (uidlUri.startsWith(ApplicationConstants.APP_PROTOCOL_PREFIX)) {
- String relativeUrl = uidlUri
- .substring(ApplicationConstants.APP_PROTOCOL_PREFIX
- .length());
- ApplicationConfiguration conf = getConfiguration();
- String serviceUrl = conf.getServiceUrl();
- if (conf.useServiceUrlPathParam()) {
- // Should put path in v-resourcePath parameter and append query
- // params to base portlet url
- String[] parts = relativeUrl.split("\\?", 2);
- String path = parts[0];
-
- // If there's a "?" followed by something, append it as a query
- // string to the base URL
- if (parts.length > 1) {
- String appUrlParams = parts[1];
- serviceUrl = addGetParameters(serviceUrl, appUrlParams);
- }
- if (!path.startsWith("/")) {
- path = '/' + path;
- }
- String pathParam = conf.getServiceUrlParameterName() + "="
- + URL.encodeQueryString(path);
- serviceUrl = addGetParameters(serviceUrl, pathParam);
- uidlUri = serviceUrl;
- } else {
- uidlUri = serviceUrl + relativeUrl;
- }
- }
- if (uidlUri.startsWith(ApplicationConstants.VAADIN_PROTOCOL_PREFIX)) {
- final String vaadinUri = configuration.getVaadinDirUrl();
- String relativeUrl = uidlUri
- .substring(ApplicationConstants.VAADIN_PROTOCOL_PREFIX
- .length());
- uidlUri = vaadinUri + relativeUrl;
- }
-
- return uidlUri;
+ return uriResolver.resolveVaadinUri(uidlUri);
}
/**
@@ -3417,35 +3386,12 @@ public class ApplicationConnection implements HasHandlers {
* One or more parameters in the format "a=b" or "c=d&e=f". An
* empty string is allowed but will not modify the url.
* @return The modified URI with the get parameters in extraParams added.
+ * @deprecated Use {@link SharedUtil#addGetParameters(String,String)}
+ * instead
*/
+ @Deprecated
public static String addGetParameters(String uri, String extraParams) {
- if (extraParams == null || extraParams.length() == 0) {
- return uri;
- }
- // RFC 3986: The query component is indicated by the first question
- // mark ("?") character and terminated by a number sign ("#") character
- // or by the end of the URI.
- String fragment = null;
- int hashPosition = uri.indexOf('#');
- if (hashPosition != -1) {
- // Fragment including "#"
- fragment = uri.substring(hashPosition);
- // The full uri before the fragment
- uri = uri.substring(0, hashPosition);
- }
-
- if (uri.contains("?")) {
- uri += "&";
- } else {
- uri += "?";
- }
- uri += extraParams;
-
- if (fragment != null) {
- uri += fragment;
- }
-
- return uri;
+ return SharedUtil.addGetParameters(uri, extraParams);
}
ConnectorMap getConnectorMap() {
diff --git a/client/src/com/vaadin/client/EventHelper.java b/client/src/com/vaadin/client/EventHelper.java
index a1cb75527d..f251215d41 100644
--- a/client/src/com/vaadin/client/EventHelper.java
+++ b/client/src/com/vaadin/client/EventHelper.java
@@ -25,6 +25,7 @@ import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.Widget;
/**
* Helper class for attaching/detaching handlers for Vaadin client side
@@ -61,7 +62,7 @@ public class EventHelper {
* @param connector
* The connector to update. Must implement focusHandler.
* @param handlerRegistration
- * The old registration reference or null no handler has been
+ * The old registration reference or null if no handler has been
* registered previously
* @return a new registration handler that can be used to unregister the
* handler later
@@ -69,7 +70,27 @@ public class EventHelper {
public static <T extends ComponentConnector & FocusHandler> HandlerRegistration updateFocusHandler(
T connector, HandlerRegistration handlerRegistration) {
return updateHandler(connector, FOCUS, handlerRegistration,
- FocusEvent.getType());
+ FocusEvent.getType(), connector.getWidget());
+ }
+
+ /**
+ * Adds or removes a focus handler depending on if the connector has focus
+ * listeners on the server side or not.
+ *
+ * @param connector
+ * The connector to update. Must implement focusHandler.
+ * @param handlerRegistration
+ * The old registration reference or null if no handler has been
+ * registered previously
+ * @param widget
+ * The widget which emits focus events
+ * @return a new registration handler that can be used to unregister the
+ * handler later
+ */
+ public static <T extends ComponentConnector & FocusHandler> HandlerRegistration updateFocusHandler(
+ T connector, HandlerRegistration handlerRegistration, Widget widget) {
+ return updateHandler(connector, FOCUS, handlerRegistration,
+ FocusEvent.getType(), widget);
}
/**
@@ -79,7 +100,7 @@ public class EventHelper {
* @param connector
* The connector to update. Must implement BlurHandler.
* @param handlerRegistration
- * The old registration reference or null no handler has been
+ * The old registration reference or null if no handler has been
* registered previously
* @return a new registration handler that can be used to unregister the
* handler later
@@ -87,16 +108,36 @@ public class EventHelper {
public static <T extends ComponentConnector & BlurHandler> HandlerRegistration updateBlurHandler(
T connector, HandlerRegistration handlerRegistration) {
return updateHandler(connector, BLUR, handlerRegistration,
- BlurEvent.getType());
+ BlurEvent.getType(), connector.getWidget());
+ }
+
+ /**
+ * Adds or removes a blur handler depending on if the connector has blur
+ * listeners on the server side or not.
+ *
+ * @param connector
+ * The connector to update. Must implement BlurHandler.
+ * @param handlerRegistration
+ * The old registration reference or null if no handler has been
+ * registered previously
+ * @param widget
+ * The widget which emits blur events
+ *
+ * @return a new registration handler that can be used to unregister the
+ * handler later
+ */
+ public static <T extends ComponentConnector & BlurHandler> HandlerRegistration updateBlurHandler(
+ T connector, HandlerRegistration handlerRegistration, Widget widget) {
+ return updateHandler(connector, BLUR, handlerRegistration,
+ BlurEvent.getType(), widget);
}
private static <H extends EventHandler> HandlerRegistration updateHandler(
ComponentConnector connector, String eventIdentifier,
- HandlerRegistration handlerRegistration, Type<H> type) {
+ HandlerRegistration handlerRegistration, Type<H> type, Widget widget) {
if (connector.hasEventListener(eventIdentifier)) {
if (handlerRegistration == null) {
- handlerRegistration = connector.getWidget().addDomHandler(
- (H) connector, type);
+ handlerRegistration = widget.addDomHandler((H) connector, type);
}
} else if (handlerRegistration != null) {
handlerRegistration.removeHandler();
diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
index dc8d497a69..da08928f36 100644
--- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
+++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
@@ -34,6 +34,8 @@ import com.vaadin.shared.Version;
import com.vaadin.shared.communication.PushConstants;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
+import com.vaadin.shared.util.SharedUtil;
+
import elemental.json.JsonObject;
/**
@@ -185,7 +187,7 @@ public class AtmospherePushConnection implements PushConnection {
}
// uri is needed to identify the right connection when closing
- uri = ApplicationConnection.addGetParameters(baseUrl, extraParams);
+ uri = SharedUtil.addGetParameters(baseUrl, extraParams);
VConsole.log("Establishing push connection");
socket = doConnect(uri, getConfig());
diff --git a/client/src/com/vaadin/client/communication/Heartbeat.java b/client/src/com/vaadin/client/communication/Heartbeat.java
index b9493d4520..5d15e5585f 100644
--- a/client/src/com/vaadin/client/communication/Heartbeat.java
+++ b/client/src/com/vaadin/client/communication/Heartbeat.java
@@ -28,6 +28,7 @@ import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent;
import com.vaadin.client.ApplicationConnection.ConnectionStatusEvent;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.ui.ui.UIConstants;
+import com.vaadin.shared.util.SharedUtil;
/**
* Handles sending of heartbeats to the server and reacting to the response
@@ -63,7 +64,7 @@ public class Heartbeat {
setInterval(connection.getConfiguration().getHeartbeatInterval());
- uri = ApplicationConnection.addGetParameters(connection
+ uri = SharedUtil.addGetParameters(connection
.translateVaadinUri(ApplicationConstants.APP_PROTOCOL_PREFIX
+ ApplicationConstants.HEARTBEAT_PATH + '/'),
UIConstants.UI_ID_PARAMETER + "="
diff --git a/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java b/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java
index 58457c1b7b..11e3e80a14 100644
--- a/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java
+++ b/client/src/com/vaadin/client/extensions/BrowserWindowOpenerConnector.java
@@ -23,12 +23,12 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
import com.vaadin.server.BrowserWindowOpener;
import com.vaadin.shared.ui.BrowserWindowOpenerState;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.util.SharedUtil;
/**
* Client-side code for {@link BrowserWindowOpener}
@@ -81,8 +81,7 @@ public class BrowserWindowOpenerConnector extends AbstractExtensionConnector
}
}
- url = ApplicationConnection
- .addGetParameters(url, params.toString());
+ url = SharedUtil.addGetParameters(url, params.toString());
}
if (getState().uriFragment != null) {
diff --git a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java
index 59e6600949..2e1e75f6cd 100644
--- a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java
+++ b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java
@@ -24,11 +24,13 @@ import com.google.gwt.dom.client.Element;
import com.vaadin.client.BrowserInfo;
import com.vaadin.client.LayoutManager;
import com.vaadin.client.ServerConnector;
+import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.layout.ElementResizeEvent;
import com.vaadin.client.ui.layout.ElementResizeListener;
import com.vaadin.server.Responsive;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.util.SharedUtil;
/**
* The client side connector for the Responsive extension.
@@ -68,6 +70,12 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
*/
protected static JavaScriptObject heightRangeCache;
+ /**
+ * The theme that was in use when the width and height range caches were
+ * created.
+ */
+ protected static String parsedTheme;
+
private static Logger getLogger() {
return Logger.getLogger(ResponsiveConnector.class.getName());
}
@@ -78,16 +86,7 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
@Override
protected void extend(ServerConnector target) {
- // Initialize cache if not already done
- if (widthRangeCache == null) {
- searchForBreakPoints();
- }
-
this.target = (AbstractComponentConnector) target;
-
- // Get any breakpoints from the styles defined for this widget
- getBreakPointsFor(constructSelectorsForTarget());
-
// Start listening for size changes
LayoutManager.get(getConnection()).addElementResizeListener(
this.target.getWidget().getElement(), this);
@@ -131,11 +130,37 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
target.getWidget().getElement(), this);
}
+ @Override
+ public void onStateChanged(StateChangeEvent event) {
+ super.onStateChanged(event);
+ // Changing the theme may introduce new style sheets so we may need to
+ // rebuild the cache
+ if (widthRangeCache == null
+ || !SharedUtil.equals(parsedTheme, getCurrentThemeName())) {
+ // updating break points
+ searchForBreakPoints();
+ }
+ // Get any breakpoints from the styles defined for this widget
+ getBreakPointsFor(constructSelectorsForTarget());
+ // make sure that the ranges are updated at least once regardless of
+ // resize events.
+ updateRanges();
+ }
+
+ private String getCurrentThemeName() {
+ return getConnection().getUIConnector().getActiveTheme();
+ }
+
+ private void searchForBreakPoints() {
+ searchForBreakPointsNative();
+ parsedTheme = getCurrentThemeName();
+ }
+
/**
* Build a cache of all 'width-range' and 'height-range' attribute selectors
* found in the stylesheets.
*/
- private static native void searchForBreakPoints()
+ private static native void searchForBreakPointsNative()
/*-{
// Initialize variables
@@ -307,36 +332,36 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
@Override
public void onElementResize(final ElementResizeEvent event) {
- int width = event.getLayoutManager().getOuterWidth(event.getElement());
- int height = event.getLayoutManager()
- .getOuterHeight(event.getElement());
+ updateRanges();
+ }
+ private void updateRanges() {
+ LayoutManager layoutManager = LayoutManager.get(getConnection());
com.google.gwt.user.client.Element element = target.getWidget()
.getElement();
+ int width = layoutManager.getOuterWidth(element);
+ int height = layoutManager.getOuterHeight(element);
+
boolean forceRedraw = false;
String oldWidthRanges = currentWidthRanges;
String oldHeightRanges = currentHeightRanges;
// Loop through breakpoints and see which one applies to this width
- currentWidthRanges = resolveBreakpoint("width", width,
- event.getElement());
+ currentWidthRanges = resolveBreakpoint("width", width);
if (!"".equals(currentWidthRanges)) {
- target.getWidget().getElement()
- .setAttribute("width-range", currentWidthRanges);
+ element.setAttribute("width-range", currentWidthRanges);
forceRedraw = true;
} else {
element.removeAttribute("width-range");
}
// Loop through breakpoints and see which one applies to this height
- currentHeightRanges = resolveBreakpoint("height", height,
- event.getElement());
+ currentHeightRanges = resolveBreakpoint("height", height);
if (!"".equals(currentHeightRanges)) {
- target.getWidget().getElement()
- .setAttribute("height-range", currentHeightRanges);
+ element.setAttribute("height-range", currentHeightRanges);
forceRedraw = true;
} else {
element.removeAttribute("height-range");
@@ -350,8 +375,8 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
// case some new styles are applied
if (!currentWidthRanges.equals(oldWidthRanges)
|| !currentHeightRanges.equals(oldHeightRanges)) {
- event.getLayoutManager().setNeedsMeasureRecursively(
- ResponsiveConnector.this.target);
+ layoutManager
+ .setNeedsMeasureRecursively(ResponsiveConnector.this.target);
}
}
@@ -370,8 +395,7 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
}
}
- private native String resolveBreakpoint(String which, int size,
- Element element)
+ private native String resolveBreakpoint(String which, int size)
/*-{
// Default to "width" breakpoints
diff --git a/client/src/com/vaadin/client/ui/VNativeSelect.java b/client/src/com/vaadin/client/ui/VNativeSelect.java
index 879c54cae8..330442b550 100644
--- a/client/src/com/vaadin/client/ui/VNativeSelect.java
+++ b/client/src/com/vaadin/client/ui/VNativeSelect.java
@@ -19,9 +19,7 @@ package com.vaadin.client.ui;
import java.util.ArrayList;
import java.util.Iterator;
-import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.ListBox;
import com.vaadin.client.BrowserInfo;
import com.vaadin.client.UIDL;
@@ -119,14 +117,6 @@ public class VNativeSelect extends VOptionGroupBase implements Field {
}
}
- public void addFocusHandler(FocusHandler handler) {
- select.addFocusHandler(handler);
- }
-
- public void addBlurHandler(BlurHandler handler) {
- select.addBlurHandler(handler);
- }
-
@Override
public void setHeight(String height) {
select.setHeight(height);
@@ -154,4 +144,11 @@ public class VNativeSelect extends VOptionGroupBase implements Field {
select.setFocus(true);
}
+ /**
+ * @return the root select widget
+ */
+ public ListBox getSelect() {
+ return getOptionsContainer();
+ }
+
}
diff --git a/client/src/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java b/client/src/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java
index c52b762e58..938903da9a 100644
--- a/client/src/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java
+++ b/client/src/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java
@@ -20,6 +20,9 @@ import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.vaadin.client.EventHelper;
+import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.ui.VNativeSelect;
import com.vaadin.client.ui.optiongroup.OptionGroupBaseConnector;
import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
@@ -30,10 +33,19 @@ import com.vaadin.ui.NativeSelect;
public class NativeSelectConnector extends OptionGroupBaseConnector implements
BlurHandler, FocusHandler {
+ private HandlerRegistration focusHandlerRegistration = null;
+ private HandlerRegistration blurHandlerRegistration = null;
+
public NativeSelectConnector() {
super();
- getWidget().addFocusHandler(this);
- getWidget().addBlurHandler(this);
+ }
+
+ @OnStateChange("registeredEventListeners")
+ private void onServerEventListenerChanged() {
+ focusHandlerRegistration = EventHelper.updateFocusHandler(this,
+ focusHandlerRegistration, getWidget().getSelect());
+ blurHandlerRegistration = EventHelper.updateBlurHandler(this,
+ blurHandlerRegistration, getWidget().getSelect());
}
@Override
@@ -43,11 +55,16 @@ public class NativeSelectConnector extends OptionGroupBaseConnector implements
@Override
public void onFocus(FocusEvent event) {
+ // EventHelper.updateFocusHandler ensures that this is called only when
+ // there is a listener on server side
getRpcProxy(FocusAndBlurServerRpc.class).focus();
}
@Override
public void onBlur(BlurEvent event) {
+ // EventHelper.updateFocusHandler ensures that this is called only when
+ // there is a listener on server side
getRpcProxy(FocusAndBlurServerRpc.class).blur();
}
+
}
diff --git a/client/tests/src/com/vaadin/client/ApplicationConnectionURLGenerationTest.java b/client/tests/src/com/vaadin/client/ApplicationConnectionURLGenerationTest.java
index 36baa163cb..f529ba0886 100644
--- a/client/tests/src/com/vaadin/client/ApplicationConnectionURLGenerationTest.java
+++ b/client/tests/src/com/vaadin/client/ApplicationConnectionURLGenerationTest.java
@@ -4,6 +4,8 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import com.vaadin.shared.util.SharedUtil;
+
public class ApplicationConnectionURLGenerationTest {
private static final String[] URIS = new String[] {
@@ -51,23 +53,23 @@ public class ApplicationConnectionURLGenerationTest {
for (int i = 0; i < URIS.length; i++) {
// Adding nothing
assertEquals(URIS[i],
- ApplicationConnection.addGetParameters(URIS[i], ""));
+ SharedUtil.addGetParameters(URIS[i], ""));
// Adding a=b&c=d
assertEquals(URIS_WITH_ABCD_PARAM[i],
- ApplicationConnection.addGetParameters(URIS[i], "a=b&c=d"));
+ SharedUtil.addGetParameters(URIS[i], "a=b&c=d"));
// Fragments
if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) {
assertEquals(
URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i],
- ApplicationConnection.addGetParameters(URIS[i]
+ SharedUtil.addGetParameters(URIS[i]
+ "#fragment", "a=b&c=d"));
// Empty fragment
assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].replace(
"#fragment", "#"),
- ApplicationConnection.addGetParameters(URIS[i] + "#",
+ SharedUtil.addGetParameters(URIS[i] + "#",
"a=b&c=d"));
}
}
diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
index 1b598ef720..069cb2e153 100644
--- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
+++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
@@ -266,6 +266,14 @@ public class FieldGroup implements Serializable {
configureField(field);
}
+ /**
+ * Wrap property to transactional property.
+ */
+ protected <T> Property.Transactional<T> wrapInTransactionalProperty(
+ Property<T> itemProperty) {
+ return new TransactionalPropertyWrapper<T>(itemProperty);
+ }
+
private void throwIfFieldIsNull(Field<?> field, Object propertyId) {
if (field == null) {
throw new BindException(
@@ -283,11 +291,6 @@ public class FieldGroup implements Serializable {
}
}
- private <T> Property.Transactional<T> wrapInTransactionalProperty(
- Property<T> itemProperty) {
- return new TransactionalPropertyWrapper<T>(itemProperty);
- }
-
/**
* Gets the property with the given property id from the item.
*
diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java
index c45e2b70e0..a9343a7e03 100644
--- a/server/src/com/vaadin/server/BootstrapHandler.java
+++ b/server/src/com/vaadin/server/BootstrapHandler.java
@@ -37,10 +37,14 @@ import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.parser.Tag;
+import com.google.gwt.thirdparty.guava.common.net.UrlEscapers;
+import com.vaadin.annotations.JavaScript;
+import com.vaadin.annotations.StyleSheet;
import com.vaadin.annotations.Viewport;
import com.vaadin.annotations.ViewportGeneratorClass;
import com.vaadin.server.communication.AtmospherePushConnection;
import com.vaadin.shared.ApplicationConstants;
+import com.vaadin.shared.VaadinUriResolver;
import com.vaadin.shared.Version;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.ui.UI;
@@ -76,6 +80,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
private String themeName;
private String appId;
private PushMode pushMode;
+ private JsonObject applicationParameters;
+ private VaadinUriResolver uriResolver;
public BootstrapContext(VaadinResponse response,
BootstrapFragmentResponse bootstrapResponse) {
@@ -149,6 +155,71 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
return bootstrapResponse;
}
+ public JsonObject getApplicationParameters() {
+ if (applicationParameters == null) {
+ applicationParameters = BootstrapHandler.this
+ .getApplicationParameters(this);
+ }
+
+ return applicationParameters;
+ }
+
+ public VaadinUriResolver getUriResolver() {
+ if (uriResolver == null) {
+ uriResolver = new BootstrapUriResolver(this);
+ }
+
+ return uriResolver;
+ }
+ }
+
+ private class BootstrapUriResolver extends VaadinUriResolver {
+ private final BootstrapContext context;
+
+ public BootstrapUriResolver(BootstrapContext bootstrapContext) {
+ context = bootstrapContext;
+ }
+
+ @Override
+ protected String getVaadinDirUrl() {
+ return context.getApplicationParameters().getString(
+ ApplicationConstants.VAADIN_DIR_URL);
+ }
+
+ @Override
+ protected String getThemeUri() {
+ return getVaadinDirUrl() + "themes/" + context.getThemeName();
+ }
+
+ @Override
+ protected String getServiceUrlParameterName() {
+ return getConfigOrNull(ApplicationConstants.SERVICE_URL_PARAMETER_NAME);
+ }
+
+ @Override
+ protected String getServiceUrl() {
+ String serviceUrl = getConfigOrNull(ApplicationConstants.SERVICE_URL);
+ if (serviceUrl == null) {
+ return "./";
+ } else if (!serviceUrl.endsWith("/")) {
+ serviceUrl += "/";
+ }
+ return serviceUrl;
+ }
+
+ private String getConfigOrNull(String name) {
+ JsonObject parameters = context.getApplicationParameters();
+ if (parameters.hasKey(name)) {
+ return parameters.getString(name);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ protected String encodeQueryStringParameterValue(String queryString) {
+ return UrlEscapers.urlFormParameterEscaper().escape(queryString);
+ }
}
@Override
@@ -345,11 +416,41 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
.attr("href", themeUri + "/favicon.ico");
}
+ JavaScript javaScript = uiClass.getAnnotation(JavaScript.class);
+ if (javaScript != null) {
+ String[] resources = javaScript.value();
+ for (String resource : resources) {
+ String url = registerDependency(context, uiClass, resource);
+ head.appendElement("script").attr("type", "text/javascript")
+ .attr("src", url);
+ }
+ }
+
+ StyleSheet styleSheet = uiClass.getAnnotation(StyleSheet.class);
+ if (styleSheet != null) {
+ String[] resources = styleSheet.value();
+ for (String resource : resources) {
+ String url = registerDependency(context, uiClass, resource);
+ head.appendElement("link").attr("rel", "stylesheet")
+ .attr("type", "text/css").attr("href", url);
+ }
+ }
+
Element body = document.body();
body.attr("scroll", "auto");
body.addClass(ApplicationConstants.GENERATED_BODY_CLASSNAME);
}
+ private String registerDependency(BootstrapContext context,
+ Class<? extends UI> uiClass, String resource) {
+ String url = context.getSession().getCommunicationManager()
+ .registerDependency(resource, uiClass);
+
+ url = context.getUriResolver().resolveVaadinUri(url);
+
+ return url;
+ }
+
protected String getMainDivStyle(BootstrapContext context) {
return null;
}
@@ -457,7 +558,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
protected void appendMainScriptTagContents(BootstrapContext context,
StringBuilder builder) throws IOException {
- JsonObject appConfig = getApplicationParameters(context);
+ JsonObject appConfig = context.getApplicationParameters();
boolean isDebug = !context.getSession().getConfiguration()
.isProductionMode();
@@ -490,8 +591,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
}
}
- protected JsonObject getApplicationParameters(BootstrapContext context)
- throws PaintException {
+ protected JsonObject getApplicationParameters(BootstrapContext context) {
VaadinRequest request = context.getRequest();
VaadinSession session = context.getSession();
VaadinService vaadinService = request.getService();
@@ -581,6 +681,12 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
appConfig.put(ApplicationConstants.SERVICE_URL, serviceUrl);
}
+ boolean sendUrlsAsParameters = vaadinService
+ .getDeploymentConfiguration().isSendUrlsAsParameters();
+ if (!sendUrlsAsParameters) {
+ appConfig.put("sendUrlsAsParameters", false);
+ }
+
return appConfig;
}
diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java
index 02a992a882..8036490333 100644
--- a/server/src/com/vaadin/server/Constants.java
+++ b/server/src/com/vaadin/server/Constants.java
@@ -136,6 +136,7 @@ public interface Constants {
static final String SERVLET_PARAMETER_UI_PROVIDER = "UIProvider";
static final String SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING = "legacyPropertyToString";
static final String SERVLET_PARAMETER_SYNC_ID_CHECK = "syncIdCheck";
+ static final String SERVLET_PARAMETER_SENDURLSASPARAMETERS = "sendUrlsAsParameters";
// Configurable parameter names
static final String PARAMETER_VAADIN_RESOURCES = "Resources";
diff --git a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
index 22d5210eaa..b26e048431 100644
--- a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
@@ -59,6 +59,8 @@ public class DefaultDeploymentConfiguration extends
*/
public static final boolean DEFAULT_SYNC_ID_CHECK = true;
+ public static final boolean DEFAULT_SEND_URLS_AS_PARAMETERS = true;
+
private final Properties initParameters;
private boolean productionMode;
private boolean xsrfProtectionEnabled;
@@ -69,6 +71,7 @@ public class DefaultDeploymentConfiguration extends
private final Class<?> systemPropertyBaseClass;
private LegacyProperyToStringMode legacyPropertyToStringMode;
private boolean syncIdCheck;
+ private boolean sendUrlsAsParameters;
/**
* Create a new deployment configuration instance.
@@ -93,6 +96,7 @@ public class DefaultDeploymentConfiguration extends
checkPushMode();
checkLegacyPropertyToString();
checkSyncIdCheck();
+ checkSendUrlsAsParameters();
}
private void checkLegacyPropertyToString() {
@@ -258,6 +262,16 @@ public class DefaultDeploymentConfiguration extends
/**
* {@inheritDoc}
* <p>
+ * The default value is <code>true</code>.
+ */
+ @Override
+ public boolean isSendUrlsAsParameters() {
+ return sendUrlsAsParameters;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
* The default mode is {@link PushMode#DISABLED}.
*/
@Override
@@ -347,6 +361,13 @@ public class DefaultDeploymentConfiguration extends
Boolean.toString(DEFAULT_SYNC_ID_CHECK)).equals("true");
}
+ private void checkSendUrlsAsParameters() {
+ sendUrlsAsParameters = getApplicationOrSystemProperty(
+ Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS,
+ Boolean.toString(DEFAULT_SEND_URLS_AS_PARAMETERS)).equals(
+ "true");
+ }
+
private Logger getLogger() {
return Logger.getLogger(getClass().getName());
}
diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java
index 3c20518c39..968ec7c0c3 100644
--- a/server/src/com/vaadin/server/DeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DeploymentConfiguration.java
@@ -111,6 +111,15 @@ public interface DeploymentConfiguration extends Serializable {
public int getHeartbeatInterval();
/**
+ * Returns whether the sending of URL's as GET and POST parameters in
+ * requests with content-type <code>application/x-www-form-urlencoded</code>
+ * is enabled or not.
+ *
+ * @return <code>false</code> if set to false or <code>true</code> otherwise
+ */
+ public boolean isSendUrlsAsParameters();
+
+ /**
* Returns whether a session should be closed when all its open UIs have
* been idle for longer than its configured maximum inactivity time.
* <p>
diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java
index 3ddf4862b2..74d79ade50 100644
--- a/server/src/com/vaadin/server/Page.java
+++ b/server/src/com/vaadin/server/Page.java
@@ -939,6 +939,12 @@ public class Page implements Serializable {
* @return The browser location URI.
*/
public URI getLocation() {
+ if (location == null
+ && !uI.getSession().getConfiguration().isSendUrlsAsParameters()) {
+ throw new IllegalStateException("Location is not available as the "
+ + Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS
+ + " parameter is configured as false");
+ }
return location;
}
diff --git a/server/src/com/vaadin/server/VaadinRequest.java b/server/src/com/vaadin/server/VaadinRequest.java
index 538e0af598..5b7e16ac46 100644
--- a/server/src/com/vaadin/server/VaadinRequest.java
+++ b/server/src/com/vaadin/server/VaadinRequest.java
@@ -123,7 +123,7 @@ public interface VaadinRequest extends Serializable {
/**
* Gets the path of the requested resource relative to the application. The
- * path be <code>null</code> if no path information is available. Does
+ * path is <code>null</code> if no path information is available. Does
* always start with / if the path isn't <code>null</code>.
*
* @return a string with the path relative to the application.
diff --git a/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
index 1d1a300cd1..289309b631 100644
--- a/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
+++ b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
@@ -26,7 +26,6 @@ import javax.portlet.RenderResponse;
import javax.portlet.ResourceURL;
import com.vaadin.server.BootstrapHandler;
-import com.vaadin.server.PaintException;
import com.vaadin.server.VaadinPortlet;
import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest;
import com.vaadin.server.VaadinPortletRequest;
@@ -36,6 +35,7 @@ import com.vaadin.server.VaadinResponse;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.ApplicationConstants;
+
import elemental.json.JsonObject;
public class PortletBootstrapHandler extends BootstrapHandler {
@@ -92,8 +92,7 @@ public class PortletBootstrapHandler extends BootstrapHandler {
}
@Override
- protected JsonObject getApplicationParameters(BootstrapContext context)
- throws PaintException {
+ protected JsonObject getApplicationParameters(BootstrapContext context) {
JsonObject parameters = super.getApplicationParameters(context);
VaadinPortletResponse response = (VaadinPortletResponse) context
.getResponse();
@@ -105,17 +104,16 @@ public class PortletBootstrapHandler extends BootstrapHandler {
resourceURL.setResourceID("v-browserDetails");
parameters.put("browserDetailsUrl", resourceURL.toString());
- // Always send path info as a query parameter
- parameters
- .put(ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER, true);
+ String serviceUrlParameterName = ApplicationConstants.V_RESOURCE_PATH;
// If we are running in Liferay then we need to prefix all parameters
// with the portlet namespace
if (request instanceof VaadinLiferayRequest) {
- parameters.put(
- ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE,
- response.getPortletResponse().getNamespace());
+ serviceUrlParameterName = response.getPortletResponse()
+ .getNamespace() + serviceUrlParameterName;
}
+ parameters.put(ApplicationConstants.SERVICE_URL_PARAMETER_NAME,
+ serviceUrlParameterName);
return parameters;
}
diff --git a/server/src/com/vaadin/ui/NativeSelect.java b/server/src/com/vaadin/ui/NativeSelect.java
index ee7bfc3e5c..137d57f677 100644
--- a/server/src/com/vaadin/ui/NativeSelect.java
+++ b/server/src/com/vaadin/ui/NativeSelect.java
@@ -56,14 +56,17 @@ public class NativeSelect extends AbstractSelect implements
public NativeSelect(String caption, Collection<?> options) {
super(caption, options);
+ registerRpc(focusBlurRpc);
}
public NativeSelect(String caption, Container dataSource) {
super(caption, dataSource);
+ registerRpc(focusBlurRpc);
}
public NativeSelect(String caption) {
super(caption);
+ registerRpc(focusBlurRpc);
}
/**
diff --git a/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java
index 0e7d682e39..dce9f656b9 100644
--- a/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java
+++ b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java
@@ -5,10 +5,16 @@ import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.nullValue;
import static org.mockito.Mockito.mock;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.Transactional;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.util.TransactionalPropertyWrapper;
import com.vaadin.ui.Field;
+import com.vaadin.ui.TextField;
public class FieldGroupTests {
@@ -45,4 +51,45 @@ public class FieldGroupTests {
sut.unbind(field);
assertThat(sut.getField("foobar"), is(nullValue()));
}
+
+ @Test
+ public void wrapInTransactionalProperty_provideCustomImpl_customTransactionalWrapperIsUsed() {
+ Bean bean = new Bean();
+ FieldGroup group = new FieldGroup() {
+ @Override
+ protected <T> Transactional<T> wrapInTransactionalProperty(
+ Property<T> itemProperty) {
+ return new TransactionalPropertyImpl(itemProperty);
+ }
+ };
+ group.setItemDataSource(new BeanItem<Bean>(bean));
+ TextField field = new TextField();
+ group.bind(field, "name");
+
+ Property propertyDataSource = field.getPropertyDataSource();
+ Assert.assertTrue("Custom implementation of transactional property "
+ + "has not been used",
+ propertyDataSource instanceof TransactionalPropertyImpl);
+ }
+
+ public static class TransactionalPropertyImpl<T> extends
+ TransactionalPropertyWrapper<T> {
+
+ public TransactionalPropertyImpl(Property<T> wrappedProperty) {
+ super(wrappedProperty);
+ }
+
+ }
+
+ public static class Bean {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
}
diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
index bef57fd7d1..c70462012e 100644
--- a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
+++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
@@ -1,5 +1,14 @@
package com.vaadin.data.util.sqlcontainer;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.SQLException;
@@ -24,14 +33,19 @@ import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
import com.vaadin.data.util.sqlcontainer.query.OrderBy;
import com.vaadin.data.util.sqlcontainer.query.TableQuery;
-import static org.junit.Assert.assertTrue;
-
public class SQLContainerTableQueryTest {
private static final int offset = SQLTestsConstants.offset;
+ private final int numberOfRowsInContainer = 4;
+ private final int numberOfPropertiesInContainer = 3;
+ private final String NAME = "NAME";
+ private final String ID = "ID";
+ private final String AGE = "AGE";
private JDBCConnectionPool connectionPool;
- private TableQuery peopleQuery;
+ private TableQuery query;
private SQLContainer container;
+ private final RowId existingItemId = getRowId(1);
+ private final RowId nonExistingItemId = getRowId(1337);
@Before
public void setUp() throws SQLException {
@@ -47,8 +61,8 @@ public class SQLContainerTableQueryTest {
DataGenerator.addPeopleToDatabase(connectionPool);
- peopleQuery = getTableQuery("people");
- container = new SQLContainer(peopleQuery);
+ query = getTableQuery("people");
+ container = new SQLContainer(query);
}
private TableQuery getTableQuery(String tableName) {
@@ -62,6 +76,14 @@ public class SQLContainerTableQueryTest {
return new SQLContainer(getTableQuery("garbage"));
}
+ private Item getItem(Object id) {
+ return container.getItem(id);
+ }
+
+ private RowId getRowId(int id) {
+ return new RowId(new Object[] { id + offset });
+ }
+
@After
public void tearDown() {
if (connectionPool != null) {
@@ -72,7 +94,7 @@ public class SQLContainerTableQueryTest {
@Test
public void itemWithExistingVersionColumnIsRemoved() throws SQLException {
container.setAutoCommit(true);
- peopleQuery.setVersionColumn("ID");
+ query.setVersionColumn(ID);
assertTrue(container.removeItem(container.lastItemId()));
}
@@ -80,7 +102,7 @@ public class SQLContainerTableQueryTest {
@Test(expected = IllegalArgumentException.class)
public void itemWithNonExistingVersionColumnCannotBeRemoved()
throws SQLException {
- peopleQuery.setVersionColumn("version");
+ query.setVersionColumn("version");
container.removeItem(container.lastItemId());
@@ -88,160 +110,113 @@ public class SQLContainerTableQueryTest {
}
@Test
- public void constructor_withTableQuery_shouldSucceed() throws SQLException {
- new SQLContainer(new TableQuery("people", connectionPool,
- SQLTestsConstants.sqlGen));
+ public void containerContainsId() {
+ assertTrue(container.containsId(existingItemId));
}
@Test
- public void containsId_withTableQueryAndExistingId_returnsTrue()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, SQLTestsConstants.sqlGen));
-
- assertTrue(container.containsId(new RowId(new Object[] { 1 + offset })));
- Assert.assertTrue(container.containsId(new RowId(
- new Object[] { 1 + offset })));
- assertTrue(this.container.containsId(new RowId(
- new Object[] { 1 + offset })));
+ public void containerDoesNotContainId() {
+ assertFalse(container.containsId(nonExistingItemId));
}
@Test
- public void containsId_withTableQueryAndNonexistingId_returnsFalse()
- throws SQLException {
- Assert.assertFalse(container.containsId(new RowId(
- new Object[] { 1337 + offset })));
+ public void idPropertyHasCorrectType() {
+ if (SQLTestsConstants.db == DB.ORACLE) {
+ assertEquals(container.getType(ID), BigDecimal.class);
+ } else {
+ assertEquals(container.getType(ID), Integer.class);
+ }
}
@Test
- public void getContainerProperty_tableExistingItemIdAndNonexistingPropertyId_returnsNull()
- throws SQLException {
- Assert.assertNull(container.getContainerProperty(new RowId(
- new Object[] { 1 + offset }), "asdf"));
+ public void namePropertyHasCorrectType() {
+ assertEquals(container.getType(NAME), String.class);
}
@Test
- public void getContainerProperty_tableNonexistingItemId_returnsNull()
- throws SQLException {
- Assert.assertNull(container.getContainerProperty(new RowId(
- new Object[] { 1337 + offset }), "NAME"));
+ public void nonExistingPropertyDoesNotHaveType() {
+ assertThat(container.getType("adsf"), is(nullValue()));
}
@Test
- public void getType_tableIDPropertyId_returnsInteger() throws SQLException {
- if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(BigDecimal.class, container.getType("ID"));
- } else {
- Assert.assertEquals(Integer.class, container.getType("ID"));
- }
+ public void sizeIsReturnedCorrectly() {
+ assertEquals(numberOfRowsInContainer, container.size());
}
@Test
- public void getType_tableNonexistingPropertyId_returnsNull()
- throws SQLException {
- Assert.assertNull(container.getType("asdf"));
+ public void propertyIsFetchedForExistingItem() {
+ assertThat(container.getContainerProperty(existingItemId, NAME)
+ .getValue().toString(), is("Kalle"));
}
@Test
- public void size_table_returnsFour() throws SQLException {
- Assert.assertEquals(4, container.size());
+ public void containerDoesNotContainPropertyForExistingItem() {
+ assertThat(container.getContainerProperty(existingItemId, "asdf"),
+ is(nullValue()));
}
@Test
- public void getContainerProperty_tableExistingItemIdAndPropertyId_returnsProperty()
- throws SQLException {
- if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(
- "Ville",
- container
- .getContainerProperty(
- new RowId(new Object[] { new BigDecimal(
- 0 + offset) }), "NAME").getValue());
- } else {
- Assert.assertEquals(
- "Ville",
- container.getContainerProperty(
- new RowId(new Object[] { 0 + offset }), "NAME")
- .getValue());
- }
+ public void containerDoesNotContainExistingPropertyForNonExistingItem() {
+ assertThat(container.getContainerProperty(nonExistingItemId, NAME),
+ is(nullValue()));
}
@Test
- public void getContainerPropertyIds_table_returnsIDAndNAME()
- throws SQLException {
- Collection<?> propertyIds = container.getContainerPropertyIds();
- Assert.assertEquals(3, propertyIds.size());
- Assert.assertArrayEquals(new String[] { "ID", "NAME", "AGE" },
- propertyIds.toArray());
+ public void propertyIdsAreFetched() {
+ ArrayList<String> propertyIds = new ArrayList<String>(
+ (Collection<? extends String>) container
+ .getContainerPropertyIds());
+
+ assertThat(propertyIds.size(), is(numberOfPropertiesInContainer));
+ assertThat(propertyIds, hasItems(ID, NAME, AGE));
}
@Test
- public void getItem_tableExistingItemId_returnsItem() throws SQLException {
- Item item;
- if (SQLTestsConstants.db == DB.ORACLE) {
- item = container.getItem(new RowId(new Object[] { new BigDecimal(
- 0 + offset) }));
- } else {
- item = container.getItem(new RowId(new Object[] { 0 + offset }));
- }
- Assert.assertNotNull(item);
- Assert.assertEquals("Ville", item.getItemProperty("NAME").getValue());
+ public void existingItemIsFetched() {
+ Item item = container.getItem(existingItemId);
+
+ assertThat(item.getItemProperty(NAME).getValue().toString(),
+ is("Kalle"));
}
@Test
- public void getItem_commitedModifiedAndRefreshed() throws SQLException {
- String OLD_VALUE = "SomeValue"; //$NON-NLS-1$
- String NEW_VALUE = "OtherValue"; //$NON-NLS-1$
+ public void newItemIsAdded() throws SQLException {
+ Object id = container.addItem();
+ getItem(id).getItemProperty(NAME).setValue("foo");
- Object itemID = container.addItem();
- Item item = container.getItem(itemID);
- item.getItemProperty("NAME").setValue(OLD_VALUE); //$NON-NLS-1$
container.commit();
- itemID = container.getIdByIndex(container.size() - 1);
- item = container.getItem(itemID);
- Assert.assertEquals(OLD_VALUE, item.getItemProperty("NAME") //$NON-NLS-1$
- .getValue());
- item.getItemProperty("NAME").setValue(NEW_VALUE); //$NON-NLS-1$
+ Item item = getItem(container.lastItemId());
+ assertThat(item.getItemProperty(NAME).getValue().toString(), is("foo"));
+ }
+
+ @Test
+ public void itemPropertyIsNotRevertedOnRefresh() {
+ getItem(existingItemId).getItemProperty(NAME).setValue("foo");
- // refresh the container which free's the caches
- // and the modified cache keeps untouched which is a really powerful
- // feature
container.refresh();
- // access the item again will use the item from the modified cache.
- item = container.getItem(itemID);
- Assert.assertEquals(NEW_VALUE, item.getItemProperty("NAME") //$NON-NLS-1$
- .getValue());
+ assertThat(getItem(existingItemId).getItemProperty(NAME).toString(),
+ is("foo"));
}
@Test
- public void getItem_table5000RowsWithParameter1337_returnsItemWithId1337()
- throws SQLException {
+ public void correctItemIsFetchedFromMultipleRows() throws SQLException {
DataGenerator.addFiveThousandPeople(connectionPool);
- Item item;
- if (SQLTestsConstants.db == DB.ORACLE) {
- item = container.getItem(new RowId(new Object[] { new BigDecimal(
- 1337 + offset) }));
- Assert.assertNotNull(item);
- Assert.assertEquals(new BigDecimal(1337 + offset), item
- .getItemProperty("ID").getValue());
- } else {
- item = container.getItem(new RowId(new Object[] { 1337 + offset }));
- Assert.assertNotNull(item);
- Assert.assertEquals(1337 + offset, item.getItemProperty("ID")
- .getValue());
- }
- Assert.assertEquals("Person 1337", item.getItemProperty("NAME")
- .getValue());
+ Item item = container.getItem(getRowId(1337));
+
+ assertThat((Integer) item.getItemProperty(ID).getValue(),
+ is(equalTo(1337 + offset)));
+ assertThat(item.getItemProperty(NAME).getValue().toString(),
+ is("Person 1337"));
}
@Test
public void getItemIds_table_returnsItemIdsWithKeys0through3()
throws SQLException {
Collection<?> itemIds = container.getItemIds();
- Assert.assertEquals(4, itemIds.size());
+ assertEquals(4, itemIds.size());
RowId zero = new RowId(new Object[] { 0 + offset });
RowId one = new RowId(new Object[] { 1 + offset });
RowId two = new RowId(new Object[] { 2 + offset });
@@ -260,11 +235,6 @@ public class SQLContainerTableQueryTest {
}
@Test
- public void getType_tableNAMEPropertyId_returnsString() throws SQLException {
- Assert.assertEquals(String.class, container.getType("NAME"));
- }
-
- @Test
public void size_tableOneAddedItem_returnsFive() throws SQLException {
Connection conn = connectionPool.reserveConnection();
Statement statement = conn.createStatement();
@@ -278,17 +248,17 @@ public class SQLContainerTableQueryTest {
conn.commit();
connectionPool.releaseConnection(conn);
- Assert.assertEquals(5, container.size());
+ assertEquals(5, container.size());
}
@Test
public void indexOfId_tableWithParameterThree_returnsThree()
throws SQLException {
if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(3, container.indexOfId(new RowId(
+ assertEquals(3, container.indexOfId(new RowId(
new Object[] { new BigDecimal(3 + offset) })));
} else {
- Assert.assertEquals(3,
+ assertEquals(3,
container.indexOfId(new RowId(new Object[] { 3 + offset })));
}
}
@@ -301,11 +271,11 @@ public class SQLContainerTableQueryTest {
if (SQLTestsConstants.db == DB.ORACLE) {
container.getItem(new RowId(new Object[] { new BigDecimal(
1337 + offset) }));
- Assert.assertEquals(1337, container.indexOfId(new RowId(
+ assertEquals(1337, container.indexOfId(new RowId(
new Object[] { new BigDecimal(1337 + offset) })));
} else {
container.getItem(new RowId(new Object[] { 1337 + offset }));
- Assert.assertEquals(1337, container.indexOfId(new RowId(
+ assertEquals(1337, container.indexOfId(new RowId(
new Object[] { 1337 + offset })));
}
}
@@ -316,12 +286,10 @@ public class SQLContainerTableQueryTest {
DataGenerator.addFiveThousandPeople(connectionPool);
Object itemId = container.getIdByIndex(1337);
if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1337 + offset }).toString(),
+ assertEquals(new RowId(new Object[] { 1337 + offset }).toString(),
itemId.toString());
} else {
- Assert.assertEquals(new RowId(new Object[] { 1337 + offset }),
- itemId);
+ assertEquals(new RowId(new Object[] { 1337 + offset }), itemId);
}
}
@@ -332,12 +300,10 @@ public class SQLContainerTableQueryTest {
Object itemId = container.getIdByIndex(1337);
if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1337 + offset }).toString(),
+ assertEquals(new RowId(new Object[] { 1337 + offset }).toString(),
itemId.toString());
} else {
- Assert.assertEquals(new RowId(new Object[] { 1337 + offset }),
- itemId);
+ assertEquals(new RowId(new Object[] { 1337 + offset }), itemId);
}
}
@@ -349,11 +315,10 @@ public class SQLContainerTableQueryTest {
connectionPool, SQLTestsConstants.sqlGen));
Object itemId = container.getIdByIndex(1337);
if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1338 + offset }).toString(),
+ assertEquals(new RowId(new Object[] { 1338 + offset }).toString(),
container.nextItemId(itemId).toString());
} else {
- Assert.assertEquals(new RowId(new Object[] { 1338 + offset }),
+ assertEquals(new RowId(new Object[] { 1338 + offset }),
container.nextItemId(itemId));
}
}
@@ -364,11 +329,10 @@ public class SQLContainerTableQueryTest {
DataGenerator.addFiveThousandPeople(connectionPool);
Object itemId = container.getIdByIndex(1337);
if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1336 + offset }).toString(),
+ assertEquals(new RowId(new Object[] { 1336 + offset }).toString(),
container.prevItemId(itemId).toString());
} else {
- Assert.assertEquals(new RowId(new Object[] { 1336 + offset }),
+ assertEquals(new RowId(new Object[] { 1336 + offset }),
container.prevItemId(itemId));
}
}
@@ -376,11 +340,10 @@ public class SQLContainerTableQueryTest {
@Test
public void firstItemId_table_returnsItemId0() throws SQLException {
if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 0 + offset }).toString(),
+ assertEquals(new RowId(new Object[] { 0 + offset }).toString(),
container.firstItemId().toString());
} else {
- Assert.assertEquals(new RowId(new Object[] { 0 + offset }),
+ assertEquals(new RowId(new Object[] { 0 + offset }),
container.firstItemId());
}
}
@@ -391,11 +354,10 @@ public class SQLContainerTableQueryTest {
DataGenerator.addFiveThousandPeople(connectionPool);
if (SQLTestsConstants.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 4999 + offset }).toString(),
+ assertEquals(new RowId(new Object[] { 4999 + offset }).toString(),
container.lastItemId().toString());
} else {
- Assert.assertEquals(new RowId(new Object[] { 4999 + offset }),
+ assertEquals(new RowId(new Object[] { 4999 + offset }),
container.lastItemId());
}
}
@@ -479,10 +441,10 @@ public class SQLContainerTableQueryTest {
@Test
public void refresh_table_sizeShouldUpdate() throws SQLException {
- Assert.assertEquals(4, container.size());
+ assertEquals(4, container.size());
DataGenerator.addFiveThousandPeople(connectionPool);
container.refresh();
- Assert.assertEquals(5000, container.size());
+ assertEquals(5000, container.size());
}
@Test
@@ -492,9 +454,9 @@ public class SQLContainerTableQueryTest {
// after adding lots of items unless we call refresh inbetween. This to
// make sure that the refresh method actually refreshes stuff and isn't
// a NOP.
- Assert.assertEquals(4, container.size());
+ assertEquals(4, container.size());
DataGenerator.addFiveThousandPeople(connectionPool);
- Assert.assertEquals(4, container.size());
+ assertEquals(4, container.size());
}
@Test
@@ -507,15 +469,15 @@ public class SQLContainerTableQueryTest {
@Test
public void getPageLength_table_returnsDefault100() throws SQLException {
- Assert.assertEquals(100, container.getPageLength());
+ assertEquals(100, container.getPageLength());
}
@Test
public void setPageLength_table_shouldSucceed() throws SQLException {
container.setPageLength(20);
- Assert.assertEquals(20, container.getPageLength());
+ assertEquals(20, container.getPageLength());
container.setPageLength(200);
- Assert.assertEquals(200, container.getPageLength());
+ assertEquals(200, container.getPageLength());
}
@Test(expected = UnsupportedOperationException.class)
@@ -577,7 +539,7 @@ public class SQLContainerTableQueryTest {
container.setAutoCommit(true);
int originalSize = container.size();
container.addItem();
- Assert.assertEquals(originalSize + 1, container.size());
+ assertEquals(originalSize + 1, container.size());
}
@Test
@@ -585,7 +547,7 @@ public class SQLContainerTableQueryTest {
throws SQLException {
int size = container.size();
container.addItem();
- Assert.assertEquals(size + 1, container.size());
+ assertEquals(size + 1, container.size());
}
@Test
@@ -594,7 +556,7 @@ public class SQLContainerTableQueryTest {
int size = container.size();
Object id1 = container.addItem();
Object id2 = container.addItem();
- Assert.assertEquals(size + 2, container.size());
+ assertEquals(size + 2, container.size());
Assert.assertNotSame(id1, id2);
Assert.assertFalse(id1.equals(id2));
}
@@ -604,7 +566,7 @@ public class SQLContainerTableQueryTest {
throws SQLException {
Object lastId = container.lastItemId();
Object id = container.addItem();
- Assert.assertEquals(id, container.nextItemId(lastId));
+ assertEquals(id, container.nextItemId(lastId));
}
@Test
@@ -612,14 +574,14 @@ public class SQLContainerTableQueryTest {
throws SQLException {
Object lastId = container.lastItemId();
Object id = container.addItem();
- Assert.assertEquals(id, container.lastItemId());
+ assertEquals(id, container.lastItemId());
Assert.assertNotSame(lastId, container.lastItemId());
}
@Test
public void indexOfId_tableNewlyAddedItem_returnsFour() throws SQLException {
Object id = container.addItem();
- Assert.assertEquals(4, container.indexOfId(id));
+ assertEquals(4, container.indexOfId(id));
}
@Test
@@ -641,8 +603,8 @@ public class SQLContainerTableQueryTest {
throws SQLException {
Object id = container.addItem();
Item item = container.getItem(id);
- item.getItemProperty("NAME").setValue("asdf");
- Assert.assertEquals("asdf", container.getContainerProperty(id, "NAME")
+ item.getItemProperty(NAME).setValue("asdf");
+ assertEquals("asdf", container.getContainerProperty(id, NAME)
.getValue());
}
@@ -660,7 +622,7 @@ public class SQLContainerTableQueryTest {
Object id1 = container.addItem();
Object id2 = container.addItem();
- Assert.assertEquals(id1, container.prevItemId(id2));
+ assertEquals(id1, container.prevItemId(id2));
}
@Test
@@ -706,7 +668,7 @@ public class SQLContainerTableQueryTest {
throws SQLException {
Object id = container.addItem();
- Assert.assertEquals(id, container.getIdByIndex(container.size() - 1));
+ assertEquals(id, container.getIdByIndex(container.size() - 1));
}
@Test
@@ -718,7 +680,7 @@ public class SQLContainerTableQueryTest {
assertTrue(container.removeItem(id));
Assert.assertNotSame(id, container.firstItemId());
- Assert.assertEquals(originalSize - 1, container.size());
+ assertEquals(originalSize - 1, container.size());
}
@Test
@@ -736,7 +698,7 @@ public class SQLContainerTableQueryTest {
assertTrue(container.removeItem(id));
Assert.assertFalse(container.containsId(id));
- Assert.assertEquals(size - 1, container.size());
+ assertEquals(size - 1, container.size());
}
@Test
@@ -803,7 +765,7 @@ public class SQLContainerTableQueryTest {
Object third = container.getIdByIndex(2);
assertTrue(container.removeItem(second));
- Assert.assertEquals(third, container.nextItemId(first));
+ assertEquals(third, container.nextItemId(first));
}
@Test
@@ -814,7 +776,7 @@ public class SQLContainerTableQueryTest {
Object third = container.addItem();
assertTrue(container.removeItem(second));
- Assert.assertEquals(third, container.nextItemId(first));
+ assertEquals(third, container.nextItemId(first));
}
@Test
@@ -825,7 +787,7 @@ public class SQLContainerTableQueryTest {
Object third = container.getIdByIndex(2);
assertTrue(container.removeItem(second));
- Assert.assertEquals(first, container.prevItemId(third));
+ assertEquals(first, container.prevItemId(third));
}
@Test
@@ -836,7 +798,7 @@ public class SQLContainerTableQueryTest {
Object third = container.addItem();
assertTrue(container.removeItem(second));
- Assert.assertEquals(first, container.prevItemId(third));
+ assertEquals(first, container.prevItemId(third));
}
@Test
@@ -926,7 +888,7 @@ public class SQLContainerTableQueryTest {
Object id = container.getIdByIndex(2);
assertTrue(container.removeItem(id));
- Assert.assertEquals(-1, container.indexOfId(id));
+ assertEquals(-1, container.indexOfId(id));
}
@Test
@@ -936,7 +898,7 @@ public class SQLContainerTableQueryTest {
assertTrue(container.indexOfId(id) != -1);
assertTrue(container.removeItem(id));
- Assert.assertEquals(-1, container.indexOfId(id));
+ assertEquals(-1, container.indexOfId(id));
}
@Test
@@ -962,7 +924,7 @@ public class SQLContainerTableQueryTest {
@Test
public void removeAllItems_table_shouldSucceed() throws SQLException {
assertTrue(container.removeAllItems());
- Assert.assertEquals(0, container.size());
+ assertEquals(0, container.size());
}
@Test
@@ -972,7 +934,7 @@ public class SQLContainerTableQueryTest {
container.addItem();
assertTrue(container.removeAllItems());
- Assert.assertEquals(0, container.size());
+ assertEquals(0, container.size());
}
// Set timeout to ensure there is no infinite looping (#12882)
@@ -984,28 +946,28 @@ public class SQLContainerTableQueryTest {
container.removeAllItems();
- Assert.assertEquals(container.size(), 0);
+ assertEquals(container.size(), 0);
for (int i = 0; i < itemNumber; ++i) {
container.addItem();
}
container.commit();
- Assert.assertEquals(container.size(), itemNumber);
+ assertEquals(container.size(), itemNumber);
assertTrue(container.removeAllItems());
container.commit();
- Assert.assertEquals(container.size(), 0);
+ assertEquals(container.size(), 0);
}
@Test
public void commit_tableAddedItem_shouldBeWrittenToDB() throws SQLException {
Object id = container.addItem();
- container.getContainerProperty(id, "NAME").setValue("New Name");
+ container.getContainerProperty(id, NAME).setValue("New Name");
assertTrue(id instanceof TemporaryRowId);
Assert.assertSame(id, container.lastItemId());
container.commit();
Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
- Assert.assertEquals("New Name",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("New Name",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@@ -1014,19 +976,19 @@ public class SQLContainerTableQueryTest {
throws SQLException {
Object id = container.addItem();
Object id2 = container.addItem();
- container.getContainerProperty(id, "NAME").setValue("Herbert");
- container.getContainerProperty(id2, "NAME").setValue("Larry");
+ container.getContainerProperty(id, NAME).setValue("Herbert");
+ container.getContainerProperty(id2, NAME).setValue("Larry");
assertTrue(id2 instanceof TemporaryRowId);
Assert.assertSame(id2, container.lastItemId());
container.commit();
Object nextToLast = container.getIdByIndex(container.size() - 2);
Assert.assertFalse(nextToLast instanceof TemporaryRowId);
- Assert.assertEquals("Herbert",
- container.getContainerProperty(nextToLast, "NAME").getValue());
+ assertEquals("Herbert", container
+ .getContainerProperty(nextToLast, NAME).getValue());
Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
- Assert.assertEquals("Larry",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Larry",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@@ -1044,11 +1006,11 @@ public class SQLContainerTableQueryTest {
public void commit_tableLastItemUpdated_shouldUpdateRowInDB()
throws SQLException {
Object last = container.lastItemId();
- container.getContainerProperty(last, "NAME").setValue("Donald");
+ container.getContainerProperty(last, NAME).setValue("Donald");
container.commit();
- Assert.assertEquals("Donald",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Donald",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@@ -1057,23 +1019,23 @@ public class SQLContainerTableQueryTest {
int size = container.size();
Object key = container.firstItemId();
Item row = container.getItem(key);
- row.getItemProperty("NAME").setValue("Pekka");
+ row.getItemProperty(NAME).setValue("Pekka");
assertTrue(container.removeItem(key));
container.commit();
- Assert.assertEquals(size - 1, container.size());
+ assertEquals(size - 1, container.size());
}
@Test
public void rollback_tableItemAdded_discardsAddedItem() throws SQLException {
int size = container.size();
Object id = container.addItem();
- container.getContainerProperty(id, "NAME").setValue("foo");
- Assert.assertEquals(size + 1, container.size());
+ container.getContainerProperty(id, NAME).setValue("foo");
+ assertEquals(size + 1, container.size());
container.rollback();
- Assert.assertEquals(size, container.size());
+ assertEquals(size, container.size());
Assert.assertFalse("foo".equals(container.getContainerProperty(
- container.lastItemId(), "NAME").getValue()));
+ container.lastItemId(), NAME).getValue()));
}
@Test
@@ -1082,19 +1044,19 @@ public class SQLContainerTableQueryTest {
int size = container.size();
Object last = container.lastItemId();
container.removeItem(last);
- Assert.assertEquals(size - 1, container.size());
+ assertEquals(size - 1, container.size());
container.rollback();
- Assert.assertEquals(size, container.size());
- Assert.assertEquals(last, container.lastItemId());
+ assertEquals(size, container.size());
+ assertEquals(last, container.lastItemId());
}
@Test
public void rollback_tableItemChanged_discardsChanges() throws SQLException {
Object last = container.lastItemId();
- container.getContainerProperty(last, "NAME").setValue("foo");
+ container.getContainerProperty(last, NAME).setValue("foo");
container.rollback();
Assert.assertFalse("foo".equals(container.getContainerProperty(
- container.lastItemId(), "NAME").getValue()));
+ container.lastItemId(), NAME).getValue()));
}
@Test
@@ -1164,8 +1126,8 @@ public class SQLContainerTableQueryTest {
@Test
public void isModified_tableChangedItem_returnsTrue() throws SQLException {
Assert.assertFalse(container.isModified());
- container.getContainerProperty(container.lastItemId(), "NAME")
- .setValue("foo");
+ container.getContainerProperty(container.lastItemId(), NAME).setValue(
+ "foo");
assertTrue(container.isModified());
}
@@ -1173,10 +1135,10 @@ public class SQLContainerTableQueryTest {
public void getSortableContainerPropertyIds_table_returnsAllPropertyIds()
throws SQLException {
Collection<?> sortableIds = container.getSortableContainerPropertyIds();
- assertTrue(sortableIds.contains("ID"));
- assertTrue(sortableIds.contains("NAME"));
+ assertTrue(sortableIds.contains(ID));
+ assertTrue(sortableIds.contains(NAME));
assertTrue(sortableIds.contains("AGE"));
- Assert.assertEquals(3, sortableIds.size());
+ assertEquals(3, sortableIds.size());
if (SQLTestsConstants.db == DB.MSSQL
|| SQLTestsConstants.db == DB.ORACLE) {
Assert.assertFalse(sortableIds.contains("rownum"));
@@ -1186,20 +1148,20 @@ public class SQLContainerTableQueryTest {
@Test
public void addOrderBy_table_shouldReorderResults() throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.firstItemId(), "NAME")
+ assertEquals("Ville",
+ container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
- container.addOrderBy(new OrderBy("NAME", true));
+ container.addOrderBy(new OrderBy(NAME, true));
// Börje, Kalle, Pelle, Ville
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.firstItemId(), "NAME")
+ assertEquals("Börje",
+ container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@@ -1211,51 +1173,51 @@ public class SQLContainerTableQueryTest {
@Test
public void sort_table_sortsByName() throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.firstItemId(), "NAME")
+ assertEquals("Ville",
+ container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
- container.sort(new Object[] { "NAME" }, new boolean[] { true });
+ container.sort(new Object[] { NAME }, new boolean[] { true });
// Börje, Kalle, Pelle, Ville
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.firstItemId(), "NAME")
+ assertEquals("Börje",
+ container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@Test
public void addFilter_table_filtersResults() throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(4, container.size());
+ assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
- container.addContainerFilter(new Like("NAME", "%lle"));
+ container.addContainerFilter(new Like(NAME, "%lle"));
// Ville, Kalle, Pelle
- Assert.assertEquals(3, container.size());
- Assert.assertEquals("Pelle",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(3, container.size());
+ assertEquals("Pelle",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@Test
public void addContainerFilter_filtersResults() throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
+ assertEquals(4, container.size());
- container.addContainerFilter("NAME", "Vi", false, false);
+ container.addContainerFilter(NAME, "Vi", false, false);
// Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(1, container.size());
+ assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@@ -1263,14 +1225,14 @@ public class SQLContainerTableQueryTest {
public void addContainerFilter_ignoreCase_filtersResults()
throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
+ assertEquals(4, container.size());
- container.addContainerFilter("NAME", "vi", true, false);
+ container.addContainerFilter(NAME, "vi", true, false);
// Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(1, container.size());
+ assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@@ -1278,42 +1240,42 @@ public class SQLContainerTableQueryTest {
public void removeAllContainerFilters_table_noFiltering()
throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
+ assertEquals(4, container.size());
- container.addContainerFilter("NAME", "Vi", false, false);
+ container.addContainerFilter(NAME, "Vi", false, false);
// Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(1, container.size());
+ assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
container.removeAllContainerFilters();
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(4, container.size());
+ assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@Test
public void removeContainerFilters_table_noFiltering() throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
+ assertEquals(4, container.size());
- container.addContainerFilter("NAME", "Vi", false, false);
+ container.addContainerFilter(NAME, "Vi", false, false);
// Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(1, container.size());
+ assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
- container.removeContainerFilters("NAME");
+ container.removeContainerFilters(NAME);
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(4, container.size());
+ assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
@@ -1321,36 +1283,32 @@ public class SQLContainerTableQueryTest {
public void addFilter_tableBufferedItems_alsoFiltersBufferedItems()
throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals(4, container.size());
+ assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
Object id1 = container.addItem();
- container.getContainerProperty(id1, "NAME").setValue("Palle");
+ container.getContainerProperty(id1, NAME).setValue("Palle");
Object id2 = container.addItem();
- container.getContainerProperty(id2, "NAME").setValue("Bengt");
+ container.getContainerProperty(id2, NAME).setValue("Bengt");
- container.addContainerFilter(new Like("NAME", "%lle"));
+ container.addContainerFilter(new Like(NAME, "%lle"));
// Ville, Kalle, Pelle, Palle
- Assert.assertEquals(4, container.size());
- Assert.assertEquals(
- "Ville",
- container.getContainerProperty(container.getIdByIndex(0),
- "NAME").getValue());
- Assert.assertEquals(
- "Kalle",
- container.getContainerProperty(container.getIdByIndex(1),
- "NAME").getValue());
- Assert.assertEquals(
- "Pelle",
- container.getContainerProperty(container.getIdByIndex(2),
- "NAME").getValue());
- Assert.assertEquals(
- "Palle",
- container.getContainerProperty(container.getIdByIndex(3),
- "NAME").getValue());
+ assertEquals(4, container.size());
+ assertEquals("Ville",
+ container.getContainerProperty(container.getIdByIndex(0), NAME)
+ .getValue());
+ assertEquals("Kalle",
+ container.getContainerProperty(container.getIdByIndex(1), NAME)
+ .getValue());
+ assertEquals("Pelle",
+ container.getContainerProperty(container.getIdByIndex(2), NAME)
+ .getValue());
+ assertEquals("Palle",
+ container.getContainerProperty(container.getIdByIndex(3), NAME)
+ .getValue());
try {
container.getIdByIndex(4);
@@ -1364,7 +1322,7 @@ public class SQLContainerTableQueryTest {
Assert.assertFalse(container.getItemIds().contains(id2));
Assert.assertNull(container.getItem(id2));
- Assert.assertEquals(-1, container.indexOfId(id2));
+ assertEquals(-1, container.indexOfId(id2));
Assert.assertNotSame(id2, container.lastItemId());
Assert.assertSame(id1, container.lastItemId());
@@ -1374,31 +1332,31 @@ public class SQLContainerTableQueryTest {
public void sort_tableBufferedItems_sortsBufferedItemsLastInOrderAdded()
throws SQLException {
// Ville, Kalle, Pelle, Börje
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.firstItemId(), "NAME")
+ assertEquals("Ville",
+ container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
Object id1 = container.addItem();
- container.getContainerProperty(id1, "NAME").setValue("Wilbert");
+ container.getContainerProperty(id1, NAME).setValue("Wilbert");
Object id2 = container.addItem();
- container.getContainerProperty(id2, "NAME").setValue("Albert");
+ container.getContainerProperty(id2, NAME).setValue("Albert");
- container.sort(new Object[] { "NAME" }, new boolean[] { true });
+ container.sort(new Object[] { NAME }, new boolean[] { true });
// Börje, Kalle, Pelle, Ville, Wilbert, Albert
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.firstItemId(), "NAME")
+ assertEquals("Börje",
+ container.getContainerProperty(container.firstItemId(), NAME)
.getValue());
- Assert.assertEquals(
+ assertEquals(
"Wilbert",
container.getContainerProperty(
- container.getIdByIndex(container.size() - 2), "NAME")
+ container.getIdByIndex(container.size() - 2), NAME)
.getValue());
- Assert.assertEquals("Albert",
- container.getContainerProperty(container.lastItemId(), "NAME")
+ assertEquals("Albert",
+ container.getContainerProperty(container.lastItemId(), NAME)
.getValue());
}
diff --git a/server/tests/src/com/vaadin/server/AbstractDeploymentConfigurationTest.java b/server/tests/src/com/vaadin/server/AbstractDeploymentConfigurationTest.java
index 7370bd3fac..0518bea650 100644
--- a/server/tests/src/com/vaadin/server/AbstractDeploymentConfigurationTest.java
+++ b/server/tests/src/com/vaadin/server/AbstractDeploymentConfigurationTest.java
@@ -153,5 +153,10 @@ public class AbstractDeploymentConfigurationTest {
return null;
}
+ @Override
+ public boolean isSendUrlsAsParameters() {
+ return DefaultDeploymentConfiguration.DEFAULT_SEND_URLS_AS_PARAMETERS;
+ }
+
}
}
diff --git a/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java b/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
index 8eceaea53f..ddee23a9ec 100644
--- a/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
+++ b/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
@@ -21,6 +21,7 @@ public class MockDeploymentConfiguration extends
private Map<String, String> applicationOrSystemProperty = new HashMap<String, String>();
private LegacyProperyToStringMode legacyPropertyToStringMode = LegacyProperyToStringMode.DISABLED;
private boolean syncIdCheckEnabled = true;
+ private boolean sendUrlsAsParameters = true;
@Override
public boolean isProductionMode() {
@@ -119,4 +120,9 @@ public class MockDeploymentConfiguration extends
this.legacyPropertyToStringMode = legacyPropertyToStringMode;
}
+ @Override
+ public boolean isSendUrlsAsParameters() {
+ return sendUrlsAsParameters;
+ }
+
}
diff --git a/server/tests/src/com/vaadin/ui/NativeSelectTest.java b/server/tests/src/com/vaadin/ui/NativeSelectTest.java
new file mode 100644
index 0000000000..7e2a04ef1c
--- /dev/null
+++ b/server/tests/src/com/vaadin/ui/NativeSelectTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.ui;
+
+import java.util.Collections;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.data.util.IndexedContainer;
+
+public class NativeSelectTest {
+
+ @Test
+ public void rpcRegisteredConstructorNoArg() {
+ assertFocusRpcRegistered(new NativeSelect());
+ }
+
+ @Test
+ public void rpcRegisteredConstructorString() {
+ assertFocusRpcRegistered(new NativeSelect("foo"));
+ }
+
+ @Test
+ public void rpcRegisteredConstructorStringCollection() {
+ assertFocusRpcRegistered(new NativeSelect("foo",
+ Collections.singleton("Hello")));
+ }
+
+ @Test
+ public void rpcRegisteredConstructorStringContainer() {
+ assertFocusRpcRegistered(new NativeSelect("foo", new IndexedContainer()));
+ }
+
+ private void assertFocusRpcRegistered(NativeSelect s) {
+ Assert.assertNotNull(
+ "RPC is not correctly registered",
+ s.getRpcManager("com.vaadin.shared.communication.FieldRpc$FocusAndBlurServerRpc"));
+ }
+
+}
diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java
index 44c972462a..d7aaee6267 100644
--- a/shared/src/com/vaadin/shared/ApplicationConstants.java
+++ b/shared/src/com/vaadin/shared/ApplicationConstants.java
@@ -48,11 +48,7 @@ public class ApplicationConstants implements Serializable {
public static final String SERVICE_URL = "serviceUrl";
- public static final String SERVICE_URL_PATH_AS_PARAMETER = "usePathParameter";
-
- // Denotes the namespace which parameters should be prefixed with when
- // passed as GET parameters. Currently only used by Liferay.
- public static final String SERVICE_URL_PARAMETER_NAMESPACE = "pathParameterNS";
+ public static final String SERVICE_URL_PARAMETER_NAME = "pathParameterName";
// Javadocs in ApplicationConfiguration should be updated if this is changed
public static final String V_RESOURCE_PATH = "v-resourcePath";
diff --git a/shared/src/com/vaadin/shared/VaadinUriResolver.java b/shared/src/com/vaadin/shared/VaadinUriResolver.java
new file mode 100644
index 0000000000..b45d32f71a
--- /dev/null
+++ b/shared/src/com/vaadin/shared/VaadinUriResolver.java
@@ -0,0 +1,161 @@
+/*
+ * 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.shared;
+
+import java.io.Serializable;
+
+import com.vaadin.shared.util.SharedUtil;
+
+/**
+ * Utility for translating special Vaadin URIs like theme:// and app:// into
+ * URLs usable by the browser. This is an abstract class performing the main
+ * logic in {@link #resolveVaadinUri(String)} and using abstract methods in the
+ * class for accessing information specific to the current environment.
+ *
+ * @since 7.4
+ * @author Vaadin Ltd
+ */
+public abstract class VaadinUriResolver implements Serializable {
+
+ /**
+ * Translates a Vaadin URI to a URL that can be loaded by the browser. The
+ * following URI schemes are supported:
+ * <ul>
+ * <li><code>theme://</code> - resolves to the URL of the currently active
+ * theme.</li>
+ * <li><code>published://</code> - resolves to resources on the classpath
+ * published by {@link com.vaadin.annotations.JavaScript @JavaScript} or
+ * {@link com.vaadin.annotations.StyleSheet @StyleSheet} annotations on
+ * connectors.</li>
+ * <li><code>app://</code> - resolves to a URL that will be routed to the
+ * currently registered {@link com.vaadin.server.RequestHandler
+ * RequestHandler} instances.</li>
+ * <li><code>vaadin://</code> - resolves to the location of static resouces
+ * in the VAADIN directory</li>
+ * </ul>
+ * Any other URI protocols, such as <code>http://</code> or
+ * <code>https://</code> are passed through this method unmodified.
+ *
+ * @since 7.4
+ * @param vaadinUri
+ * the uri to resolve
+ * @return the resolved uri
+ */
+ public String resolveVaadinUri(String vaadinUri) {
+ if (vaadinUri == null) {
+ return null;
+ }
+ if (vaadinUri.startsWith("theme://")) {
+ final String themeUri = getThemeUri();
+ vaadinUri = themeUri + vaadinUri.substring(7);
+ }
+
+ if (vaadinUri
+ .startsWith(ApplicationConstants.PUBLISHED_PROTOCOL_PREFIX)) {
+ // getAppUri *should* always end with /
+ // substring *should* always start with / (published:///foo.bar
+ // without published://)
+ vaadinUri = ApplicationConstants.APP_PROTOCOL_PREFIX
+ + ApplicationConstants.PUBLISHED_FILE_PATH
+ + vaadinUri
+ .substring(ApplicationConstants.PUBLISHED_PROTOCOL_PREFIX
+ .length());
+ // Let translation of app:// urls take care of the rest
+ }
+ if (vaadinUri.startsWith(ApplicationConstants.APP_PROTOCOL_PREFIX)) {
+ String relativeUrl = vaadinUri
+ .substring(ApplicationConstants.APP_PROTOCOL_PREFIX
+ .length());
+ String serviceUrl = getServiceUrl();
+ String serviceUrlParameterName = getServiceUrlParameterName();
+ if (serviceUrlParameterName != null) {
+ // Should put path in v-resourcePath parameter and append query
+ // params to base portlet url
+ String[] parts = relativeUrl.split("\\?", 2);
+ String path = parts[0];
+
+ // If there's a "?" followed by something, append it as a query
+ // string to the base URL
+ if (parts.length > 1) {
+ String appUrlParams = parts[1];
+ serviceUrl = SharedUtil.addGetParameters(serviceUrl,
+ appUrlParams);
+ }
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+ String pathParam = serviceUrlParameterName + "="
+ + encodeQueryStringParameterValue(path);
+ serviceUrl = SharedUtil.addGetParameters(serviceUrl, pathParam);
+ vaadinUri = serviceUrl;
+ } else {
+ vaadinUri = serviceUrl + relativeUrl;
+ }
+ }
+ if (vaadinUri.startsWith(ApplicationConstants.VAADIN_PROTOCOL_PREFIX)) {
+ final String vaadinDirUri = getVaadinDirUrl();
+ String relativeUrl = vaadinUri
+ .substring(ApplicationConstants.VAADIN_PROTOCOL_PREFIX
+ .length());
+ vaadinUri = vaadinDirUri + relativeUrl;
+ }
+
+ return vaadinUri;
+ }
+
+ /**
+ * Gets the URL pointing to the VAADIN directory.
+ *
+ * @return the VAADIN directory URL
+ */
+ protected abstract String getVaadinDirUrl();
+
+ /**
+ * Gets the name of the request parameter that should be used for sending
+ * the requested URL to the {@link #getServiceUrl() service URL}. If
+ * <code>null</code> is returned, the requested URL will instead be appended
+ * to the base service URL.
+ *
+ * @return the parameter name used for passing request URLs, or
+ * <code>null</code> to send the path as a part of the request path.
+ */
+ protected abstract String getServiceUrlParameterName();
+
+ /**
+ * Gets the URL handled by {@link com.vaadin.server.VaadinService
+ * VaadinService} to handle application requests.
+ *
+ * @return the service URL
+ */
+ protected abstract String getServiceUrl();
+
+ /**
+ * Gets the URI of the directory of the current theme.
+ *
+ * @return the URI of the current theme directory
+ */
+ protected abstract String getThemeUri();
+
+ /**
+ * Encodes a value for safe inclusion as a parameter in the query string.
+ *
+ * @param parameterValue
+ * the value to encode
+ * @return the encoded value
+ */
+ protected abstract String encodeQueryStringParameterValue(
+ String parameterValue);
+}
diff --git a/shared/src/com/vaadin/shared/util/SharedUtil.java b/shared/src/com/vaadin/shared/util/SharedUtil.java
index b40d8f03bb..206041235a 100644
--- a/shared/src/com/vaadin/shared/util/SharedUtil.java
+++ b/shared/src/com/vaadin/shared/util/SharedUtil.java
@@ -196,4 +196,45 @@ public class SharedUtil implements Serializable {
return camelCaseToHumanFriendly(string);
}
+ /**
+ * Adds the get parameters to the uri and returns the new uri that contains
+ * the parameters.
+ *
+ * @param uri
+ * The uri to which the parameters should be added.
+ * @param extraParams
+ * One or more parameters in the format "a=b" or "c=d&e=f". An
+ * empty string is allowed but will not modify the url.
+ * @return The modified URI with the get parameters in extraParams added.
+ */
+ public static String addGetParameters(String uri, String extraParams) {
+ if (extraParams == null || extraParams.length() == 0) {
+ return uri;
+ }
+ // RFC 3986: The query component is indicated by the first question
+ // mark ("?") character and terminated by a number sign ("#") character
+ // or by the end of the URI.
+ String fragment = null;
+ int hashPosition = uri.indexOf('#');
+ if (hashPosition != -1) {
+ // Fragment including "#"
+ fragment = uri.substring(hashPosition);
+ // The full uri before the fragment
+ uri = uri.substring(0, hashPosition);
+ }
+
+ if (uri.contains("?")) {
+ uri += "&";
+ } else {
+ uri += "?";
+ }
+ uri += extraParams;
+
+ if (fragment != null) {
+ uri += fragment;
+ }
+
+ return uri;
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParameters.java b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParameters.java
new file mode 100644
index 0000000000..d398ead622
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParameters.java
@@ -0,0 +1,36 @@
+/*
+ * 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.applicationservlet;
+
+import com.vaadin.launcher.CustomDeploymentConfiguration;
+import com.vaadin.launcher.CustomDeploymentConfiguration.Conf;
+import com.vaadin.server.Constants;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+
+@CustomDeploymentConfiguration({ @Conf(name = Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS, value = "false") })
+public class DisableSendUrlAsParameters extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ try {
+ log("Init location: " + getPage().getLocation());
+ } catch (IllegalStateException e) {
+ log("Init location exception: " + e.getMessage());
+ }
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java
new file mode 100644
index 0000000000..f10f281646
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.applicationservlet;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class DisableSendUrlAsParametersTest extends SingleBrowserTest {
+
+ @Test
+ public void testInitLocation() {
+ openTestURL();
+
+ String logRow = getLogRow(0);
+
+ Assert.assertEquals(
+ "1. Init location exception: Location is not available as the sendUrlsAsParameters parameter is configured as false",
+ logRow);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
index 3a7d42e29c..dba055a65a 100644
--- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
+++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
@@ -46,6 +46,11 @@ public abstract class AbstractTestUI extends UI {
}
protected void warnIfWidgetsetMaybeNotCompiled() {
+ // Can't check location if sendUrlAsParameters is disabled
+ if (!getSession().getConfiguration().isSendUrlsAsParameters()) {
+ return;
+ }
+
// Ignore if using debug mode
String query = getPage().getLocation().getQuery();
if (query != null && query.matches(".*[&?]gwt\\.codesvr.*")) {
diff --git a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java
index 29c8c27883..bf81ca4390 100644
--- a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java
+++ b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java
@@ -15,102 +15,58 @@
*/
package com.vaadin.tests.components.nativeselect;
-import java.util.Collections;
-import java.util.List;
-
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.remote.DesiredCapabilities;
+import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-/**
- *
- * @since
- * @author Vaadin Ltd
- */
public class NativeSelectsFocusAndBlurListenerTests extends MultiBrowserTest {
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest()
- */
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return Collections.singletonList(Browser.CHROME
- .getDesiredCapabilities());
- }
-
@Test
- public void testFocusListener() throws InterruptedException {
+ public void testFocusAndBlurListener() throws InterruptedException {
setDebug(true);
openTestURL();
- Thread.sleep(1000);
+ Thread.sleep(200);
menu("Component");
menuSub("Listeners");
menuSub("Focus listener");
-
- getDriver().findElement(By.tagName("body")).click();
-
- WebElement select = getDriver().findElement(By.tagName("select"));
- select.click();
-
- String bodytext = getDriver().findElement(By.tagName("body")).getText();
-
- Assert.assertTrue(bodytext.contains("FocusEvent"));
-
- }
-
- @Test
- public void testBlurListener() throws InterruptedException {
- setDebug(true);
- openTestURL();
- Thread.sleep(1000);
menu("Component");
menuSub("Listeners");
menuSub("Blur listener");
- getDriver().findElement(By.tagName("body")).click();
-
- WebElement select = getDriver().findElement(By.tagName("select"));
- select.click();
+ findElement(By.tagName("body")).click();
+ NativeSelectElement s = $(NativeSelectElement.class).first();
+ s.selectByText("Item 3");
getDriver().findElement(By.tagName("body")).click();
- String bodytext = getDriver().findElement(By.tagName("body")).getText();
-
- Assert.assertTrue(bodytext.contains("BlurEvent"));
+ // Somehow selectByText causes focus + blur + focus + blur on
+ // Chrome/PhantomJS
+ if (BrowserUtil.isChrome(getDesiredCapabilities())
+ || BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
+ Assert.assertEquals("4. FocusEvent", getLogRow(1));
+ Assert.assertEquals("5. BlurEvent", getLogRow(0));
+ } else {
+ Assert.assertEquals("2. FocusEvent", getLogRow(1));
+ Assert.assertEquals("3. BlurEvent", getLogRow(0));
+ }
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass()
- */
@Override
protected Class<?> getUIClass() {
return NativeSelects.class;
}
- /**
- * @since
- * @param string
- */
private void menuSub(String string) {
getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
.click();
new Actions(getDriver()).moveByOffset(100, 0).build().perform();
}
- /**
- * @since
- * @param string
- */
private void menu(String string) {
getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
.click();
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java
new file mode 100644
index 0000000000..96210b2027
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java
@@ -0,0 +1,38 @@
+/*
+ * 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.components.ui;
+
+import com.vaadin.annotations.JavaScript;
+import com.vaadin.annotations.StyleSheet;
+import com.vaadin.annotations.Theme;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+
+@JavaScript("uiDependency.js")
+@StyleSheet("theme://uiDependency.css")
+@Theme("tests-valo")
+public class UiDependenciesInHtml extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Label statusBox = new Label("Status box");
+ statusBox.setId("statusBox");
+ addComponent(statusBox);
+
+ getPage().getJavaScript().execute("window.reportUiDependencyStatus();");
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java
new file mode 100644
index 0000000000..188a0aea3e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.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.components.ui;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class UiDependenciesInHtmlTest extends SingleBrowserTest {
+
+ @Test
+ public void testUiDependencisInHtml() {
+ openTestURL();
+
+ String statusText = findElement(By.id("statusBox")).getText();
+
+ Assert.assertEquals(
+ "Script loaded before vaadinBootstrap.js: true\nStyle tag before vaadin theme: true",
+ statusText);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/ui/uiDependency.js b/uitest/src/com/vaadin/tests/components/ui/uiDependency.js
new file mode 100644
index 0000000000..4a5775c57f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/uiDependency.js
@@ -0,0 +1,24 @@
+(function() {
+ var loadedBeforeVaadin = (window.vaadin === undefined);
+
+ window.reportUiDependencyStatus = function() {
+ var styleIndex = 1000;
+ var themeIndex = -1;
+
+ var stylesheets = document.querySelectorAll("link[rel=stylesheet]");
+ for(var i = 0; i < stylesheets.length; i++) {
+ var stylesheet = stylesheets[i];
+ var href = stylesheet.getAttribute("href");
+ if (href.indexOf("uiDependency.css") > -1) {
+ styleIndex = i;
+ } else if (href.indexOf("styles.css" > -1)) {
+ themeIndex = i;
+ }
+ }
+
+ var status = "Script loaded before vaadinBootstrap.js: " + loadedBeforeVaadin;
+ status += "<br />Style tag before vaadin theme: " + (styleIndex < themeIndex);
+
+ document.getElementById("statusBox").innerHTML = status;
+ }
+})(); \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java
new file mode 100644
index 0000000000..f3df1a1176
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java
@@ -0,0 +1,59 @@
+/*
+ * 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.extensions;
+
+import com.vaadin.server.Responsive;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Label;
+
+public class SetThemeAndResponsiveLayout extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getLayout().setSizeFull();
+ CssLayout responsiveLayout = new CssLayout();
+ responsiveLayout.addStyleName("width-and-height");
+ responsiveLayout.setSizeFull();
+ setContent(responsiveLayout);
+ responsiveLayout
+ .addComponent(new Label(
+ "First set the theme using the button and then resize the browser window in both dimensions to see the background color change."));
+ Button setThemeButton = new Button("Set theme");
+ setThemeButton.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ setTheme("tests-responsive");
+ }
+ });
+ responsiveLayout.addComponent(setThemeButton);
+ Responsive.makeResponsive(responsiveLayout);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "This test verifies that responsive works also when theme is set using setTheme method";
+ };
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 15281;
+ };
+
+}
diff --git a/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayoutTest.java b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayoutTest.java
new file mode 100644
index 0000000000..8a1fbde245
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayoutTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.extensions;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.CssLayoutElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class SetThemeAndResponsiveLayoutTest extends MultiBrowserTest {
+
+ @Before
+ public void setUp() throws Exception {
+ // We need this in order to ensure that the initial width-range is
+ // width: 600px- and height: 500px-
+ testBench().resizeViewPortTo(1024, 768);
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // Seems like stylesheet onload is not fired on PhantomJS
+ // https://github.com/ariya/phantomjs/issues/12332
+ return super.getBrowsersExcludingPhantomJS();
+ }
+
+ @Test
+ public void testWidthAndHeightRanges() throws Exception {
+ openTestURL();
+ // IE sometimes has trouble waiting long enough.
+ new WebDriverWait(getDriver(), 30).until(ExpectedConditions
+ .presenceOfElementLocated(By
+ .cssSelector(".v-csslayout-width-and-height")));
+ // set the theme programmatically
+ $(ButtonElement.class).caption("Set theme").first().click();
+ new WebDriverWait(getDriver(), 30).until(ExpectedConditions
+ .presenceOfElementLocated(By.xpath("//div[@width-range]")));
+
+ // Verify both width-range and height-range.
+ assertEquals("600px-",
+ $(CssLayoutElement.class).first().getAttribute("width-range"));
+ assertEquals("500px-",
+ $(CssLayoutElement.class).first().getAttribute("height-range"));
+
+ // Resize
+ testBench().resizeViewPortTo(550, 450);
+
+ // Verify updated width-range and height-range.
+ assertEquals("0-599px",
+ $(CssLayoutElement.class).first().getAttribute("width-range"));
+ assertEquals("0-499px",
+ $(CssLayoutElement.class).first().getAttribute("height-range"));
+ }
+}