diff options
143 files changed, 5401 insertions, 3052 deletions
diff --git a/.classpath b/.classpath index a6e494c5c3..ccbd35cffb 100644 --- a/.classpath +++ b/.classpath @@ -22,8 +22,7 @@ <classpathentry exported="true" kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&ivyXmlPath=push%2Fivy.xml&confs=ide&ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles="/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> - <classpathentry combineaccessrules="false" kind="src" path="/gwt-dev"/> - <classpathentry combineaccessrules="false" kind="src" path="/gwt-user"/> <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&ivyXmlPath=buildhelpers%2Fivy.xml&confs=ide&ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=build.properties"/> + <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&ivyXmlPath=gwt%2Fivy.xml&confs=ide&ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=%24%7Bworkspace_loc%3Avaadin%2Fbuild.properties%7D"/> <classpathentry kind="output" path="build/classes"/> </classpath> @@ -11,34 +11,32 @@ for general instructions and requirements for contributing code to the Vaadin fr Instructions on how to set up a working environment for developing the Vaadin framework follow below. -Cloning the project repositories +Quick Setup ====== +1. <code>git clone https://github.com/vaadin/vaadin.git</code> +1. Install IvyDE, including Ant Tasks, if needed (http://www.apache.org/dist/ant/ivyde/updatesite) +1. Import the project into Eclipse +1. Run build/ide.xml in Eclipse -Vaadin 7 consists of three separate repositories -* https://github.com/vaadin/vaadin.git -* https://github.com/vaadin/gwt.git -* https://github.com/vaadin/gwt-tools.git - -Start by cloning these repositories **into the same folder**: -<pre><code>git clone https://github.com/vaadin/vaadin.git -git clone https://github.com/vaadin/gwt.git -git clone https://github.com/vaadin/gwt-tools.git</code></pre> +For more details, see below -The *vaadin* and *gwt* repositories contain project code. The *gwt-tools* project only contain dependency jars used by the other projects. +Cloning the project repositories +====== +The Vaadin repository can be cloned using +<pre><code>git clone https://github.com/vaadin/vaadin.git</code></pre> -Do not rename the repositories as the rest of this document relies on using the standard naming. +or using your favorite Git tool Setting up Eclipse to Develop Vaadin 7 ========= -Assuming you have cloned the repositories as described in “Cloning the project repositories” above, you can import the *vaadin* and *gwt* projects into Eclipse as follows: Start Eclipse ------------- -Start Eclipse and **use the root checkout folder** (the one containing the *vaadin*, *gwt* and *gwt-tools* folders) **as the workspace folder** +Start Eclipse with the workspace you would like to use. It is usually a good idea to use the parent folder of the Git repository as the workspace folder. Install IvyDE --------- -You'll need the Apache Ivy plug-in for Eclipse to build the project later on, in “Compiling the Default Widget Set and Themes”. +You'll need the Apache Ivy plug-in for Eclipse to build the project: 1. Go to *Help* -> *Install New Software...* 1. Enter `http://www.apache.org/dist/ant/ivyde/updatesite` in the "Work with:" text field @@ -49,25 +47,35 @@ If you have installed IvyDE via the Eclipse Marketplace previously, **make sure* 1. Go to *Help* -> *Install New Software...* 1. Click the hyperlink in the "What is already installed?" sentence near the bottom right-hand corner 1. Verify that the list includes *Apache Ivy Ant Tasks* +1. If it isn't included, follow the installation process above, but select only *Apache Ivy library* > *Apache Ivy Ant Tasks* + + +Import the Project into the Workspace +------------ +1. Do *File* -> *Import* -> *General* -> *Existing Projects into Workspace* +![ImportProject](http://f.cl.ly/items/0G361519182v1z2T1o1O/Import.png "Import project") +1. Select the *vaadin* folder (where you cloned the project) +1. Ensure the *vaadin* project is checked +1. Click “finish” to complete the import of Vaadin Framework + +The project should compile without further configuration. If the project does not compile without errors, choose *Ivy* -> *Resolve* from the vaadin project popup menu to ensure all dependencies have been resolved. -If it isn't included, follow the installation process above, but select only *Apache Ivy library* > *Apache Ivy Ant Tasks* +Note that the first compilation takes a while to finish as Ivy downloads dependencies used in the projects. + +Compiling the Default Widget Set and Themes +-------- +Compile the default widget set by executing the default target in build/ide.xml in the vaadin project. +In Eclipse this is done by opening build/ide.xml, right clicking on it and choosing *Run As* -> *Ant Build*. +![CompileWidgetSet](http://cl.ly/image/1R43162b282e/build.png "Compiling the Widget Set") -Set up the Workspace and define required variables for projects +Set up extra workspace preferences -------- +The following preferences need to be set to keep the project consistent. You need to do this especially to be able to contribute changes to the project. + 1. Open *Window* -> *Preferences* (Windows) or *Eclipse* -> *Preferences* (Mac) 1. Go to *General* -> *Workspace* 1. Set *Text file encoding* to *UTF-8* 1. Set *New text file line delimiter* to *Unix* -1. Go to *General* -> *Workspace* -> *Linked Resources* -1. Add a new Path Variable **GWT_ROOT** referring to the gwt folder containing the gwt project -![GWT_ROOT](http://f.cl.ly/items/430q0H0z3t362Z1A1n3L/LinkedResources.png "Defining GWT_ROOT") -1. Go to *Java* -> *Build Path* -> *Classpath Variables* -1. Add two new variables - 1. GWT_TOOLS referring to the gwt-tools folder containing the dependency jars - 1. JDK_HOME referring to your jdk installation directory - ![GWT_TOOLS](http://f.cl.ly/items/1k2Z1n2v0p0y3l0X0D1G/ClasspathVars.png "Defining GWT_TOOLS") -1. Go to Java -> Compiler - 1. Check that the compliance level has been set to 1.6 1. Go to XML -> XML Files -> Editor 1. Ensure the settings are follows: <pre><code>Line width: 72 @@ -78,61 +86,26 @@ Indent-using spaces: true Indentation size: 4 </code></pre> -Import the Projects into the Workspace ------------- -1. Do *File* -> *Import* -> *General* -> *Existing Projects into Workspace* -![ImportProject](http://f.cl.ly/items/0G361519182v1z2T1o1O/Import.png "Import project") -1. Select the workspace folder as root directory -1. Click “deselect all” and select - 1. gwt-dev - 2. gwt-user -1. Click “finish” to complete the import of GWT -1. Then repeat by doing *File* -> *Import* -> *General* -> *Existing Projects into Workspace* -1. Select the workspace folder as root directory -1. Click “deselect all” and select - 1. vaadin -1. Click “finish” to complete the import of Vaadin Framework - -![FinishImportProject](http://cl.ly/image/2W3S0P2c2p1t/Import2.png "Finishing Project Import") - -You should now have three projects in your workspace. If the vaadin project does not compile without errors, choose *Ivy* -> *Resolve* from the vaadin project popup menu. Now all projects should compile without errors (there might be warnings). - -Note that the first compilation takes a while to finish as Ivy downloads dependencies used in the projects. - -Compiling the Default Widget Set and Themes --------- -Compile the default widget set by executing the default target in build/ide.xml in the vaadin project. -In Eclipse this is done by opening build/ide.xml, right clicking on it and choosing *Run As* -> *Ant Build*. -![CompileWidgetSet](http://cl.ly/image/1R43162b282e/build.png "Compiling the Widget Set") - Running a UI test ------ -The *vaadin* project includes an embedded Jetty which is used for running the UI tests. -It is a standard Java application: *com.vaadin.launcher.DevelopmentServerLauncher*. -Launch it in debug mode in Eclipse by right clicking on it and selecting *Debug As* -> *Java Application*. +The *vaadin* project includes an embedded Jetty (*com.vaadin.launcher.DevelopmentServerLauncher*) which is used for running the UI tests. +In Eclipse you can launch it using the included launch configuration: Right click on *eclipse/Development Server (vaadin).launch" and select *Debug As* -> *Development Server (vaadin)*. -This launches a Jetty on port 8888 which allows you to run any UI class in the project by opening http://localhost:8888/run/<UI class name>?restartApplication in your browser, e.g. [http://localhost:8888/run/com.vaadin.tests.components.label.LabelModes?restartApplication](http://localhost:8888/run/com.vaadin.tests.components.label.LabelModes?restartApplication) (Add ?restartApplication to ensure). +This launches a Jetty on port 8888 which allows you to run any UI class in the project by opening http://localhost:8888/run/<UI class name>?restartApplication in your browser, e.g. [http://localhost:8888/run/com.vaadin.tests.components.label.LabelModes?restartApplication](http://localhost:8888/run/com.vaadin.tests.components.label.LabelModes?restartApplication) (Use ?restartApplication to ensure the correct UI is shown). Running JUnit tests ===== -The JUnit tests for the projects can be run using +The unit tests for the projects can be run using <pre><code>ant test</code></pre> -Running this in the *gwt* directory will run the GWT JUnit tests. -Running it in the *vaadin* directory will run the Vaadin JUnit tests. - -Note that the included Vaadin TestBench (browser) tests currently requires access to a TestBench cluster, which is currently only available internally at Vaadin Ltd. +Note that the included Vaadin TestBench (browser) tests require access to a TestBench cluster, currently only available internally at Vaadin Ltd. Building a package ===== -The distribution files can be built in a few steps. First build the *gwt* project by running -<pre><code>ant</code></pre> -in the *gwt* directory. The elemental package needs to be built separately: -<pre><code>ant elemental</code></pre> -Building the elemental package is not possible on Windows as it requires gcc. +The distribution files can be built in two steps. -Move to the *vaadin* project directory and unpack the previously built gwt jars +1. Unpack required gwt jars into the project <pre><code>ant -f gwt-files.xml unpack.gwt</code></pre> -Then build the *vaadin* project by running +2. Build the project by running <pre><code>ant</code></pre> -in the *vaadin* directory. +in the project root directory (add -Dvaadin.version=1.2.3 to use a specific version number). diff --git a/WebContent/VAADIN/themes/tests-responsive/styles.css b/WebContent/VAADIN/themes/tests-responsive/styles.css index 4bfc6dd768..db92a2a2fc 100644 --- a/WebContent/VAADIN/themes/tests-responsive/styles.css +++ b/WebContent/VAADIN/themes/tests-responsive/styles.css @@ -90,3 +90,12 @@ .description[width-range="701px-"] { font-size: 30px; } + +/* Styles for ResponsiveWidthAndHeight test. */ +.v-csslayout-width-and-height[width-range~="0-599px"][height-range~="0-499px"] { + background: blue; + color: #fff; +} +.v-csslayout-width-and-height[height-range~="500px-"][width-range~="600px-"] { + background: red; +}
\ No newline at end of file diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index f98b7c78d1..7d86cf7cc2 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -25,6 +25,7 @@ <param-value>com.vaadin.tests.components.button.Buttons</param-value> </init-param> <async-supported>true</async-supported> + <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>Embed App 2</servlet-name> @@ -34,6 +35,7 @@ <param-value>com.vaadin.tests.components.label.MarginsInLabels</param-value> </init-param> <async-supported>true</async-supported> + <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>UI provider app</servlet-name> @@ -47,6 +49,7 @@ <param-value>com.vaadin.tests.VerifyAssertionsEnabled</param-value> </init-param> <async-supported>true</async-supported> + <load-on-startup>3</load-on-startup> </servlet> <servlet> @@ -74,6 +77,7 @@ <param-value>42</param-value> </init-param> <async-supported>true</async-supported> + <load-on-startup>4</load-on-startup> </servlet> <servlet> @@ -84,6 +88,7 @@ --> <servlet-name>VaadinApplicationRunnerWithTimeoutRedirect</servlet-name> <servlet-class>com.vaadin.launcher.ApplicationRunnerServlet</servlet-class> + <load-on-startup>5</load-on-startup> </servlet> <servlet> @@ -94,6 +99,7 @@ <param-value>automatic</param-value> </init-param> <async-supported>true</async-supported> + <load-on-startup>6</load-on-startup> </servlet> <!-- For testing GAE - the deployment script changes this to use GAEVaadinServlet --> @@ -105,6 +111,7 @@ <param-value>com.vaadin.tests.integration.ServletIntegrationUI</param-value> </init-param> <async-supported>true</async-supported> + <load-on-startup>7</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Embed App 1</servlet-name> diff --git a/build.properties b/build.properties index b524afd139..0fc074ce69 100644 --- a/build.properties +++ b/build.properties @@ -6,4 +6,5 @@ vaadin.url=http://vaadin.com vaadin.java.version=1.6 vaadin.version=0.0.0.unversioned-development-build vaadin.sass.version=0.9.6 +gwt.version=2.6.0.vaadin2 commons-io.version=2.4 diff --git a/build/ide.xml b/build/ide.xml index 678fc49d5b..525e16d88d 100755 --- a/build/ide.xml +++ b/build/ide.xml @@ -1,17 +1,8 @@ <?xml version="1.0"?> <project xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:artifact="antlib:org.apache.maven.artifact.ant" xmlns:ivy="antlib:org.apache.ivy.ant" name="Build script for IDE users" basedir=".." default="theme-and-default-widgetset"> - <include file="${basedir}/gwt-files.xml" /> - - <property name="gwt.dev.classes" location="${gwt.eclipse.basedir}/dev/bin" /> - <property name="gwt.user.classes" location="${gwt.eclipse.basedir}/user/bin" /> - <property name="gwt.dev.src" location="${gwt.basedir}/dev/core/src" /> - <property name="gwt.dev.super.src" location="${gwt.basedir}/dev/core/super" /> - <property name="gwt.user.src" location="${gwt.basedir}/user/src" /> - <property name="gwt.user.super.src" location="${gwt.basedir}/user/super" /> - <property name="work.dir" location="work" /> - <echo>Using gwt files from ${gwt.user.classes} and ${gwt.dev.classes}</echo> + <property file="build.properties" /> <ivy:resolve log="download-only" file="client-compiler/ivy.xml" conf="ide" /> <ivy:cachepath pathid="client-compiler.deps" conf="ide" /> @@ -25,22 +16,19 @@ <ivy:cachepath pathid="uitest.deps" conf="ide" /> <ivy:resolve log="download-only" file="buildhelpers/ivy.xml" /> <ivy:cachepath pathid="buildhelpers.deps" /> + <ivy:resolve log="download-only" file="gwt/ivy.xml" conf="ide" /> + <ivy:cachepath pathid="gwt.deps" conf="ide" /> <path id="classpath"> <path location="bin" /> <path location="build/classes" /> - <path location="${gwt.user.classes}" /> - <path location="${gwt.user.src}" /> - <path location="${gwt.user.super.src}" /> - <path location="${gwt.dev.classes}" /> - <path location="${gwt.dev.super.src}" /> - <path location="${gwt.dev.src}" /> <path refid="client-compiler.deps" /> <path refid="server.deps" /> <path refid="shared.deps" /> <path refid="uitest.deps" /> <path refid="client.deps" /> <path refid="buildhelpers.deps" /> + <path refid="gwt.deps" /> <path location="server/src" /> <path location="shared/src" /> <path location="uitest/src" /> diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java index 8a4ca8f795..8bbcac4ecb 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java @@ -253,9 +253,9 @@ public class ConnectorBundle { needsSuperClass = needsSuperClass.getSuperclass(); } - for (Property property : getProperties(typeAsClass)) { - setNeedsGwtConstructor(property.getBeanType()); + setNeedsGwtConstructor(typeAsClass); + for (Property property : getProperties(typeAsClass)) { setNeedsProperty(property); JType propertyType = property.getPropertyType(); diff --git a/client/src/com/vaadin/client/TooltipInfo.java b/client/src/com/vaadin/client/TooltipInfo.java index 67d2ad37c2..06940536c8 100644 --- a/client/src/com/vaadin/client/TooltipInfo.java +++ b/client/src/com/vaadin/client/TooltipInfo.java @@ -21,6 +21,11 @@ public class TooltipInfo { private String errorMessageHtml; + // Contains the tooltip's identifier. If a tooltip's contents and this + // identifier haven't changed, the tooltip won't be updated in subsequent + // events. + private Object identifier; + public TooltipInfo() { } @@ -29,10 +34,23 @@ public class TooltipInfo { } public TooltipInfo(String tooltip, String errorMessage) { + this(tooltip, errorMessage, null); + } + + public TooltipInfo(String tooltip, String errorMessage, Object identifier) { + setIdentifier(identifier); setTitle(tooltip); setErrorMessage(errorMessage); } + public void setIdentifier(Object identifier) { + this.identifier = identifier; + } + + public Object getIdentifier() { + return identifier; + } + public String getTitle() { return title; } @@ -61,6 +79,7 @@ public class TooltipInfo { } public boolean equals(TooltipInfo other) { - return (other != null && other.title == title && other.errorMessageHtml == errorMessageHtml); + return (other != null && other.title == title + && other.errorMessageHtml == errorMessageHtml && other.identifier == identifier); } } diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index 487f577ae3..8e653a0476 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -153,15 +153,61 @@ public class VTooltip extends VWindowOverlay { offsetWidth = getOffsetWidth(); offsetHeight = getOffsetHeight(); } + int x = getFinalX(offsetWidth); + int y = getFinalY(offsetHeight); - int x = tooltipEventMouseX + 10 + Window.getScrollLeft(); - int y = tooltipEventMouseY + 10 + Window.getScrollTop(); + setPopupPosition(x, y); + sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT); + } + /** + * Return the final X-coordinate of the tooltip based on cursor + * position, size of the tooltip, size of the page and necessary + * margins. + * + * @param offsetWidth + * @return The final X-coordinate + */ + private int getFinalX(int offsetWidth) { + int x = 0; + int widthNeeded = 10 + MARGIN + offsetWidth; + int roomLeft = tooltipEventMouseX; + int roomRight = Window.getClientWidth() - roomLeft; + if (roomRight > widthNeeded) { + x = tooltipEventMouseX + 10 + Window.getScrollLeft(); + } else { + x = tooltipEventMouseX + Window.getScrollLeft() - 10 + - offsetWidth; + } if (x + offsetWidth + MARGIN - Window.getScrollLeft() > Window .getClientWidth()) { x = Window.getClientWidth() - offsetWidth - MARGIN + Window.getScrollLeft(); } + return x; + } + + /** + * Return the final Y-coordinate of the tooltip based on cursor + * position, size of the tooltip, size of the page and necessary + * margins. + * + * @param offsetHeight + * @return The final y-coordinate + * + */ + private int getFinalY(int offsetHeight) { + int y = 0; + int heightNeeded = 10 + MARGIN + offsetHeight; + int roomAbove = tooltipEventMouseY; + int roomBelow = Window.getClientHeight() - roomAbove; + + if (roomBelow > heightNeeded) { + y = tooltipEventMouseY + 10 + Window.getScrollTop(); + } else { + y = tooltipEventMouseY + Window.getScrollTop() - 10 + - offsetHeight; + } if (y + offsetHeight + MARGIN - Window.getScrollTop() > Window .getClientHeight()) { @@ -173,8 +219,7 @@ public class VTooltip extends VWindowOverlay { y = Window.getScrollTop(); } } - setPopupPosition(x, y); - sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT); + return y; } }); } else { @@ -234,8 +279,10 @@ public class VTooltip extends VWindowOverlay { // already about to close return; } - closeTimer.schedule(getCloseTimeout()); - closing = true; + if (isActuallyVisible()) { + closeTimer.schedule(getCloseTimeout()); + closing = true; + } } @Override @@ -311,11 +358,9 @@ public class VTooltip extends VWindowOverlay { * @return TooltipInfo if connector and tooltip found, null if not */ private TooltipInfo getTooltipFor(Element element) { - ApplicationConnection ac = getApplicationConnection(); ComponentConnector connector = Util.getConnectorForElement(ac, RootPanel.get(), element); - // Try to find first connector with proper tooltip info TooltipInfo info = null; while (connector != null) { @@ -348,8 +393,6 @@ public class VTooltip extends VWindowOverlay { /** * Handle hide event * - * @param event - * Event causing hide */ private void handleHideEvent() { hideTooltip(); @@ -402,12 +445,26 @@ public class VTooltip extends VWindowOverlay { return; } + // If the parent (sub)component already has a tooltip open and it + // hasn't changed, we ignore the event. + // TooltipInfo contains a reference to the parent component that is + // checked in it's equals-method. + if (currentElement != null && isActuallyVisible()) { + TooltipInfo currentTooltip = getTooltipFor(currentElement); + TooltipInfo newTooltip = getTooltipFor(element); + if (currentTooltip != null && currentTooltip.equals(newTooltip)) { + return; + } + } + TooltipInfo info = getTooltipFor(element); if (info == null) { - if (isActuallyVisible()) { - handleHideEvent(); - } + handleHideEvent(); } else { + if (closing) { + closeTimer.cancel(); + closing = false; + } setTooltipText(info); updatePosition(event, isFocused); if (isActuallyVisible() && !isFocused) { @@ -417,8 +474,7 @@ public class VTooltip extends VWindowOverlay { closeNow(); } // Schedule timer for showing the tooltip according to if it - // was - // recently closed or not. + // was recently closed or not. int timeout = justClosed ? getQuickOpenDelay() : getOpenDelay(); if (timeout == 0) { diff --git a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java index 1392a1a49a..62913400db 100644 --- a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java +++ b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java @@ -208,58 +208,55 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements } else if(rule.type == 1 || !rule.type) { // Regular selector rule - // IE parses CSS like .class[attr="val"] into [attr="val"].class so we need to check for both - - // Pattern for matching [width-range] selectors - var widths = IE? /\[width-range~?=["|'](.*)-(.*)["|']\]([\.|#]\S+)/i : /([\.|#]\S+)\[width-range~?=["|'](.*)-(.*)["|']\]/i; - - // Patter for matching [height-range] selectors - var heights = IE? /\[height-range~?=["|'](.*)-(.*)["|']\]([\.|#]\S+)/i : /([\.|#]\S+)\[height-range~?=["|'](.*)-(.*)["|']\]/i; + // Helper function + var pushToCache = function(ranges, selector, min, max) { + // Avoid adding duplicates + var duplicate = false; + for(var l = 0, len3 = ranges.length; l < len3; l++) { + var bp = ranges[l]; + if (selector == bp[0] && min == bp[1] && max == bp[2]) { + duplicate = true; + break; + } + } + if (!duplicate) { + ranges.push([selector, min, max]); + } + }; // Array of all of the separate selectors in this ruleset var haystack = rule.selectorText.split(","); + // IE parses CSS like .class[attr="val"] into [attr="val"].class so we need to check for both + var selectorRegEx = IE ? /\[.*\]([\.|#]\S+)/ : /([\.|#]\S+?)\[.*\]/; + // Loop all the selectors in this ruleset for(var k = 0, len2 = haystack.length; k < len2; k++) { - var result; - - // Check for width-range matches - if(result = haystack[k].match(widths)) { - var selector = IE? result[3] : result[1] - var min = IE? result[1] : result[2]; - var max = IE? result[2] : result[3]; - - // Avoid adding duplicates - var duplicate = false; - for(var l = 0, len3 = widthRanges.length; l < len3; l++) { - var bp = widthRanges[l]; - if(selector == bp[0] && min == bp[1] && max == bp[2]) { - duplicate = true; - break; - } - } - if(!duplicate) { - widthRanges.push([selector, min, max]); + + // Split the haystack into parts. + var widthRange = haystack[k].match(/\[width-range.*?\]/); + var heightRange = haystack[k].match(/\[height-range.*?\]/); + var selector = haystack[k].match(selectorRegEx); + + if (selector != null) { + selector = selector[1]; + + // Check for width-ranges. + if (widthRange != null) { + var minMax = widthRange[0].match(/\[width-range~?=["|'](.*?)-(.*?)["|']\]/i); + var min = minMax[1]; + var max = minMax[2]; + + pushToCache(widthRanges, selector, min, max); } - } - // Check for height-range matches - if(result = haystack[k].match(heights)) { - var selector = IE? result[3] : result[1] - var min = IE? result[1] : result[2]; - var max = IE? result[2] : result[3]; - - // Avoid adding duplicates - var duplicate = false; - for(var l = 0, len3 = heightRanges.length; l < len3; l++) { - var bp = heightRanges[l]; - if(selector == bp[0] && min == bp[1] && max == bp[2]) { - duplicate = true; - break; - } - } - if(!duplicate) { - heightRanges.push([selector, min, max]); + // Check for height-ranges. + if (heightRange != null) { + var minMax = heightRange[0].match(/\[height-range~?=["|'](.*?)-(.*?)["|']\]/i); + var min = minMax[1]; + var max = minMax[2]; + + pushToCache(heightRanges, selector, min, max); } } } diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index ccf070698b..c3f14be40c 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -333,14 +333,6 @@ public abstract class AbstractComponentConnector extends AbstractConnector AbstractComponentState state = getState(); String primaryStyleName = getWidget().getStylePrimaryName(); - if (state.primaryStyleName != null - && !state.primaryStyleName.equals(primaryStyleName)) { - /* - * We overwrite the widgets primary stylename if state defines a - * primary stylename. - */ - getWidget().setStylePrimaryName(state.primaryStyleName); - } // Set the core 'v' style name for the widget setWidgetStyleName(StyleConstants.UI_WIDGET, true); @@ -376,6 +368,16 @@ public abstract class AbstractComponentConnector extends AbstractConnector } } + + if (state.primaryStyleName != null + && !state.primaryStyleName.equals(primaryStyleName)) { + /* + * We overwrite the widgets primary stylename if state defines a + * primary stylename. This has to be done after updating other + * styles to be sure the dependent styles are updated correctly. + */ + getWidget().setStylePrimaryName(state.primaryStyleName); + } Profiler.leave("AbstractComponentConnector.updateWidgetStyleNames"); } diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 5ffa580371..a1de2c2b6d 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -30,6 +30,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Display; +import com.google.gwt.dom.client.Style.Overflow; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -212,6 +213,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, private final Element down = DOM.createDiv(); private final Element status = DOM.createDiv(); + private int desiredHeight = -1; + private boolean isPagingEnabled = true; private long lastAutoClosed; @@ -228,6 +231,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, debug("VFS.SP: constructor()"); setOwner(VFilterSelect.this); menu = new SuggestionMenu(); + menu.getElement().getStyle().setOverflowY(Overflow.AUTO); setWidget(menu); getElement().getStyle().setZIndex(Z_INDEX); @@ -550,16 +554,12 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, public void setPosition(int offsetWidth, int offsetHeight) { debug("VFS.SP: setPosition()"); - int top = -1; - int left = -1; + int top = getPopupTop(); + int left = getPopupLeft(); - // reset menu size and retrieve its "natural" size - menu.setHeight(""); - if (currentPage > 0) { - // fix height to avoid height change when getting to last page - menu.fixHeightTo(pageLength); + if (desiredHeight < 0) { + desiredHeight = offsetHeight; } - offsetHeight = getOffsetHeight(); final int desiredWidth = getMainWidth(); Element menuFirstChild = menu.getElement().getFirstChildElement(); @@ -585,16 +585,20 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, getContainerElement().getStyle().setWidth(rootWidth, Unit.PX); } - if (offsetHeight + getPopupTop() > Window.getClientHeight() - + Window.getScrollTop()) { + final int spaceAvailableBelow = Window.getClientHeight() + - (top - Window.getScrollTop()); + final int spaceAvailableAbove = top - Window.getScrollTop() + - VFilterSelect.this.getOffsetHeight(); + if (spaceAvailableBelow < desiredHeight + && spaceAvailableBelow < spaceAvailableAbove) { // popup on top of input instead - top = getPopupTop() - offsetHeight - - VFilterSelect.this.getOffsetHeight(); + top -= desiredHeight + VFilterSelect.this.getOffsetHeight(); + offsetHeight = desiredHeight; if (top < 0) { + offsetHeight += top; top = 0; } } else { - top = getPopupTop(); /* * Take popup top margin into account. getPopupTop() returns the * top value including the margin but the value we give must not @@ -602,6 +606,19 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ int topMargin = (top - topPosition); top -= topMargin; + offsetHeight = Math.min(desiredHeight, spaceAvailableBelow); + } + + /* + * Resize popup and menu if calculated height doesn't match the + * actual height + */ + if (getOffsetHeight() != offsetHeight) { + int menuHeight = offsetHeight - up.getOffsetHeight() + - down.getOffsetHeight() - status.getOffsetHeight(); + menu.setHeight(menuHeight + "px"); + getContainerElement().getStyle().setHeight(offsetHeight, + Unit.PX); } // fetch real width (mac FF bugs here due GWT popups overflow:auto ) @@ -614,8 +631,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, if (left < 0) { left = 0; } - } else { - left = getPopupLeft(); } setPopupPosition(left, top); } diff --git a/client/src/com/vaadin/client/ui/VGridLayout.java b/client/src/com/vaadin/client/ui/VGridLayout.java index 1c42243621..10e5c00a38 100644 --- a/client/src/com/vaadin/client/ui/VGridLayout.java +++ b/client/src/com/vaadin/client/ui/VGridLayout.java @@ -1,12 +1,12 @@ /* * 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 @@ -19,6 +19,7 @@ package com.vaadin.client.ui; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Set; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; @@ -71,6 +72,8 @@ public class VGridLayout extends ComplexPanel { /** For internal use only. May be removed or replaced in the future. */ public DivElement spacingMeasureElement; + public Set<Integer> explicitRowRatios; + public Set<Integer> explicitColRatios; public VGridLayout() { super(); @@ -92,7 +95,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the column widths measured in pixels - * + * * @return */ protected int[] getColumnWidths() { @@ -101,7 +104,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the row heights measured in pixels - * + * * @return */ protected int[] getRowHeights() { @@ -110,7 +113,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the spacing between the cells horizontally in pixels - * + * * @return */ protected int getHorizontalSpacing() { @@ -119,7 +122,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the spacing between the cells vertically in pixels - * + * * @return */ protected int getVerticalSpacing() { @@ -136,18 +139,20 @@ public class VGridLayout extends ComplexPanel { void expandRows() { if (!isUndefinedHeight()) { - int usedSpace = minRowHeights[0]; - int verticalSpacing = getVerticalSpacing(); - for (int i = 1; i < minRowHeights.length; i++) { - usedSpace += verticalSpacing + minRowHeights[i]; - } + int usedSpace = calcRowUsedSpace(); + int[] actualExpandRatio = calcRowExpandRatio(); int availableSpace = LayoutManager.get(client).getInnerHeight( getElement()); int excessSpace = availableSpace - usedSpace; int distributed = 0; if (excessSpace > 0) { + int expandRatioSum = 0; + for (int i = 0; i < rowHeights.length; i++) { + expandRatioSum += actualExpandRatio[i]; + } for (int i = 0; i < rowHeights.length; i++) { - int ew = excessSpace * rowExpandRatioArray[i] / 1000; + int ew = excessSpace * actualExpandRatio[i] + / expandRatioSum; rowHeights[i] = minRowHeights[i] + ew; distributed += ew; } @@ -162,44 +167,52 @@ public class VGridLayout extends ComplexPanel { } } - /** For internal use only. May be removed or replaced in the future. */ - public void updateHeight() { - // Detect minimum heights & calculate spans - detectRowHeights(); - - // Expand - expandRows(); - - // Position - layoutCellsVertically(); + private int[] calcRowExpandRatio() { + int[] actualExpandRatio = new int[minRowHeights.length]; + for (int i = 0; i < minRowHeights.length; i++) { + if (rowHasComponentsOrRowSpan(i)) { + actualExpandRatio[i] = rowExpandRatioArray[i]; + } else { + // Should not do this if this has explicitly been + // expanded + if (explicitRowRatios.contains(i)) { + actualExpandRatio[i] = rowExpandRatioArray[i]; + } else { + actualExpandRatio[i] = 0; + } + } + } + return actualExpandRatio; } - /** For internal use only. May be removed or replaced in the future. */ - public void updateWidth() { - // Detect widths & calculate spans - detectColWidths(); - // Expand - expandColumns(); - // Position - layoutCellsHorizontally(); - + private int calcRowUsedSpace() { + int usedSpace = minRowHeights[0]; + int verticalSpacing = getVerticalSpacing(); + for (int i = 1; i < minRowHeights.length; i++) { + if (rowHasComponentsOrRowSpan(i) || minRowHeights[i] > 0 + || explicitRowRatios.contains(i)) { + usedSpace += verticalSpacing + minRowHeights[i]; + } + } + return usedSpace; } void expandColumns() { if (!isUndefinedWidth()) { - int usedSpace = minColumnWidths[0]; - int horizontalSpacing = getHorizontalSpacing(); - for (int i = 1; i < minColumnWidths.length; i++) { - usedSpace += horizontalSpacing + minColumnWidths[i]; - } - + int usedSpace = calcColumnUsedSpace(); + int[] actualExpandRatio = calcColumnExpandRatio(); int availableSpace = LayoutManager.get(client).getInnerWidth( getElement()); int excessSpace = availableSpace - usedSpace; int distributed = 0; if (excessSpace > 0) { + int expandRatioSum = 0; + for (int i = 0; i < columnWidths.length; i++) { + expandRatioSum += actualExpandRatio[i]; + } for (int i = 0; i < columnWidths.length; i++) { - int ew = excessSpace * colExpandRatioArray[i] / 1000; + int ew = excessSpace * actualExpandRatio[i] + / expandRatioSum; columnWidths[i] = minColumnWidths[i] + ew; distributed += ew; } @@ -214,6 +227,97 @@ public class VGridLayout extends ComplexPanel { } } + /** + * Calculates column expand ratio. + */ + private int[] calcColumnExpandRatio() { + int[] actualExpandRatio = new int[minColumnWidths.length]; + for (int i = 0; i < minColumnWidths.length; i++) { + if (colHasComponentsOrColSpan(i)) { + actualExpandRatio[i] = colExpandRatioArray[i]; + } else { + // Should not do this if this has explicitly been + // expanded + if (explicitColRatios.contains(i)) { + actualExpandRatio[i] = colExpandRatioArray[i]; + } else { + actualExpandRatio[i] = 0; + } + } + } + return actualExpandRatio; + } + + /** + * Calculates column used space + */ + private int calcColumnUsedSpace() { + int usedSpace = minColumnWidths[0]; + int horizontalSpacing = getHorizontalSpacing(); + for (int i = 1; i < minColumnWidths.length; i++) { + if (colHasComponentsOrColSpan(i) || minColumnWidths[i] > 0 + || explicitColRatios.contains(i)) { + usedSpace += horizontalSpacing + minColumnWidths[i]; + } + } + return usedSpace; + } + + private boolean rowHasComponentsOrRowSpan(int i) { + for (Cell cell : widgetToCell.values()) { + if (cell.row == i) { + return true; + } + } + for (SpanList l : rowSpans) { + for (Cell cell : l.cells) { + if (cell.row >= i && i < cell.row + cell.rowspan) { + return true; + } + } + } + return false; + } + + private boolean colHasComponentsOrColSpan(int i) { + for (Cell cell : widgetToCell.values()) { + if (cell.col == i) { + return true; + } + } + for (SpanList l : colSpans) { + for (Cell cell : l.cells) { + if (cell.col >= i && i < cell.col + cell.colspan) { + return true; + } + } + } + return false; + } + + /** For internal use only. May be removed or replaced in the future. */ + public void updateHeight() { + // Detect minimum heights & calculate spans + detectRowHeights(); + + // Expand + expandRows(); + + // Position + layoutCellsVertically(); + } + + /** For internal use only. May be removed or replaced in the future. */ + public void updateWidth() { + // Detect widths & calculate spans + detectColWidths(); + // Expand + expandColumns(); + // Position + layoutCellsHorizontally(); + + } + void layoutCellsVertically() { int verticalSpacing = getVerticalSpacing(); LayoutManager layoutManager = LayoutManager.get(client); @@ -241,7 +345,9 @@ public class VGridLayout extends ComplexPanel { cell.layoutVertically(y, reservedMargin); } - y += rowHeights[row] + verticalSpacing; + if (rowHasComponentsOrRowSpan(row) || rowHeights[row] > 0) { + y += rowHeights[row] + verticalSpacing; + } } } @@ -277,7 +383,9 @@ public class VGridLayout extends ComplexPanel { cell.layoutHorizontally(x, reservedMargin); } } - x += columnWidths[i] + horizontalSpacing; + if (colHasComponentsOrColSpan(i) || columnWidths[i] > 0) { + x += columnWidths[i] + horizontalSpacing; + } } if (isUndefinedWidth()) { @@ -602,7 +710,6 @@ public class VGridLayout extends ComplexPanel { - childComponentData.column1; // Set cell height rowspan = 1 + childComponentData.row2 - childComponentData.row1; - setAlignment(new AlignmentInfo(childComponentData.alignment)); } @@ -644,7 +751,7 @@ public class VGridLayout extends ComplexPanel { * Creates a new Cell with the given coordinates. * <p> * For internal use only. May be removed or replaced in the future. - * + * * @param row * @param col * @return @@ -660,7 +767,7 @@ public class VGridLayout extends ComplexPanel { * child component is also returned if "element" is part of its caption. * <p> * For internal use only. May be removed or replaced in the future. - * + * * @param element * An element that is a nested sub element of the root element in * this layout @@ -681,13 +788,13 @@ public class VGridLayout extends ComplexPanel { * child component is also returned if "element" is part of its caption. * <p> * For internal use only. May be removed or replaced in the future. - * + * * @param element * An element that is a nested sub element of the root element in * this layout * @return The Paintable which the element is a part of. Null if the element * belongs to the layout and not to a child. - * + * * @since 7.2 */ public ComponentConnector getComponent(Element element) { diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java index f17ffbefed..11fda6222c 100644 --- a/client/src/com/vaadin/client/ui/VMenuBar.java +++ b/client/src/com/vaadin/client/ui/VMenuBar.java @@ -1034,7 +1034,7 @@ public class VMenuBar extends SimpleFocusablePanel implements return null; } - return new TooltipInfo(description); + return new TooltipInfo(description, null, this); } /** diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index d6eec66561..d3317abd4d 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -5157,7 +5157,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, String rowDescription = uidl.getStringAttribute("rowdescr"); if (rowDescription != null && !rowDescription.equals("")) { - tooltipInfo = new TooltipInfo(rowDescription); + tooltipInfo = new TooltipInfo(rowDescription, null, this); } else { tooltipInfo = null; } @@ -5430,7 +5430,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private void setTooltip(TableCellElement td, String description) { if (description != null && !description.equals("")) { - TooltipInfo info = new TooltipInfo(description); + TooltipInfo info = new TooltipInfo(description, null, this); cellToolTips.put(td, info); } else { cellToolTips.remove(td); diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 3f2d90b721..15d9c83c49 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -329,7 +329,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, private boolean update(TabState tabState) { if (tabState.description != null || tabState.componentError != null) { setTooltipInfo(new TooltipInfo(tabState.description, - tabState.componentError)); + tabState.componentError, this)); } else { setTooltipInfo(null); } diff --git a/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java b/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java index 67220e5c36..786bd18bf9 100644 --- a/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java @@ -1,12 +1,12 @@ /* * 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 @@ -119,9 +119,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector layout.rowExpandRatioArray = uidl.getIntArrayAttribute("rowExpand"); layout.updateMarginStyleNames(new MarginInfo(getState().marginsBitmask)); - layout.updateSpacingStyleName(getState().spacing); - getLayoutManager().setNeedsLayout(this); } @@ -171,7 +169,8 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector layout.columnWidths = new int[cols]; layout.rowHeights = new int[rows]; - + layout.explicitRowRatios = getState().explicitRowRatios; + layout.explicitColRatios = getState().explicitColRatios; layout.setSize(rows, cols); } diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java index c57430b3b4..55224b455f 100644 --- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java +++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java @@ -269,7 +269,8 @@ public class TreeConnector extends AbstractComponentConnector implements String description = uidl.getStringAttribute("descr"); if (description != null) { - tooltipMap.put(treeNode, new TooltipInfo(description)); + tooltipMap.put(treeNode, new TooltipInfo(description, null, + treeNode)); } if (uidl.getBooleanAttribute("expanded") && !treeNode.getState()) { diff --git a/eclipse/Development Mode (vaadin).launch b/eclipse/Development Mode (vaadin).launch index e8a8ee09c1..8c828eca96 100644 --- a/eclipse/Development Mode (vaadin).launch +++ b/eclipse/Development Mode (vaadin).launch @@ -12,21 +12,16 @@ <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/vaadin/shared/src" path="3" type="2"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/vaadin/client/src" path="3" type="2"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/vaadin/uitest/src" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="gwt-dev" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="gwt-user" type="1"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2.jar" path="3" type="3"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="GWT_TOOLS/lib/junit/junit-4.8.2.jar" path="3" type="3"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="GWT_TOOLS/lib/tomcat/servlet-api-2.5.jar" path="3" type="3"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="GWT_TOOLS/lib/javax/validation/validation-api-1.0.0.GA.jar" path="3" type="3"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="GWT_TOOLS/lib/javax/validation/validation-api-1.0.0.GA-sources.jar" path="3" type="3"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-dev/core/src" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-dev/core/super" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/src" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/super" path="3" type="2"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&amp;ivyXmlPath=client%2Fivy.xml&amp;confs=ide&amp;ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=" javaProject="vaadin" path="3" type="4"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&amp;ivyXmlPath=server%2Fivy.xml&amp;confs=ide&amp;ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=" javaProject="vaadin" path="3" type="4"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&amp;ivyXmlPath=shared%2Fivy.xml&amp;confs=ide&amp;ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=" javaProject="vaadin" path="3" type="4"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&amp;ivyXmlPath=client-compiler%2Fivy.xml&amp;confs=ide&amp;ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=" javaProject="vaadin" path="3" type="4"/> "/> +<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&amp;ivyXmlPath=gwt%2Fivy.xml&amp;confs=ide&amp;ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=" javaProject="vaadin" path="3" type="4"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&amp;ivyXmlPath=uitest%2Fivy.xml&amp;confs=ide&amp;ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=" javaProject="vaadin" path="3" type="4"/> "/> </listAttribute> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> diff --git a/gwt-files.xml b/gwt-files.xml index a40d69806f..4a8486ab55 100644 --- a/gwt-files.xml +++ b/gwt-files.xml @@ -1,15 +1,20 @@ <?xml version="1.0"?> -<project name="GWT files for Vaadin" basedir="."> +<project name="GWT files for Vaadin" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant"> <include file="common.xml" as="common" /> - <property name="gwt.lib.dir" location="${gwt.basedir}/build/lib" /> + <ivy:resolve log="download-only" file="${vaadin.basedir}/gwt/ivy.xml" transitive="false" /> + <ivy:cachepath pathid="gwt-dev.classpath" conf="gwt-dev" /> + <ivy:cachepath pathid="gwt-user.classpath" conf="gwt-user" /> + <ivy:cachepath pathid="gwt-elemental.classpath" conf="gwt-elemental" /> + <ivy:cachepath pathid="gwt-codeserver.classpath" conf="gwt-codeserver" /> + <property name="gwt.eclipse.basedir" location="${gwt.basedir}/eclipse" /> - <property name="gwt.user.jar" location="${gwt.lib.dir}/gwt-user.jar" /> - <property name="gwt.dev.jar" location="${gwt.lib.dir}/gwt-dev.jar" /> - <property name="gwt.elemental.jar" location="${gwt.lib.dir}/gwt-elemental.jar" /> - <property name="gwt.codeserver.jar" location="${gwt.lib.dir}/gwt-codeserver.jar" /> + <property name="gwt.user.jar" refid="gwt-user.classpath" /> + <property name="gwt.dev.jar" refid="gwt-dev.classpath" /> + <property name="gwt.elemental.jar" refid="gwt-elemental.classpath" /> + <property name="gwt.codeserver.jar" refid="gwt-codeserver.classpath" /> <available file="${gwt.dev.jar}" property="gwt.dev.jar.found" /> <available file="${gwt.user.jar}" property="gwt.user.jar.found" /> diff --git a/gwt/ivy.xml b/gwt/ivy.xml new file mode 100644 index 0000000000..52d8acea92 --- /dev/null +++ b/gwt/ivy.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ivy-module version="2.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" + xmlns:m="http://ant.apache.org/ivy/maven"> + + <info organisation="com.vaadin" module="vaadin-gwt" + revision="${vaadin.version}" /> + + <configurations> + <conf name="build" /> + <conf name="gwt-dev" /> + <conf name="gwt-user" /> + <conf name="gwt-codeserver" /> + <conf name="gwt-elemental" /> + <conf name="ide" visibility="private" /> + </configurations> + <publications> + <artifact type="jar" ext="jar" /> + <artifact type="source" ext="jar" m:classifier="sources" /> + <artifact type="javadoc" ext="jar" m:classifier="javadoc" /> + <artifact type="pom" ext="pom" /> + </publications> + <dependencies> + <dependency org="com.vaadin.external.gwt" name="gwt-dev" rev="${gwt.version}" conf="gwt-dev,ide->default" /> + <dependency org="com.vaadin.external.gwt" name="gwt-user" rev="${gwt.version}" conf="gwt-user,ide->default" /> + <dependency org="com.vaadin.external.gwt" name="gwt-codeserver" rev="${gwt.version}" conf="gwt-codeserver,ide->default" /> + <dependency org="com.vaadin.external.gwt" name="gwt-elemental" rev="${gwt.version}" conf="gwt-elemental->default" /> + </dependencies> +</ivy-module> diff --git a/server/src/com/vaadin/server/JsonCodec.java b/server/src/com/vaadin/server/JsonCodec.java index 08345714fd..93074abcdb 100644 --- a/server/src/com/vaadin/server/JsonCodec.java +++ b/server/src/com/vaadin/server/JsonCodec.java @@ -27,7 +27,6 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.lang.reflect.WildcardType; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -435,21 +434,6 @@ public class JsonCodec implements Serializable { return new UidlValue(decodedValue); } - private static boolean transportTypesCompatible( - String encodedTransportType, String transportType) { - if (encodedTransportType == null) { - return false; - } - if (encodedTransportType.equals(transportType)) { - return true; - } - if (encodedTransportType.equals(JsonConstants.VTYPE_NULL)) { - return true; - } - - return false; - } - private static Map<Object, Object> decodeMap(Type targetType, boolean restrictToInternalTypes, Object jsonMap, ConnectorTracker connectorTracker) throws JSONException { @@ -588,7 +572,8 @@ public class JsonCodec implements Serializable { private static Object[] decodeObjectArray(Type targetType, JSONArray jsonArray, ConnectorTracker connectorTracker) throws JSONException { - List list = decodeList(List.class, true, jsonArray, connectorTracker); + List<Object> list = decodeList(List.class, true, jsonArray, + connectorTracker); return list.toArray(new Object[list.size()]); } @@ -644,80 +629,59 @@ public class JsonCodec implements Serializable { Type valueType, ConnectorTracker connectorTracker) throws JSONException { - if (valueType == null) { - throw new IllegalArgumentException("type must be defined"); - } - - if (valueType instanceof WildcardType) { - throw new IllegalStateException( - "Can not serialize type with wildcard: " + valueType); - } - if (null == value) { return ENCODE_RESULT_NULL; } - if (value instanceof String[]) { - String[] array = (String[]) value; - JSONArray jsonArray = new JSONArray(); - for (int i = 0; i < array.length; ++i) { - jsonArray.put(array[i]); - } - return new EncodeResult(jsonArray); - } else if (value instanceof String) { - return new EncodeResult(value); - } else if (value instanceof Boolean) { - return new EncodeResult(value); - } else if (value instanceof Number) { - return new EncodeResult(value); - } else if (value instanceof Character) { - // Character is not a Number - return new EncodeResult(value); + // Storing a single reference and only returning the EncodeResult at the + // end the method is much shorter in bytecode which allows inlining + Object toReturn; + + if (value instanceof String || value instanceof Boolean + || value instanceof Number || value instanceof Character + || value instanceof JSONArray || value instanceof JSONObject) { + // all JSON compatible types are returned as is. + toReturn = value; + } else if (value instanceof String[]) { + toReturn = toJsonArray((String[]) value); } else if (value instanceof Collection) { - Collection<?> collection = (Collection<?>) value; - JSONArray jsonArray = encodeCollection(valueType, collection, - connectorTracker); - return new EncodeResult(jsonArray); - } else if (valueType instanceof Class<?> - && ((Class<?>) valueType).isArray()) { - JSONArray jsonArray = encodeArrayContents( - ((Class<?>) valueType).getComponentType(), value, - connectorTracker); - return new EncodeResult(jsonArray); - } else if (valueType instanceof GenericArrayType) { - Type componentType = ((GenericArrayType) valueType) - .getGenericComponentType(); - JSONArray jsonArray = encodeArrayContents(componentType, value, + toReturn = encodeCollection(valueType, (Collection<?>) value, connectorTracker); - return new EncodeResult(jsonArray); } else if (value instanceof Map) { - Object jsonMap = encodeMap(valueType, (Map<?, ?>) value, - connectorTracker); - return new EncodeResult(jsonMap); + toReturn = encodeMap(valueType, (Map<?, ?>) value, connectorTracker); } else if (value instanceof Connector) { - Connector connector = (Connector) value; if (value instanceof Component && !(LegacyCommunicationManager .isComponentVisibleToClient((Component) value))) { + // an encoded null is cached, return it directly. return ENCODE_RESULT_NULL; } - return new EncodeResult(connector.getConnectorId()); + // Connectors are simply serialized as ID. + toReturn = ((Connector) value).getConnectorId(); } else if (value instanceof Enum) { - return encodeEnum((Enum<?>) value, connectorTracker); - } else if (value instanceof JSONArray || value instanceof JSONObject) { - return new EncodeResult(value); + toReturn = ((Enum<?>) value).name(); } else if (customSerializers.containsKey(value.getClass())) { - JSONSerializer serializer = customSerializers.get(value.getClass()); - return new EncodeResult(serializer.serialize(value, - connectorTracker)); + toReturn = serializeJson(value, connectorTracker); + } else if (valueType instanceof GenericArrayType) { + toReturn = encodeArrayContents( + ((GenericArrayType) valueType).getGenericComponentType(), + value, connectorTracker); } else if (valueType instanceof Class<?>) { - // Any object that we do not know how to encode we encode by looping - // through fields - return encodeObject(value, (Class<?>) valueType, - (JSONObject) diffState, connectorTracker); + if (((Class<?>) valueType).isArray()) { + toReturn = encodeArrayContents( + ((Class<?>) valueType).getComponentType(), value, + connectorTracker); + } else { + // encodeObject returns an EncodeResult with a diff, thus it + // needs to return it directly rather than assigning it to + // toReturn. + return encodeObject(value, (Class<?>) valueType, + (JSONObject) diffState, connectorTracker); + } } else { - throw new JSONException("Can not encode " + valueType); + throw new JSONException("Can not encode type " + valueType); } + return new EncodeResult(toReturn); } public static Collection<BeanProperty> getProperties(Class<?> type) @@ -737,6 +701,9 @@ public class JsonCodec implements Serializable { return properties; } + /* + * Loops through the fields of value and encodes them. + */ private static EncodeResult encodeObject(Object value, Class<?> valueType, JSONObject referenceValue, ConnectorTracker connectorTracker) throws JSONException { @@ -812,11 +779,6 @@ public class JsonCodec implements Serializable { } } - private static EncodeResult encodeEnum(Enum<?> e, - ConnectorTracker connectorTracker) throws JSONException { - return new EncodeResult(e.name()); - } - private static JSONArray encodeArrayContents(Type componentType, Object array, ConnectorTracker connectorTracker) throws JSONException { @@ -830,7 +792,7 @@ public class JsonCodec implements Serializable { } private static JSONArray encodeCollection(Type targetType, - Collection collection, ConnectorTracker connectorTracker) + Collection<?> collection, ConnectorTracker connectorTracker) throws JSONException { JSONArray jsonArray = new JSONArray(); for (Object o : collection) { @@ -898,6 +860,9 @@ public class JsonCodec implements Serializable { return new JSONArray(Arrays.asList(keys, values)); } + /* + * Encodes a connector map. Invisible connectors are skipped. + */ private static JSONObject encodeConnectorMap(Type valueType, Map<?, ?> map, ConnectorTracker connectorTracker) throws JSONException { JSONObject jsonMap = new JSONObject(); @@ -929,21 +894,27 @@ public class JsonCodec implements Serializable { return jsonMap; } - /** - * Gets the transport type for the given class. Returns null if no transport - * type can be found. - * - * @param valueType - * The type that should be transported - * @return - * @throws JSONException + /* + * These methods looks good to inline, but are on a cold path of the + * otherwise hot encode method, which needed to be shorted to allow inlining + * of the hot part. */ private static String getInternalTransportType(Type valueType) { return typeToTransportType.get(getClassForType(valueType)); } - private static String getCustomTransportType(Class<?> targetType) { - return targetType.getName(); + private static Object serializeJson(Object value, + ConnectorTracker connectorTracker) { + JSONSerializer serializer = customSerializers.get(value.getClass()); + return serializer.serialize(value, connectorTracker); + } + + private static JSONArray toJsonArray(String[] array) { + JSONArray jsonArray = new JSONArray(); + for (int i = 0; i < array.length; ++i) { + jsonArray.put(array[i]); + } + return jsonArray; } } diff --git a/server/src/com/vaadin/server/communication/ClientRpcWriter.java b/server/src/com/vaadin/server/communication/ClientRpcWriter.java index 1090fdbab9..181bfbb882 100644 --- a/server/src/com/vaadin/server/communication/ClientRpcWriter.java +++ b/server/src/com/vaadin/server/communication/ClientRpcWriter.java @@ -81,9 +81,9 @@ public class ClientRpcWriter implements Serializable { // + parameterType.getName()); // } // } - EncodeResult encodeResult = JsonCodec.encode( - invocation.getParameters()[i], referenceParameter, - parameterType, ui.getConnectorTracker()); + EncodeResult encodeResult = JsonCodec.encode(invocation.getParameters()[i], + referenceParameter, parameterType, + ui.getConnectorTracker()); paramJson.put(encodeResult.getEncodedValue()); } invocationJson.put(paramJson); diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java index 7ab7732079..e98b1e1b31 100644 --- a/server/src/com/vaadin/ui/DateField.java +++ b/server/src/com/vaadin/ui/DateField.java @@ -152,7 +152,8 @@ public class DateField extends AbstractField<Date> implements private String dateOutOfRangeMessage = "Date is out of allowed range"; private DateRangeValidator currentRangeValidator; - { + + static { variableNameForResolution.put(Resolution.SECOND, "sec"); variableNameForResolution.put(Resolution.MINUTE, "min"); variableNameForResolution.put(Resolution.HOUR, "hour"); diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 00e50aafc4..989f5efdea 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -1,12 +1,12 @@ /* * 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 @@ -39,12 +39,12 @@ import com.vaadin.shared.ui.gridlayout.GridLayoutState.ChildComponentData; /** * A layout where the components are laid out on a grid using cell coordinates. - * + * * <p> * The GridLayout also maintains a cursor for adding components in * left-to-right, top-to-bottom order. * </p> - * + * * <p> * Each component in a <code>GridLayout</code> uses a defined * {@link GridLayout.Area area} (column1,row1,column2,row2) from the grid. The @@ -52,12 +52,12 @@ import com.vaadin.shared.ui.gridlayout.GridLayoutState.ChildComponentData; * you will get an {@link OverlapsException}. Adding a component with cursor * automatically extends the grid by increasing the grid height. * </p> - * + * * <p> * The grid coordinates, which are specified by a row and column index, always * start from 0 for the topmost row and the leftmost column. * </p> - * + * * @author Vaadin Ltd. * @since 3.0 */ @@ -96,10 +96,10 @@ public class GridLayout extends AbstractLayout implements /** * Constructor for a grid of given size (number of columns and rows). - * + * * The grid may grow or shrink later. Grid grows automatically if you add * components outside its area. - * + * * @param columns * Number of columns in the grid. * @param rows @@ -121,9 +121,9 @@ public class GridLayout extends AbstractLayout implements /** * Constructs a GridLayout of given size (number of columns and rows) and * adds the given components in order to the grid. - * + * * @see #addComponents(Component...) - * + * * @param columns * Number of columns in the grid. * @param rows @@ -147,13 +147,13 @@ public class GridLayout extends AbstractLayout implements * by specifying the upper left corner (column1, row1) and the lower right * corner (column2, row2) of the area. The coordinates are zero-based. * </p> - * + * * <p> * If the area overlaps with any of the existing components already present * in the grid, the operation will fail and an {@link OverlapsException} is * thrown. * </p> - * + * * @param component * the component to be added, not <code>null</code>. * @param column1 @@ -257,7 +257,7 @@ public class GridLayout extends AbstractLayout implements /** * Tests if the given area overlaps with any of the items already on the * grid. - * + * * @param area * the Area to be checked for overlapping. * @throws OverlapsException @@ -279,7 +279,7 @@ public class GridLayout extends AbstractLayout implements * the area.) End coordinates (SouthEast corner of the area) are the same as * column1,row1. The coordinates are zero-based. Component width and height * is 1. - * + * * @param component * the component to be added, not <code>null</code>. * @param column @@ -299,16 +299,16 @@ public class GridLayout extends AbstractLayout implements /** * Forces the next component to be added at the beginning of the next line. - * + * * <p> * Sets the cursor column to 0 and increments the cursor row by one. * </p> - * + * * <p> * By calling this function you can ensure that no more components are added * right of the previous component. * </p> - * + * * @see #space() */ public void newLine() { @@ -319,7 +319,7 @@ public class GridLayout extends AbstractLayout implements /** * Moves the cursor forward by one. If the cursor goes out of the right grid * border, it is moved to the first column of the next row. - * + * * @see #newLine() */ public void space() { @@ -335,7 +335,7 @@ public class GridLayout extends AbstractLayout implements * cursor position is already occupied, the cursor is moved forwards to find * free position. If the cursor goes out from the bottom of the grid, the * grid is automatically extended. - * + * * @param component * the component to be added, not <code>null</code>. */ @@ -371,7 +371,7 @@ public class GridLayout extends AbstractLayout implements /** * Removes the specified component from the layout. - * + * * @param component * the component to be removed. */ @@ -391,7 +391,7 @@ public class GridLayout extends AbstractLayout implements /** * Removes the component specified by its cell coordinates. - * + * * @param column * the component's column, starting from 0. * @param row @@ -414,7 +414,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets an Iterator for the components contained in the layout. By using the * Iterator it is possible to step through the contents of the layout. - * + * * @return the Iterator of the components inside the layout. */ @Override @@ -425,7 +425,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the number of components contained in the layout. Consistent with * the iterator returned by {@link #getComponentIterator()}. - * + * * @return the number of contained components */ @Override @@ -440,7 +440,7 @@ public class GridLayout extends AbstractLayout implements /** * Paints the contents of this component. - * + * * @param target * the Paint Event. * @throws PaintException @@ -497,7 +497,6 @@ public class GridLayout extends AbstractLayout implements if (columnExpandRatioArray.length > 0) { columnExpandRatioArray[0] -= realColExpandRatioSum - 1000; } - target.addAttribute("colExpand", columnExpandRatioArray); target.addAttribute("rowExpand", rowExpandRatioArray); @@ -532,17 +531,17 @@ public class GridLayout extends AbstractLayout implements /** * Defines a rectangular area of cells in a GridLayout. - * + * * <p> * Also maintains a reference to the component contained in the area. * </p> - * + * * <p> * The area is specified by the cell coordinates of its upper left corner * (column1,row1) and lower right corner (column2,row2). As otherwise with * GridLayout, the column and row coordinates start from zero. * </p> - * + * * @author Vaadin Ltd. * @since 3.0 */ @@ -554,7 +553,7 @@ public class GridLayout extends AbstractLayout implements * <p> * Construct a new area on a grid. * </p> - * + * * @param component * the component connected to the area. * @param column1 @@ -588,7 +587,7 @@ public class GridLayout extends AbstractLayout implements /** * Tests if this Area overlaps with another Area. - * + * * @param other * the other Area that is to be tested for overlap with this * area @@ -601,7 +600,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the component connected to the area. - * + * * @return the Component. */ public Component getComponent() { @@ -610,7 +609,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the column of the top-left corner cell. - * + * * @return the column of the top-left corner cell. */ public int getColumn1() { @@ -619,7 +618,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the column of the bottom-right corner cell. - * + * * @return the column of the bottom-right corner cell. */ public int getColumn2() { @@ -628,7 +627,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the row of the top-left corner cell. - * + * * @return the row of the top-left corner cell. */ public int getRow1() { @@ -637,7 +636,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the row of the bottom-right corner cell. - * + * * @return the row of the bottom-right corner cell. */ public int getRow2() { @@ -656,7 +655,7 @@ public class GridLayout extends AbstractLayout implements * Gridlayout does not support laying components on top of each other. An * <code>OverlapsException</code> is thrown when a component already exists * (even partly) at the same space on a grid with the new component. - * + * * @author Vaadin Ltd. * @since 3.0 */ @@ -666,7 +665,7 @@ public class GridLayout extends AbstractLayout implements /** * Constructs an <code>OverlapsException</code>. - * + * * @param existingArea */ public OverlapsException(Area existingArea) { @@ -701,7 +700,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the area . - * + * * @return the existing area. */ public Area getArea() { @@ -712,7 +711,7 @@ public class GridLayout extends AbstractLayout implements /** * An <code>Exception</code> object which is thrown when an area exceeds the * bounds of the grid. - * + * * @author Vaadin Ltd. * @since 3.0 */ @@ -723,7 +722,7 @@ public class GridLayout extends AbstractLayout implements /** * Constructs an <code>OoutOfBoundsException</code> with the specified * detail message. - * + * * @param areaOutOfBounds */ public OutOfBoundsException(Area areaOutOfBounds) { @@ -732,7 +731,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the area that is out of bounds. - * + * * @return the area out of Bound. */ public Area getArea() { @@ -743,7 +742,7 @@ public class GridLayout extends AbstractLayout implements /** * Sets the number of columns in the grid. The column count can not be * reduced if there are any areas that would be outside of the shrunk grid. - * + * * @param columns * the new number of columns in the grid. */ @@ -777,7 +776,7 @@ public class GridLayout extends AbstractLayout implements /** * Get the number of columns in the grid. - * + * * @return the number of columns in the grid. */ public int getColumns() { @@ -787,7 +786,7 @@ public class GridLayout extends AbstractLayout implements /** * Sets the number of rows in the grid. The number of rows can not be * reduced if there are any areas that would be outside of the shrunk grid. - * + * * @param rows * the new number of rows in the grid. */ @@ -821,7 +820,7 @@ public class GridLayout extends AbstractLayout implements /** * Get the number of rows in the grid. - * + * * @return the number of rows in the grid. */ public int getRows() { @@ -830,14 +829,14 @@ public class GridLayout extends AbstractLayout implements /** * Gets the current x-position (column) of the cursor. - * + * * <p> * The cursor position points the position for the next component that is * added without specifying its coordinates (grid cell). When the cursor * position is occupied, the next component will be added to first free * position after the cursor. * </p> - * + * * @return the grid column the cursor is on, starting from 0. */ public int getCursorX() { @@ -847,7 +846,7 @@ public class GridLayout extends AbstractLayout implements /** * Sets the current cursor x-position. This is usually handled automatically * by GridLayout. - * + * * @param cursorX */ public void setCursorX(int cursorX) { @@ -856,14 +855,14 @@ public class GridLayout extends AbstractLayout implements /** * Gets the current y-position (row) of the cursor. - * + * * <p> * The cursor position points the position for the next component that is * added without specifying its coordinates (grid cell). When the cursor * position is occupied, the next component will be added to the first free * position after the cursor. * </p> - * + * * @return the grid row the Cursor is on. */ public int getCursorY() { @@ -873,7 +872,7 @@ public class GridLayout extends AbstractLayout implements /** * Sets the current y-coordinate (row) of the cursor. This is usually * handled automatically by GridLayout. - * + * * @param cursorY * the row number, starting from 0 for the topmost row. */ @@ -957,7 +956,7 @@ public class GridLayout extends AbstractLayout implements /** * Inserts an empty row at the specified position in the grid. - * + * * @param row * Index of the row before which the new row will be inserted. * The leftmost row has index 0. @@ -991,18 +990,18 @@ public class GridLayout extends AbstractLayout implements /** * Removes a row and all the components in the row. - * + * * <p> * Components which span over several rows are removed if the selected row * is on the first row of such a component. * </p> - * + * * <p> * If the last row is removed then all remaining components will be removed * and the grid will be reduced to one row. The cursor will be moved to the * upper left cell of the grid. * </p> - * + * * @param row * Index of the row to remove. The leftmost row has index 0. */ @@ -1049,33 +1048,34 @@ public class GridLayout extends AbstractLayout implements /** * Sets the expand ratio of given column. - * + * * <p> * The expand ratio defines how excess space is distributed among columns. * Excess space means space that is left over from components that are not * sized relatively. By default, the excess space is distributed evenly. * </p> - * + * * <p> * Note that the component width of the GridLayout must be defined (fixed or * relative, as opposed to undefined) for this method to have any effect. * </p> - * + * * @see #setWidth(float, int) - * + * * @param columnIndex * @param ratio */ public void setColumnExpandRatio(int columnIndex, float ratio) { columnExpandRatio.put(columnIndex, ratio); + getState().explicitColRatios.add(columnIndex); markAsDirty(); } /** * Returns the expand ratio of given column - * + * * @see #setColumnExpandRatio(int, float) - * + * * @param columnIndex * @return the expand ratio, 0.0f by default */ @@ -1086,34 +1086,35 @@ public class GridLayout extends AbstractLayout implements /** * Sets the expand ratio of given row. - * + * * <p> * Expand ratio defines how excess space is distributed among rows. Excess * space means the space left over from components that are not sized * relatively. By default, the excess space is distributed evenly. * </p> - * + * * <p> * Note, that height needs to be defined (fixed or relative, as opposed to * undefined height) for this method to have any effect. * </p> - * + * * @see #setHeight(float, int) - * + * * @param rowIndex * The row index, starting from 0 for the topmost row. * @param ratio */ public void setRowExpandRatio(int rowIndex, float ratio) { rowExpandRatio.put(rowIndex, ratio); + getState().explicitRowRatios.add(rowIndex); markAsDirty(); } /** * Returns the expand ratio of given row. - * + * * @see #setRowExpandRatio(int, float) - * + * * @param rowIndex * The row index, starting from 0 for the topmost row. * @return the expand ratio, 0.0f by default @@ -1125,7 +1126,7 @@ public class GridLayout extends AbstractLayout implements /** * Gets the Component at given index. - * + * * @param x * The column index, starting from 0 for the leftmost column. * @param y @@ -1147,7 +1148,7 @@ public class GridLayout extends AbstractLayout implements /** * Returns information about the area where given component is laid in the * GridLayout. - * + * * @param component * the component whose area information is requested. * @return an Area object that contains information how component is laid in diff --git a/shared/build.xml b/shared/build.xml index 966d250d66..197f63c027 100644 --- a/shared/build.xml +++ b/shared/build.xml @@ -18,7 +18,7 @@ <path id="classpath.test.custom" /> <target name="jar"> - <property name="shared.osgi.import" value="org.json;version="0.0.20080701", com.google.gwt.thirdparty.guava.common.annotations;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.base;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.base.internal;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.cache;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.collect;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.eventbus;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.io;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.net;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.primitives;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.util.concurrent;version="10.0.1.rebased", com.google.gwt.thirdparty.streamhtmlparser;version="0.1.5.r10-rebased", com.google.gwt.thirdparty.streamhtmlparser.impl;version="0.1.5.r10-rebased", com.google.gwt.thirdparty.streamhtmlparser.util;version="0.1.5.r10-rebased", org.w3c.flute.parser;version="1.3.0.gg2", org.w3c.flute.parser.selectors;version="1.3.0.gg2", org.w3c.flute.util;version="1.3.0.gg2"" /> + <property name="shared.osgi.import" value="org.json;version="0.0.20131108.vaadin1", com.google.gwt.thirdparty.guava.common.annotations;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.base;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.base.internal;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.cache;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.collect;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.eventbus;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.io;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.net;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.primitives;version="16.0.1.vaadin1", com.google.gwt.thirdparty.guava.common.util.concurrent;version="16.0.1.vaadin1", com.google.gwt.thirdparty.streamhtmlparser;version="0.0.10.vaadin1", com.google.gwt.thirdparty.streamhtmlparser.impl;version="0.0.10.vaadin1", com.google.gwt.thirdparty.streamhtmlparser.util;version="0.0.10.vaadin1", org.w3c.flute.parser;version="1.3.0.gg2", org.w3c.flute.parser.selectors;version="1.3.0.gg2", org.w3c.flute.util;version="1.3.0.gg2"" /> <delete dir="${src.filtered}" /> <!-- Update version in Version.java --> <copy todir="${src.filtered}"> diff --git a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java index ad0f34c862..768183cf73 100644 --- a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java @@ -1,12 +1,12 @@ /* * 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 @@ -17,7 +17,9 @@ package com.vaadin.shared.ui.gridlayout; import java.io.Serializable; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import com.vaadin.shared.Connector; import com.vaadin.shared.ui.AbstractLayoutState; @@ -33,6 +35,9 @@ public class GridLayoutState extends AbstractLayoutState { public int rows = 0; public int columns = 0; public int marginsBitmask = 0; + // Set of indexes of implicitly Ratios rows and columns + public Set<Integer> explicitRowRatios = new HashSet<Integer>();; + public Set<Integer> explicitColRatios = new HashSet<Integer>(); public Map<Connector, ChildComponentData> childData = new HashMap<Connector, GridLayoutState.ChildComponentData>(); public static class ChildComponentData implements Serializable { @@ -41,5 +46,6 @@ public class GridLayoutState extends AbstractLayoutState { public int column2; public int row2; public int alignment = ALIGNMENT_DEFAULT.getBitMask(); + } } diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyle.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyle.java new file mode 100644 index 0000000000..1a15e7c5ae --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyle.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.abstractcomponent; + +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.Label; +import com.vaadin.ui.TextField; + +public class PrimaryStyle extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + // Use a set of three common components as a test. + final Label label = new Label("Test Label"); + label.setPrimaryStyleName("initial"); + label.setStyleName("state"); + addComponent(label); + + final Button button = new Button("Test Button"); + button.setPrimaryStyleName("initial"); + button.setStyleName("state"); + addComponent(button); + + final TextField tf = new TextField("Test TextField"); + tf.setPrimaryStyleName("initial"); + tf.setStyleName("state"); + addComponent(tf); + + Button updateButton = new Button("Update styles", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + label.setPrimaryStyleName("updated"); + label.setStyleName("correctly"); + + button.setPrimaryStyleName("updated"); + button.setStyleName("correctly"); + + tf.setPrimaryStyleName("updated"); + tf.setStyleName("correctly"); + } + }); + updateButton.setId("update-button"); + addComponent(updateButton); + } + + @Override + protected String getTestDescription() { + return "Test that setPrimaryStyleName followed by setStyleName results in correct class names."; + } + + @Override + protected Integer getTicketNumber() { + return 12190; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyleTest.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyleTest.java new file mode 100644 index 0000000000..ce99c4a3d5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyleTest.java @@ -0,0 +1,51 @@ +/* + * 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.abstractcomponent; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import com.vaadin.testbench.elements.ButtonElement; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PrimaryStyleTest extends MultiBrowserTest { + + @Test + public void testStyleNames() { + openTestURL(); + + // Verify the initial class names for all three components. + List<WebElement> initialElements = driver.findElements(By + .className("initial-state")); + assertThat(initialElements, hasSize(3)); + + // Click on a button that updates the styles. + $(ButtonElement.class).id("update-button").click(); + + // Verify that the class names where updated as expected. + List<WebElement> updatedElements = driver.findElements(By.className("updated-correctly")); + assertThat(updatedElements, hasSize(initialElements.size())); + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java new file mode 100644 index 0000000000..c50e483c44 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java @@ -0,0 +1,64 @@ +/* + * 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.combobox; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.VerticalLayout; + +/** + * Test UI for issue #11929 where ComboBox suggestion popup hides the ComboBox + * itself obscuring the text input field. + * + * @author Vaadin Ltd + */ +public class ComboBoxOnSmallScreen extends AbstractTestUI { + + private static final String PID = "captionPID"; + + @Override + protected void setup(VaadinRequest request) { + addComponents(createComboBox(), createComboBox()); + VerticalLayout vl = getLayout(); + vl.setHeight(300, Unit.PIXELS); + vl.setComponentAlignment(vl.getComponent(1), Alignment.BOTTOM_LEFT); + } + + @Override + protected String getTestDescription() { + return "Combobox hides what you are typing on small screen"; + } + + @Override + protected Integer getTicketNumber() { + return 11929; + } + + private ComboBox createComboBox() { + ComboBox cb = new ComboBox(); + cb.addContainerProperty(PID, String.class, ""); + cb.setItemCaptionPropertyId(PID); + + for (int i = 1; i < 21; ++i) { + final String v = "Item #" + i; + cb.getItem(cb.addItem()).getItemProperty(PID).setValue(v); + } + + return cb; + } +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java new file mode 100644 index 0000000000..c45168aa6d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java @@ -0,0 +1,108 @@ +/* + * 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.combobox; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebDriver.Window; +import org.openqa.selenium.WebElement; + +import com.vaadin.client.ui.VFilterSelect; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * ComboBox suggestion popup should not obscure the text input box. + * + * @author Vaadin Ltd + */ +public class ComboBoxOnSmallScreenTest extends MultiBrowserTest { + + private static final Dimension TARGETSIZE = new Dimension(600, 300); + private static final String POPUPCLASSNAME = VFilterSelect.CLASSNAME + + "-suggestpopup"; + + @Override + public void setup() throws Exception { + super.setup(); + + openTestURL(); + + getWindow().setSize(TARGETSIZE); + } + + @Test + public void testUpperSuggestionPopupOverlayPosition() { + ComboBoxElement cb = getComboBoxAndOpenPopup(0); + assertOverlayPosition(cb, getPopup()); + } + + @Test + public void testUpperSuggestionPopupOverlaySize() { + ComboBoxElement cb = getComboBoxAndOpenPopup(0); + assertOverlaySize(cb, getPopup()); + } + + @Test + public void testLowerSuggestionPopupOverlayPosition() { + ComboBoxElement cb = getComboBoxAndOpenPopup(1); + assertOverlayPosition(cb, getPopup()); + } + + @Test + public void testLowerSuggestionPopupOverlaySize() { + ComboBoxElement cb = getComboBoxAndOpenPopup(1); + assertOverlaySize(cb, getPopup()); + } + + private void assertOverlayPosition(WebElement combobox, WebElement popup) { + final int popupTop = popup.getLocation().y; + final int popupBottom = popupTop + popup.getSize().getHeight(); + final int cbTop = combobox.getLocation().y; + final int cbBottom = cbTop + combobox.getSize().getHeight(); + + assertThat("Popup overlay does not overlap with the textbox", + popupTop >= cbBottom || popupBottom <= cbTop, is(true)); + } + + private void assertOverlaySize(WebElement combobox, WebElement popup) { + final int popupTop = popup.getLocation().y; + final int popupBottom = popupTop + popup.getSize().getHeight(); + final int rootHeight = findElement(By.tagName("body")).getSize().height; + + assertThat("Popup overlay inside the viewport", popupTop < 0 + || popupBottom > rootHeight, is(false)); + } + + private ComboBoxElement getComboBoxAndOpenPopup(int comboboxIndex) { + ComboBoxElement cb = $(ComboBoxElement.class).get(comboboxIndex); + cb.openPopup(); + return cb; + } + + private WebElement getPopup() { + return findElement(By.className(POPUPCLASSNAME)); + } + + private Window getWindow() { + return getDriver().manage().window(); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html b/uitest/src/com/vaadin/tests/components/form/FormTooltips.html deleted file mode 100644 index 5e412c3aad..0000000000 --- a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html +++ /dev/null @@ -1,148 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888" /> -<title>FormTooltips</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">FormTooltips</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.form.FormTooltips?restartApplication</td> - <td></td> -</tr> -<!--first name tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Fields own tooltip</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--first name caption tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Fields own tooltip</td> -</tr> -<tr> - <td>mouseMove</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--Form should not have a description tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td> - <td>-1000</td> -</tr> -<!--Form error message should not have a tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td> - <td>-1000</td> -</tr> -<!--last name should have no tooltip--> -<tr> - <td>mouseMove</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--last name caption should have no tooltip--> -<tr> - <td>mouseMove</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.java b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java index b70f66c710..6e823204e9 100644 --- a/uitest/src/com/vaadin/tests/components/form/FormTooltips.java +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java @@ -31,6 +31,7 @@ public class FormTooltips extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { final Form form = new Form(); + form.setId("tooltipForm"); form.setDescription("Some description"); form.setItemDataSource(new BeanItem<Person>(new Person("foo", "bar", "baz", 12, Sex.MALE, null)), Arrays.asList(new String[] { diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java new file mode 100644 index 0000000000..df18d4082d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.form; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.FormElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.TooltipTest; + +public class FormTooltipsTest extends TooltipTest { + + @Test + public void testTooltipConfiguration() throws Exception { + openTestURL(); + // first name tooltip + + WebElement fieldElement = $(FormElement.class).first() + .$(TextFieldElement.class).first(); + checkTooltip(fieldElement, "Fields own tooltip"); + + moveToRoot(); + Thread.sleep(1000); + checkTooltipNotPresent(); + + // first name caption tooltip + checkTooltip( + $(FormElement.class).first().findElement( + By.className("v-caption")), "Fields own tooltip"); + + moveToRoot(); + Thread.sleep(1000); + checkTooltipNotPresent(); + + // Form should not have a description tooltip + checkTooltip($(FormElement.class).first(), null); + + // Form error message should not have a tooltip + checkTooltip(By.className("v-form-errormessage"), null); + + // last name should have no tooltip + checkTooltip($(TextFieldElement.class).get(1), null); + + // last name caption should have no tooltip + checkTooltip( + $(FormElement.class).first() + .findElements(By.className("v-caption")).get(1), null); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java new file mode 100644 index 0000000000..c20148743a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +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.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; + +public class GridLayoutExpandRatio extends AbstractTestUI { + HorizontalLayout layout; + GridLayout gridLayout; + GridLayout gridLayout2; + private static final int ROWS = 5; + private static final int COLS = 5; + private Label[][] labels; + + @Override + protected void setup(VaadinRequest request) { + + labels = new Label[ROWS][COLS]; + layout = new HorizontalLayout(); + gridLayout = new GridLayout(ROWS, COLS); + layout.setImmediate(true); + gridLayout.setImmediate(true); + gridLayout2 = new GridLayout(4, 4); + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + Label label = new Label("Slot " + i + " " + j); + label.setImmediate(true); + labels[i][j] = label; + gridLayout.addComponent(label, j, i); + if (!(i == 2 || j == 2)) { + Label label2 = new Label("Slot " + i + " " + j); + gridLayout2.addComponent(label2); + } + } + } + gridLayout.setHeight("500px"); + gridLayout.setWidth("500px"); + gridLayout.setSpacing(true); + + gridLayout2.setHeight("500px"); + gridLayout2.setWidth("500px"); + gridLayout2.setSpacing(true); + addComponent(layout); + HorizontalLayout space = new HorizontalLayout(); + space.setWidth("100px"); + layout.addComponent(gridLayout); + layout.addComponent(space); + layout.addComponent(gridLayout2); + + setExpandRatio(); + addComponent(new Button("Hide/show both middle Column and row", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + hideComponetns(); + } + })); + } + + private void hideComponetns() { + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + if (i == 2 || j == 2) { + if (labels[i][j].isVisible()) { + labels[i][j].setVisible(false); + } else { + labels[i][j].setVisible(true); + } + } + } + } + } + + private void setExpandRatio() { + gridLayout.setRowExpandRatio(2, 5); + gridLayout2.setRowExpandRatio(1, 5); + } + + @Override + protected Integer getTicketNumber() { + return 8855; + } + + @Override + protected String getTestDescription() { + return "If row/column doesn't have elements but have an expand ratio set, it should be shown as a empty row/column"; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java new file mode 100644 index 0000000000..7d5ad1fbc4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutExpandRatioTest extends MultiBrowserTest { + @Test + public void gridLayoutExpandRatioTest() { + openTestURL(); + GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); + GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); + ButtonElement hidingButton = $(ButtonElement.class).get(0); + hidingButton.click(); + List<WebElement> slots5x5 = gridLayout5x5.findElements(By + .className("v-gridlayout-slot")); + List<WebElement> slots4x4 = gridLayout4x4.findElements(By + .className("v-gridlayout-slot")); + assertEquals("Different amount of slots", slots5x5.size(), + slots4x4.size()); + for (int i = 0; i < slots5x5.size(); i++) { + WebElement compared = slots5x5.get(i); + WebElement actual = slots4x4.get(i); + assertEquals("Different top coordinate for element " + i, + compared.getCssValue("top"), actual.getCssValue("top")); + assertEquals("Different left coordinate for element " + i, + compared.getCssValue("left"), actual.getCssValue("left")); + } + } +} diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java new file mode 100644 index 0000000000..16b3742c64 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java @@ -0,0 +1,146 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import java.util.Random; + +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.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class GridLayoutHideMiddleCells extends AbstractTestUI { + GridLayout gridLayout; + GridLayout gridLayout2; + + @Override + protected void setup(VaadinRequest request) { + final int ROWS = 5; + final int COLS = 5; + + final Label[][] labels = new Label[ROWS][COLS]; + VerticalLayout mainLayout = new VerticalLayout(); + HorizontalLayout horLayout = new HorizontalLayout(); + gridLayout = new GridLayout(ROWS, COLS); + gridLayout2 = new GridLayout(4, 4); + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + Label label = new Label("Slot " + i + " " + j); + labels[i][j] = label; + gridLayout.addComponent(label); + if (!(i == 2 || j == 2)) { + Label label2 = new Label("Slot " + i + " " + j); + gridLayout2.addComponent(label2); + } + } + } + setContent(mainLayout); + gridLayout.setHeight("500px"); + gridLayout.setWidth("500px"); + gridLayout.setSpacing(true); + + addComponent(gridLayout); + addComponent(gridLayout2); + mainLayout.addComponent(horLayout); + gridLayout2.setHeight("500px"); + gridLayout2.setWidth("500px"); + gridLayout2.setSpacing(true); + horLayout.addComponent(gridLayout); + horLayout.addComponent(gridLayout2); + + mainLayout.addComponent(new Button( + "Hide/show both middle Column and row", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + if (j == 2 || i == 2) { + if (labels[i][j].isVisible()) { + labels[i][j].setVisible(false); + } else { + labels[i][j].setVisible(true); + } + } + } + } + } + })); + mainLayout.addComponent(new Button("Hide/show middle Column", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + for (int i = 0; i < ROWS; i++) { + if (labels[i][2].isVisible()) { + labels[i][2].setVisible(false); + } else { + labels[i][2].setVisible(true); + } + } + } + })); + mainLayout.addComponent(new Button("Hide/show middle Row", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + for (int j = 0; j < COLS; j++) { + if (labels[2][j].isVisible()) { + labels[2][j].setVisible(false); + } else { + labels[2][j].setVisible(true); + } + } + } + + })); + mainLayout.addComponent(new Button("Hide Random button", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + // TODO Auto-generated method stub + Random rand = new Random(); + int i = rand.nextInt(ROWS); + int j = rand.nextInt(COLS); + if (labels[i][j].isVisible()) { + labels[i][j].setVisible(false); + } else { + labels[i][j].setVisible(true); + } + } + })); + } + + @Override + protected Integer getTicketNumber() { + return 8855; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Changing the number of visible fields a GridLayout with spacing should not cause additional empty space on the place of invisible fields"; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java new file mode 100644 index 0000000000..d0225275f7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutHideMiddleCellsTest extends MultiBrowserTest { + @Test + public void gridLayoutInvisibleElementsTest() { + openTestURL(); + GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); + GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); + ButtonElement hidingButton = $(ButtonElement.class).get(0); + hidingButton.click(); + List<WebElement> slots5x5 = gridLayout5x5.findElements(By + .className("v-gridlayout-slot")); + List<WebElement> slots4x4 = gridLayout4x4.findElements(By + .className("v-gridlayout-slot")); + assertEquals("Different amount of slots", slots5x5.size(), + slots4x4.size()); + + for (int i = 0; i < slots5x5.size(); i++) { + assertEquals("Different left coordinate for element " + i, slots5x5 + .get(i).getCssValue("left"), + slots4x4.get(i).getCssValue("left")); + } + for (int i = 0; i < slots5x5.size(); i++) { + assertEquals("Different top coordinate for element " + i, slots5x5 + .get(i).getCssValue("top"), + slots4x4.get(i).getCssValue("top")); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html b/uitest/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html deleted file mode 100644 index f7c57baf1f..0000000000 --- a/uitest/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html +++ /dev/null @@ -1,122 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.menubar.MenuBarToolTips?restartApplication</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item0</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>File menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item0</td> - <td>18,11</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VOverlay[0]/VMenuBar[0]#item0</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>File - Foo menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/domChild[1]</td> - <td>830,200</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item1</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Edit menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/domChild[1]</td> - <td>625,184</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item1</td> - <td>9,6</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VOverlay[0]/VMenuBar[0]#item1</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Edit - Bar menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdge.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdge.java new file mode 100644 index 0000000000..4e42d97925 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdge.java @@ -0,0 +1,96 @@ +/* + * 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.menubar; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Component; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.Command; +import com.vaadin.ui.MenuBar.MenuItem; +import com.vaadin.ui.VerticalLayout; + +/** + * Test to see if tooltips will render in the correct locations near the edges. + * + * @author Vaadin Ltd + */ +public class MenuBarTooltipsNearEdge extends AbstractTestUI { + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + VerticalLayout vlayout = new VerticalLayout(); + vlayout.setSizeFull(); + vlayout.addComponent(buildMenu("Menu")); + vlayout.setComponentAlignment(vlayout.getComponent(0), + Alignment.BOTTOM_RIGHT); + setContent(vlayout); + + getTooltipConfiguration().setOpenDelay(0); + getTooltipConfiguration().setQuickOpenDelay(0); + getTooltipConfiguration().setCloseTimeout(1000); + + } + + private Component buildMenu(String label) { + MenuBar menu = new MenuBar(); + MenuItem item = menu.addItem(label, null); + + item.addItem("Item 1", null).setDescription("TOOLTIP 1"); + item.addItem("Item 2", null).setDescription("TOOLTIP 2"); + item.addItem("Item 3", null).setDescription("TOOLTIP 3"); + item.addItem("Item 4", null).setDescription("TOOLTIP 4"); + + return menu; + } + + private Command buildCommand() { + Command command = new Command() { + + @Override + public void menuSelected(MenuItem selectedItem) { + + } + }; + return command; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Menu item tooltips should not abscure other menu items"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12870; + } +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java new file mode 100644 index 0000000000..3cfe30a991 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java @@ -0,0 +1,64 @@ +/* + * 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.menubar; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test to see if tooltips will render in the correct locations near the edges. + * + * @author Vaadin Ltd + */ +public class MenuBarTooltipsNearEdgeTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // Tooltip tests work unreliably on IE due to an issue with the + // WebDriver (see #13854) + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + browsers.remove(Browser.IE8.getDesiredCapabilities()); + return browsers; + }; + + @Test + public void testTooltipLocation() { + openTestURL(); + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + WebElement menu = $(MenuBarElement.class).first().getWrappedElement(); + Coordinates menuLocation = ((Locatable) menu).getCoordinates(); + mouse.click(menuLocation); + mouse.mouseMove(menuLocation, 5, -40); + WebElement tooltip = getTooltipElement(); + assertThat(tooltip.getLocation().x, is(lessThan(menuLocation.onPage().x + - tooltip.getSize().getWidth()))); + + } +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java new file mode 100644 index 0000000000..2c9d43290f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java @@ -0,0 +1,88 @@ +/* + * 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.menubar; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.Command; +import com.vaadin.ui.MenuBar.MenuItem; + +/** + * Test to see if tooltips on menu items obscure other items on the menu. + * + * @author Vaadin Ltd + */ +public class MenuTooltip extends AbstractTestUI { + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + + addComponent(buildMenu()); + + getTooltipConfiguration().setOpenDelay(2000); + + } + + private Component buildMenu() { + MenuBar menu = new MenuBar(); + MenuItem item = menu.addItem("Menu", null); + + item.addItem("Item 1", null).setDescription("TOOLTIP 1"); + item.addItem("Item 2", null).setDescription("TOOLTIP 2"); + item.addItem("Item 3", null).setDescription("TOOLTIP 3"); + item.addItem("Item 4", null).setDescription("TOOLTIP 4"); + + return menu; + } + + private Command buildCommand() { + Command command = new Command() { + + @Override + public void menuSelected(MenuItem selectedItem) { + + } + }; + return command; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Menu item tooltips should not abscure other menu items"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 13914; + } +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java new file mode 100644 index 0000000000..bb8f87daaa --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java @@ -0,0 +1,68 @@ +/* + * 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.menubar; + +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test to see if tooltips on menu items obscure other items on the menu. + * + * @author Vaadin Ltd + */ +public class MenuTooltipTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return getBrowsersExcludingIE(); + } + + @Test + public void testToolTipDelay() throws InterruptedException { + openTestURL(); + + Coordinates elementCoordinates = getCoordinates($(MenuBarElement.class).first()); + + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + + mouse.click(elementCoordinates); + mouse.mouseMove(elementCoordinates, 15, 40); + + sleep(1000); + + assertThat(getTooltipElement().getLocation().getX(), + is(lessThan(-1000))); + + sleep(3000); + + assertThat(getTooltipElement().getLocation().getX(), + is(greaterThan(elementCoordinates.onPage().getX()))); + assertThat(getTooltipElement().getText(), is("TOOLTIP 1")); + } +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java new file mode 100644 index 0000000000..233049b0ba --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +/** + * + */ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class TooltipOnRequiredIndicator extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + + TextField inVertical = new TextField(); + inVertical.setRequired(true); + inVertical.setRequiredError("Vertical layout tooltip"); + inVertical.setCaption("Vertical layout caption"); + inVertical.setId("verticalField"); + + layout.addComponent(inVertical); + addComponent(layout); + + HorizontalLayout horizontalLayout = new HorizontalLayout(); + + TextField inHorizontal = new TextField(); + inHorizontal.setRequired(true); + inHorizontal.setRequiredError("Horizontal layout tooltip"); + inHorizontal.setCaption("Horizontal layout caption"); + inHorizontal.setId("horizontalField"); + + horizontalLayout.addComponent(inHorizontal); + layout.addComponent(horizontalLayout); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Show tooltip for caption and required indicator"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 10046; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java new file mode 100644 index 0000000000..815c00bfac --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.orderedlayout; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.HorizontalLayoutElement; +import com.vaadin.testbench.elements.VerticalLayoutElement; +import com.vaadin.tests.tb3.TooltipTest; + +public class TooltipOnRequiredIndicatorTest extends TooltipTest { + + @Test + public void testTooltipOnRequiredIndicator() throws Exception { + openTestURL(); + + // gwt-uid-* are not stable across browsers etc. so need to look them up + + // caption + checkTooltip( + $(VerticalLayoutElement.class).get(1).findElement( + By.className("v-captiontext")), + "Vertical layout tooltip"); + // required indicator + checkTooltip(By.className("v-required-field-indicator"), + "Vertical layout tooltip"); + + // caption + checkTooltip( + $(HorizontalLayoutElement.class).first().findElement( + By.className("v-captiontext")), + "Horizontal layout tooltip"); + // required indicator + checkTooltip( + $(HorizontalLayoutElement.class).first().findElement( + By.className("v-required-field-indicator")), + "Horizontal layout tooltip"); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html index 806e7d1b44..6014f557e7 100644 --- a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html +++ b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html @@ -64,7 +64,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> + <td>-5000</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html index 2df9fb678c..4c2dec9784 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html +++ b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html @@ -46,7 +46,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -77,7 +77,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -108,7 +108,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Cell and row tooltips--> <tr> @@ -145,7 +145,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -176,7 +176,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -207,7 +207,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Row and Component tooltips--> <tr> @@ -249,7 +249,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -280,7 +280,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -311,7 +311,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Row tooltips--> <tr> @@ -348,7 +348,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -379,7 +379,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -410,7 +410,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html deleted file mode 100644 index 338e4a2c5b..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html +++ /dev/null @@ -1,146 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>TooltipConfiguration</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">TooltipConfiguration</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.ui.TooltipConfiguration?restartApplication</td> - <td></td> -</tr> -<!--Short close delay--> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>0</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>This is a short tooltip</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--Long close delay--> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>3000</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td>0,0</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>This is a short tooltip</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td></td> -</tr> -<tr> - <td>assertElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>60,9</td> -</tr> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>0</td> -</tr> -<!--Max width 500--> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertElementWidth</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>500</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td></td> -</tr> -<!--Max width 100--> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SMax width</td> - <td>100</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td>0,0</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertElementWidth</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>100</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java index 4d201d2a1a..eeea91b638 100644 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java +++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java @@ -32,8 +32,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { closeTimeout.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setCloseTimeout( - (Integer) closeTimeout.getConvertedValue()); + if (closeTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setCloseTimeout( + (Integer) closeTimeout.getConvertedValue()); + } } }); maxWidth = createIntegerTextField("Max width", @@ -41,8 +43,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { maxWidth.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setMaxWidth( - (Integer) maxWidth.getConvertedValue()); + if (maxWidth.getConvertedValue() != null) { + getTooltipConfiguration().setMaxWidth( + (Integer) maxWidth.getConvertedValue()); + } } }); openDelay = createIntegerTextField("Open delay", @@ -50,8 +54,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { openDelay.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setOpenDelay( - (Integer) openDelay.getConvertedValue()); + if (openDelay.getConvertedValue() != null) { + getTooltipConfiguration().setOpenDelay( + (Integer) openDelay.getConvertedValue()); + } } }); @@ -61,8 +67,11 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { .addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setQuickOpenDelay( - (Integer) quickOpenDelay.getConvertedValue()); + if (quickOpenDelay.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenDelay( + (Integer) quickOpenDelay + .getConvertedValue()); + } } }); @@ -72,8 +81,11 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { .addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setQuickOpenTimeout( - (Integer) quickOpenTimeout.getConvertedValue()); + if (quickOpenTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenTimeout( + (Integer) quickOpenTimeout + .getConvertedValue()); + } } }); @@ -91,6 +103,8 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { tf.setConverter(Integer.class); tf.setImmediate(true); tf.setConvertedValue(initialValue); + // makes TB3 tests simpler - no "null" added when clearing a field + tf.setNullRepresentation(""); return tf; } diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java new file mode 100644 index 0000000000..f3e7554579 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import java.util.NoSuchElementException; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TooltipConfigurationTest extends MultiBrowserTest { + + private org.openqa.selenium.By tooltipBy = By + .vaadin("Root/VTooltip[0]/FlowPanel[0]/domChild[1]"); + + @Test + public void testTooltipConfiguration() throws Exception { + openTestURL(); + + WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); + WebElement closeTimeout = vaadinElementById("Close timeout"); + WebElement shortTooltip = vaadinElementById("shortTooltip"); + WebElement longTooltip = vaadinElementById("longTooltip"); + WebElement maxWidth = vaadinElementById("Max width"); + + selectAndType(closeTimeout, "0"); + testBenchElement(shortTooltip).showTooltip(); + waitForElementToBePresent(tooltipBy); + Assert.assertEquals("This is a short tooltip", getTooltip().getText()); + + new Actions(getDriver()).moveToElement(uiRoot, 0, 0).click().perform(); + // uiRoot.click(); + checkTooltipNotPresent(); + + selectAndType(closeTimeout, "3000"); + moveMouseToTopLeft(uiRoot); + testBenchElement(shortTooltip).showTooltip(); + waitForElementToBePresent(tooltipBy); + WebElement tooltip2 = getTooltip(); + Assert.assertEquals("This is a short tooltip", tooltip2.getText()); + + uiRoot.click(); + // assert that tooltip is present + getTooltip(); + selectAndType(closeTimeout, "0"); + testBenchElement(longTooltip).showTooltip(); + waitForElementToBePresent(tooltipBy); + Assert.assertEquals(500, getTooltip().getSize().getWidth()); + + uiRoot.click(); + selectAndType(maxWidth, "100"); + moveMouseToTopLeft(uiRoot); + testBenchElement(longTooltip).showTooltip(); + Assert.assertEquals(100, getTooltip().getSize().getWidth()); + } + + private WebElement getTooltip() { + return getDriver().findElement(tooltipBy); + } + + private void checkTooltipNotPresent() { + try { + WebElement tooltip = getTooltip(); + if (!"".equals(tooltip.getText()) + || tooltip.getLocation().getX() > -999) { + Assert.fail("Found tooltip that shouldn't be visible: " + + tooltip.getText() + " at " + tooltip.getLocation()); + } + } catch (NoSuchElementException e) { + Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools"); + } + } + + private void selectAndType(WebElement element, String value) { + // select and replace text + element.clear(); + // if null representation not set as "", need to move cursor to end and + // remove text "null" + // element.sendKeys("" + Keys.BACK_SPACE + Keys.BACK_SPACE + // + Keys.BACK_SPACE + Keys.BACK_SPACE); + element.sendKeys(value + Keys.ENTER); + } + + private void moveMouseToTopLeft(WebElement element) { + new Actions(getDriver()).moveToElement(element, 0, 0).perform(); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java index 06fb659d4a..412fd3049d 100644 --- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java +++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java @@ -74,10 +74,6 @@ public class TooltipInWindowTest extends MultiBrowserTest { } - private WebElement getTooltipElement() { - return getDriver().findElement(By.className("v-tooltip-text")); - } - private WebElement getTooltipContainerElement() { return getDriver().findElement(By.className("v-tooltip")); } diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeight.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeight.java new file mode 100644 index 0000000000..1c3acbec8d --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeight.java @@ -0,0 +1,50 @@ +/* + * 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.annotations.Theme; +import com.vaadin.server.Responsive; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.Label; + +@Theme("tests-responsive") +public class ResponsiveWidthAndHeight extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + CssLayout layout = new CssLayout(); + layout.addStyleName("width-and-height"); + layout.setSizeFull(); + setContent(layout); + Responsive.makeResponsive(layout); + + layout.addComponent(new Label( + "Resize the browser window in both dimensions to see the background color change.")); + } + + @Override + protected String getTestDescription() { + return "The CssLayout with both width-range and height-range defined"; + } + + @Override + protected Integer getTicketNumber() { + return 13587; + } +} diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeightTest.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeightTest.java new file mode 100644 index 0000000000..8086457c24 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeightTest.java @@ -0,0 +1,64 @@ +/* + * 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 org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.CssLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ResponsiveWidthAndHeightTest 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); + } + + @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"))); + + // 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")); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java deleted file mode 100644 index c96d542a4c..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import com.vaadin.ui.Layout; - -public abstract class AbstractLayoutTests { - - protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png"; - protected static final String CALENDAR_32_PNG = "../runo/icons/32/calendar.png"; - protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png"; - protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png"; - - abstract protected Layout getCaptionsTests(); - - abstract protected Layout getIconsTests(); - - abstract protected Layout getRequiredErrorIndicatorsTests(); - - abstract protected Layout getAlignmentTests(); - - abstract protected Layout getExpandRatiosTests(); - - abstract protected Layout getMarginSpacingTests(); - - abstract protected Layout getComponentAddReplaceMoveTests(); - - abstract protected Layout getComponentSizingTests(); - - abstract protected Layout getLayoutSizingTests(); - -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java new file mode 100644 index 0000000000..7ea8739cf4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java @@ -0,0 +1,109 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseAddReplaceMove extends BaseLayoutTestUI { + + /** + * @param layoutClass + */ + public BaseAddReplaceMove(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + // Set undefined height to avoid expanding + l2.setHeight(null); + // extra layout from which components will be moved + final HorizontalLayout source = new HorizontalLayout(); + source.addComponent(new Label("OTHER LABEL 1")); + source.addComponent(new Label("OTHER LABEL 2")); + + final AbstractComponent c1 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c3 = new Table("TABLE"); + c3.setHeight("100px"); + c3.setWidth("100%"); + + final Button btnAdd = new Button("Test add"); + final Button btnReplace = new Button("Test replace"); + final Button btnMove = new Button("Test move"); + final Button btnRemove = new Button("Test remove"); + + l1.addComponent(btnAdd); + l1.addComponent(btnReplace); + l1.addComponent(btnMove); + l1.addComponent(btnRemove); + + btnAdd.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.addComponent(new TextField()); + } + }); + btnReplace.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.replaceComponent(c1, c3); + } + }); + btnMove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.moveComponentsFrom(source); + } + }); + btnRemove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.removeComponent(c1); + l2.removeComponent(c2); + } + }); + + l2.addComponent(c1); + l2.addComponent(c2); + l2.addComponent(c3); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java new file mode 100644 index 0000000000..73dc39009d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java @@ -0,0 +1,43 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public abstract class BaseAddReplaceMoveTest extends MultiBrowserTest { + @Test + public void LayoutAlignment() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "add", "replace", "move", "remove" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.java new file mode 100644 index 0000000000..bfdc53bf7c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.java @@ -0,0 +1,67 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractOrderedLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +abstract public class BaseAlignment extends BaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + // create two columns of components with different + // alignment. Used to test alignment in layouts + init(); + buildLayout(); + super.setup(request); + } + + public BaseAlignment(Class<? extends AbstractOrderedLayout> layoutClass) { + super(layoutClass); + } + + /** + * Build Layout for test + */ + private void buildLayout() { + for (int i = 0; i < components.length; i++) { + AbstractOrderedLayout layout = null; + try { + layout = (AbstractOrderedLayout) layoutClass.newInstance(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + layout.setHeight("300px"); + layout.setWidth("200px"); + layout.addComponent(components[i]); + layout.setComponentAlignment(components[i], alignments[i]); + if (i < components.length / 2) { + l1.addComponent(layout); + } else { + l2.addComponent(layout); + } + } + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.java new file mode 100644 index 0000000000..9dd90a4031 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseAlignmentTest extends MultiBrowserTest { + + @Test + public void layoutAlignment() throws IOException { + openTestURL(); + compareScreen("alignment"); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java new file mode 100644 index 0000000000..37ce77e745 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java @@ -0,0 +1,44 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.TabSheet; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseCaption extends BaseLayoutTestUI { + + /** + * @param layoutClass + */ + public BaseCaption(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + l1.addComponent(createLabelsFields(ComboBox.class, true, "")); + l2.addComponent(createLabelsFields(TabSheet.class, false, "")); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.java new file mode 100644 index 0000000000..ed20657e2a --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseCaptionTest extends MultiBrowserTest { + @Test + public void LayoutCaption() throws IOException, InterruptedException { + openTestURL(); + compareScreen("caption"); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.java new file mode 100644 index 0000000000..d9377c6a8b --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseComponentSizing extends BaseLayoutTestUI { + + public BaseComponentSizing(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + getLayoutForLayoutSizing("component"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java new file mode 100644 index 0000000000..252cfcd359 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java @@ -0,0 +1,45 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public abstract class BaseComponentSizingTest extends MultiBrowserTest { + @Test + public void ComponentSizing() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "setSize350px", "setSize_-1px", "setSize75Percent", + "setSize100Percent" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java new file mode 100644 index 0000000000..34ec7928ff --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java @@ -0,0 +1,51 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseIcon extends BaseLayoutTestUI { + /** + * @param layoutClass + */ + public BaseIcon(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + l1.addComponent(createLabelsFields(TextField.class, true, "")); + l1.addComponent(createLabelsFields(Label.class, true, "")); + l1.addComponent(createLabelsFields(Button.class, true, "")); + l2.addComponent(createLabelsFields(ComboBox.class, true, "")); + l2.addComponent(createLabelsFields(Link.class, true, "")); + l2.addComponent(createLabelsFields(TabSheet.class, true, "")); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.java new file mode 100644 index 0000000000..9322672eae --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseIconTest extends MultiBrowserTest { + + @Test + public void LayoutIcon() throws IOException { + openTestURL(); + compareScreen("icon"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java new file mode 100644 index 0000000000..f21db94f80 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java @@ -0,0 +1,77 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseLayoutExpand extends BaseLayoutTestUI { + + public BaseLayoutExpand(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + class ExpandButton extends Button { + final private AbstractComponent c1; + private AbstractComponent c2; + private float expandComp1; + private float expandComp2; + + public ExpandButton(final AbstractComponent c1, + final AbstractComponent c2, float e1, float e2) { + super(); + this.c1 = c1; + this.c2 = c2; + expandComp1 = e1; + expandComp2 = e2; + setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100); + addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + l2.setExpandRatio(c1, expandComp1); + l2.setExpandRatio(c2, expandComp2); + } + }); + } + } + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + l2.addComponent(t1); + l2.addComponent(t2); + + l1.addComponent(new ExpandButton(t1, t2, 1.0f, 0.0f)); + l1.addComponent(new ExpandButton(t1, t2, 0.5f, 0.50f)); + l1.addComponent(new ExpandButton(t1, t2, .25f, 0.75f)); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java new file mode 100644 index 0000000000..08f5aed808 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java @@ -0,0 +1,49 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseLayoutExpandTest extends MultiBrowserTest { + + @Test + public void LayoutExpand() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "expand_100_0", "expand_50_50", "expand_25_75" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java new file mode 100644 index 0000000000..e98573d170 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java @@ -0,0 +1,81 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseLayoutForSpacingMargin extends BaseLayoutTestUI { + /** + * @param layoutClass + */ + public BaseLayoutForSpacingMargin( + Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + l2.addComponent(t1); + l2.setMargin(false); + l2.setSpacing(false); + // Must add something around the hr to avoid the margins collapsing + l2.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + l2.addComponent(t2); + final Button btn1 = new Button("Toggle margin on/off"); + btn1.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + boolean margin = l2.getMargin().hasLeft(); + l2.setMargin(!margin); + + } + }); + final Button btn2 = new Button("Toggle spacing on/off"); + btn2.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + l2.setSpacing(!l2.isSpacing()); + } + }); + l1.addComponent(btn1); + l1.addComponent(btn2); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..46edfec986 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java @@ -0,0 +1,42 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public abstract class BaseLayoutMarginSpacingTest extends MultiBrowserTest { + + @Test + public void LayoutMarginSpacing() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "marginOnSpaceOff", "marginOnfSpaceOn" }; + ButtonElement marginBtn = $(ButtonElement.class).get(0); + ButtonElement spaceBtn = $(ButtonElement.class).get(1); + marginBtn.click(); + sleep(1000); + compareScreen(states[0]); + spaceBtn.click(); + sleep(1000); + compareScreen(states[1]); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.java new file mode 100644 index 0000000000..61d6f8a362 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseLayoutRegErrorTest extends MultiBrowserTest { + + @Test + public void LayoutRegError() throws IOException { + openTestURL(); + compareScreen("RegError"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java new file mode 100644 index 0000000000..edc0b275d1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java @@ -0,0 +1,40 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseLayoutSizing extends BaseLayoutTestUI { + /** + * @param layoutClass + */ + public BaseLayoutSizing(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + getLayoutForLayoutSizing("layout"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java new file mode 100644 index 0000000000..e97353c989 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java @@ -0,0 +1,50 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseLayoutSizingTest extends MultiBrowserTest { + @Test + public void LayoutSizing() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "setSize350px", "setSize_-1px", "setSize75Percent", + "setSize100Percent" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java new file mode 100644 index 0000000000..02fcb677cd --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java @@ -0,0 +1,288 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.Resource; +import com.vaadin.server.ThemeResource; +import com.vaadin.server.UserError; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.AbstractOrderedLayout; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +/** + * + * Base class for Layout tests. + */ +public abstract class BaseLayoutTestUI extends AbstractTestUI { + protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png"; + protected static final String CALENDAR_32_PNG = "../runo/icons/16/calendar.png"; + protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png"; + protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png"; + public Alignment[] alignments = new Alignment[] { Alignment.TOP_CENTER, + Alignment.TOP_LEFT, Alignment.TOP_RIGHT, Alignment.BOTTOM_CENTER, + Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT, + Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT, + Alignment.MIDDLE_RIGHT }; + + public final String[] CAPTIONS = new String[] { "", + "VeryLongOneWordCaption", + "Very long caption of 50 approximately symbols aaaaaaaaaaaa aaaaaa aaa " }; + Resource[] ICONS = new Resource[] { new ThemeResource(CALENDAR_32_PNG), + new ThemeResource(LOCK_16_PNG), new ThemeResource(GLOBE_16_PNG) }; + public AbstractComponent[] components = new AbstractComponent[alignments.length]; + + protected AbstractOrderedLayout l1; + protected AbstractOrderedLayout l2; + protected Class<? extends AbstractLayout> layoutClass; + protected VerticalLayout mainLayout = new VerticalLayout(); + + public BaseLayoutTestUI(Class<? extends AbstractLayout> layoutClass) { + super(); + fillComponents(); + this.layoutClass = layoutClass; + + } + + protected void init() { + try { + l1 = (AbstractOrderedLayout) layoutClass.newInstance(); + l2 = (AbstractOrderedLayout) layoutClass.newInstance(); + } catch (InstantiationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IllegalAccessException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if (layoutClass.equals(HorizontalLayout.class)) { + setLayoutMeasures(l1, l2, "600px", "400px"); + } else if (layoutClass.equals(VerticalLayout.class)) { + setLayoutMeasures(l1, l2, "400px", "400px"); + } else { + setDefaultForVertical(l1, l2); + } + } + + private void fillComponents() { + for (int i = 0; i < components.length; i++) { + String name = "Field" + i; + TextField field = new TextField(); + field.setValue(name); + components[i] = field; + } + } + + protected AbstractLayout createLabelsFields( + Class<? extends AbstractComponent> compType) { + return createLabelsFields(compType, false, null); + } + + protected void getLayoutForLayoutSizing(final String compType) { + + l2.setSpacing(false); + l2.setMargin(false); + + final AbstractComponent c1 = getTestTable(); + c1.setSizeFull(); + final AbstractComponent c2 = getTestTable(); + c2.setSizeFull(); + + class SetSizeButton extends Button { + SetSizeButton(final String size) { + super(); + setCaption("Set size " + size); + addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (compType == "layout") { + l2.setHeight(size); + l2.setWidth(size); + } else if (compType == "component") { + c2.setHeight(size); + c2.setWidth(size); + } else { + } + + } + }); + } + + } + Button btn1 = new SetSizeButton("350px"); + Button btn2 = new SetSizeButton("-1px"); + Button btn3 = new SetSizeButton("75%"); + Button btn4 = new SetSizeButton("100%"); + + l1.addComponent(btn1); + l1.addComponent(btn2); + l1.addComponent(btn3); + l1.addComponent(btn4); + l2.addComponent(c1); + l2.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + l2.addComponent(c2); + l2.setExpandRatio(c1, 0.5f); + l2.setExpandRatio(c2, 0.5f); + + btn2.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Label newLabel = new Label("--- NEW LABEL ---"); + newLabel.setSizeUndefined(); + l2.addComponent(newLabel); + + } + }); + } + + protected Table getTestTable() { + Table t = new Table(); + t.setPageLength(5); + t.addContainerProperty("test", String.class, null); + t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1); + t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); + return t; + } + + protected AbstractLayout createLabelsFields( + Class<? extends AbstractComponent> compType, boolean useIcon, + String ErrorMessage) { + AbstractLayout mainLayout = new VerticalLayout(); + AbstractLayout curLayout = null; + try { + curLayout = layoutClass.newInstance(); + } catch (InstantiationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IllegalAccessException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + final Component[] components = new Component[CAPTIONS.length]; + + for (int i = 0; i < components.length; i++) { + AbstractComponent comp = null; + try { + comp = compType.newInstance(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + components[i] = comp; + comp.setCaption(CAPTIONS[i]); + if (useIcon) { + comp.setIcon(ICONS[i]); + } + if (ErrorMessage != null) { + if (ErrorMessage.length() == 0) { + comp.setComponentError(new UserError(null)); + } else { + comp.setComponentError(new UserError(ErrorMessage)); + } + } + // if component is a tab sheet add two tabs for it + if (comp instanceof TabSheet) { + comp.setSizeUndefined(); + TabSheet tab = (TabSheet) comp; + tab.addTab(new UndefWideLabel("TAB1"), "TAB1", + new ThemeResource(GLOBE_16_PNG)); + tab.addTab(new UndefWideLabel("TAB2"), "TAB2", null); + } + curLayout.addComponent(comp); + mainLayout.addComponent(curLayout); + } + return mainLayout; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + mainLayout.addComponent(l1); + mainLayout.addComponent(l2); + addComponent(mainLayout); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return null; + } + + protected void setLayoutMeasures(AbstractOrderedLayout l1, + AbstractOrderedLayout l2, String w, String h) { + l1.setWidth(w); + l1.setHeight(h); + l2.setWidth(h); + l2.setHeight(w); + } + + protected void setDefaultForVertical(AbstractOrderedLayout l1, + AbstractOrderedLayout l2) { + l1.setWidth("800px"); + l1.setHeight("600px"); + l2.setWidth("800px"); + l2.setHeight("600px"); + } + + protected void setDefaultForHorizontal(AbstractOrderedLayout l1, + AbstractOrderedLayout l2) { + l1.setWidth("600px"); + l1.setHeight("600px"); + l2.setWidth("600px"); + l2.setHeight("600px"); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.java new file mode 100644 index 0000000000..df4053b533 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.DateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseRegError extends BaseLayoutTestUI { + + public BaseRegError(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + + l1.addComponent(createLabelsFields(Label.class, true, "")); + l1.addComponent(createLabelsFields(Button.class, true, "")); + l1.addComponent(createLabelsFields(TabSheet.class, true, "")); + l1.addComponent(createLabelsFields(TextField.class, true, "")); + + l2.addComponent(createLabelsFields(ComboBox.class, true, "")); + l2.addComponent(createLabelsFields(DateField.class, true, "")); + l2.addComponent(createLabelsFields(NativeSelect.class, true, "")); + l2.addComponent(createLabelsFields(CheckBox.class, true, "")); + + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java new file mode 100644 index 0000000000..2771af01c6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java @@ -0,0 +1,105 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class GridAddReplaceMove extends GridBaseLayoutTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + + final HorizontalLayout source = new HorizontalLayout(); + source.addComponent(new Label("OTHER LABEL 1")); + source.addComponent(new Label("OTHER LABEL 2")); + + final AbstractComponent c1 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c3 = new Table("TABLE"); + c3.setHeight("100px"); + c3.setWidth("100%"); + + final Button btnAdd = new Button("Test add"); + final Button btnReplace = new Button("Test replace"); + final Button btnMove = new Button("Test move"); + final Button btnRemove = new Button("Test remove"); + + layout.addComponent(btnAdd); + layout.addComponent(btnReplace); + layout.addComponent(btnMove); + layout.addComponent(btnRemove); + + btnAdd.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.addComponent(new TextField()); + } + }); + btnReplace.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.replaceComponent(c1, c3); + } + }); + btnMove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.moveComponentsFrom(source); + } + }); + btnRemove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.removeComponent(c1); + layout.removeComponent(c2); + } + }); + + layout.addComponent(c1); + layout.addComponent(c2); + layout.addComponent(c3); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java new file mode 100644 index 0000000000..f83a6ccf67 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridAddReplaceMoveTest extends BaseAddReplaceMoveTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java new file mode 100644 index 0000000000..e061532690 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java @@ -0,0 +1,41 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; + +public class GridAlignment extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + /** + * Build Layout for test + */ + private void buildLayout() { + layout.setColumns(3); + layout.setRows(3); + // layout.setHeight("600px"); + // layout.setWidth("900px"); + for (int i = 0; i < components.length; i++) { + layout.addComponent(components[i]); + layout.setComponentAlignment(components[i], alignments[i]); + } + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java new file mode 100644 index 0000000000..cdc040930b --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest; + +public class GridAlignmentTest extends BaseAlignmentTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java new file mode 100644 index 0000000000..d79c52ccda --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java @@ -0,0 +1,107 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.layouts.layouttester.BaseLayoutTestUI; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class GridBaseLayoutTestUI extends BaseLayoutTestUI { + protected GridLayout layout = new GridLayout(); + + /** + * @param layoutClass + */ + public GridBaseLayoutTestUI() { + super(GridLayout.class); + } + + @Override + protected void setup(VaadinRequest request) { + layout.setMargin(true); + layout.setSizeFull(); + getUI().setContent(layout); + } + + @Override + protected void getLayoutForLayoutSizing(final String compType) { + + layout.setSpacing(false); + layout.setMargin(false); + + final AbstractComponent c1 = getTestTable(); + c1.setSizeFull(); + final AbstractComponent c2 = getTestTable(); + c2.setSizeFull(); + + class SetSizeButton extends Button { + SetSizeButton(final String size) { + super(); + setCaption("Set size " + size); + addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (compType == "layout") { + layout.setHeight(size); + layout.setWidth(size); + } else if (compType == "component") { + c2.setHeight(size); + c2.setWidth(size); + } else { + } + + } + }); + } + + } + Button btn1 = new SetSizeButton("550px"); + Button btn2 = new SetSizeButton("-1px"); + Button btn3 = new SetSizeButton("75%"); + Button btn4 = new SetSizeButton("100%"); + + layout.addComponent(btn1); + layout.addComponent(btn2); + layout.addComponent(btn3); + layout.addComponent(btn4); + layout.addComponent(c1); + layout.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + layout.addComponent(c2); + btn2.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Label newLabel = new Label("--- NEW LABEL ---"); + newLabel.setSizeUndefined(); + layout.addComponent(newLabel); + } + }); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.java new file mode 100644 index 0000000000..7b1c3d9a65 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; + +public class GridCaption extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + layout.addComponent(createLabelsFields(Button.class, true, "")); + layout.addComponent(createLabelsFields(Label.class, true, "")); + layout.addComponent(createLabelsFields(ComboBox.class, true, "")); + layout.addComponent(createLabelsFields(TabSheet.class, false, "")); + super.setup(request); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java new file mode 100644 index 0000000000..ab8046ebf3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseCaptionTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridCaptionTest extends BaseCaptionTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java new file mode 100644 index 0000000000..bebccfbf9d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridComponentSizing extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + getLayoutForLayoutSizing("component"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java new file mode 100644 index 0000000000..6572bd2a50 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest; + +public class GridComponentSizingTest extends BaseComponentSizingTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java new file mode 100644 index 0000000000..863a4f2c1d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java @@ -0,0 +1,42 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridIcon extends GridBaseLayoutTestUI { + @Override + protected void setup(VaadinRequest request) { + layout.addComponent(createLabelsFields(TextField.class, true, "")); + layout.addComponent(createLabelsFields(Label.class, true, "")); + layout.addComponent(createLabelsFields(Button.class, true, "")); + layout.addComponent(createLabelsFields(ComboBox.class, true, "")); + layout.addComponent(createLabelsFields(Link.class, true, "")); + layout.addComponent(createLabelsFields(TabSheet.class, true, "")); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java new file mode 100644 index 0000000000..25a0faa88e --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseIconTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridIconTest extends BaseIconTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java new file mode 100644 index 0000000000..b3a84cdc26 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java @@ -0,0 +1,64 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutExpand extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + class ExpandButton extends Button { + + public ExpandButton(final int i1, final int i2, final float e1, + final float e2) { + super(); + setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100); + addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + layout.setColumnExpandRatio(i1, e1); + layout.setColumnExpandRatio(i2, e2); + } + }); + } + } + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + layout.setColumns(4); + layout.setRows(4); + layout.addComponent(new ExpandButton(1, 2, 1.0f, 0.0f), 0, 0); + layout.addComponent(new ExpandButton(1, 2, 0.5f, 0.50f), 0, 1); + layout.addComponent(new ExpandButton(1, 2, .25f, 0.75f), 0, 2); + + layout.addComponent(t1, 1, 1); + layout.addComponent(t2, 2, 1); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java new file mode 100644 index 0000000000..2a49af52a9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java @@ -0,0 +1,26 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutExpandTest extends BaseLayoutExpandTest { +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java new file mode 100644 index 0000000000..78a67bdf82 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutMarginSpacing extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + + final Button btn1 = new Button("Toggle margin on/off"); + btn1.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + boolean margin = layout.getMargin().hasLeft(); + layout.setMargin(!margin); + + } + }); + final Button btn2 = new Button("Toggle spacing on/off"); + btn2.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + layout.setSpacing(!layout.isSpacing()); + } + }); + layout.addComponent(btn1); + layout.addComponent(btn2); + + layout.addComponent(t1); + layout.setMargin(false); + layout.setSpacing(false); + // Must add something around the hr to avoid the margins collapsing + layout.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + layout.addComponent(t2); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..516f3b088b --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java new file mode 100644 index 0000000000..5b4dd2a947 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.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.tests.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.DateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutRegError extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + + layout.addComponent(createLabelsFields(Label.class, true, "")); + layout.addComponent(createLabelsFields(Button.class, true, "")); + layout.addComponent(createLabelsFields(TabSheet.class, true, "")); + layout.addComponent(createLabelsFields(TextField.class, true, "")); + + layout.addComponent(createLabelsFields(ComboBox.class, true, "")); + layout.addComponent(createLabelsFields(DateField.class, true, "")); + layout.addComponent(createLabelsFields(NativeSelect.class, true, "")); + layout.addComponent(createLabelsFields(CheckBox.class, true, "")); + + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java new file mode 100644 index 0000000000..e377a7b0c4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutRegErrorTest extends BaseLayoutRegErrorTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java new file mode 100644 index 0000000000..8358f91997 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutSizing extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + getLayoutForLayoutSizing("layout"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java new file mode 100644 index 0000000000..c8a48cd70c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutSizingTest extends BaseLayoutSizingTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java deleted file mode 100644 index f55867c464..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java +++ /dev/null @@ -1,657 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import java.util.Date; - -import com.vaadin.server.LegacyApplication; -import com.vaadin.server.Resource; -import com.vaadin.server.SystemError; -import com.vaadin.server.ThemeResource; -import com.vaadin.server.UserError; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.AbstractField; -import com.vaadin.ui.AbstractOrderedLayout; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.InlineDateField; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.Link; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.Reindeer; - -public class GridLayoutTests extends AbstractLayoutTests { - - private AbstractComponent rc1, col1, col2, col3, row1, row2, row3, x3, x22; - - public GridLayoutTests(LegacyApplication application) { - super(); - } - - @Override - protected Layout getAlignmentTests() { - HorizontalLayout hlo = new HorizontalLayout(); - hlo.setSpacing(true); - GridLayout glo = getTestGrid(); - glo.addStyleName(Reindeer.LAYOUT_WHITE); - Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT, - Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT, - Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER, - Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT, - Alignment.TOP_CENTER, Alignment.TOP_RIGHT }; - - glo.replaceComponent(col1, col1 = new TextField()); - glo.replaceComponent(col2, col2 = new TextField()); - glo.replaceComponent(col3, col3 = new TextField()); - ((TextField) col1).setValue("BOTTOM_RIGHT"); - ((TextField) col2).setValue("BOTTOM_LEFT"); - ((TextField) col3).setValue("BOTTOM_CENTER"); - glo.setComponentAlignment(col2, alignments[0]); - glo.setComponentAlignment(col3, alignments[1]); - glo.setComponentAlignment(col1, alignments[2]); - - glo.setComponentAlignment(row1, alignments[3]); - glo.setComponentAlignment(row2, alignments[4]); - glo.setComponentAlignment(row3, alignments[5]); - hlo.addComponent(glo); - glo = getTestGrid(); - glo.replaceComponent(row1, row1 = new DateField()); - glo.replaceComponent(row2, row2 = new DateField()); - glo.replaceComponent(row3, row3 = new DateField()); - ((DateField) row1).setResolution(DateField.RESOLUTION_SEC); - ((DateField) row2).setResolution(DateField.RESOLUTION_SEC); - ((DateField) row3).setResolution(DateField.RESOLUTION_SEC); - glo.setComponentAlignment(col2, alignments[6]); - glo.setComponentAlignment(col3, alignments[7]); - glo.setComponentAlignment(col1, alignments[8]); - hlo.addComponent(glo); - return hlo; - } - - @Override - protected Layout getCaptionsTests() { - GridLayout glo = getTestGrid(); - glo.setWidth("600px"); - String[] captions = new String[] { - "", - "abcdefghijklmnopq", - "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" }; - glo.replaceComponent(col1, col1 = new TextField()); - glo.replaceComponent(col2, col2 = new TextField()); - glo.replaceComponent(col3, col3 = new TextField()); - - col1.setCaption(captions[0]); - col2.setCaption(captions[1]); - col3.setCaption(captions[2]); - col3.setIcon(new ThemeResource(LOCK_16_PNG)); - - glo.replaceComponent(row1, row1 = new Label()); - glo.replaceComponent(row2, row2 = new Label()); - glo.replaceComponent(row3, row3 = new Label()); - - row1.setCaption(captions[0]); - row2.setCaption(captions[1]); - row3.setCaption(captions[2]); - - glo.replaceComponent(x3, x3 = getTestTabsheet()); - glo.replaceComponent(x22, x22 = getTestTable()); - x22.setComponentError(new UserError("component error, user error")); - - x3.setCaption(captions[1]); - x22.setCaption(captions[2]); - - return glo; - } - - @Override - protected Layout getComponentAddReplaceMoveTests() { - final GridLayout glo = getTestGrid(); - glo.setHeight("350px"); - Layout baseLayout = getBaseLayout(); - final Button button1 = new Button("Test add"); - final Button button2 = new Button("Test replace"); - final Button button3 = new Button("Test move"); - final Button button4 = new Button("Test remove comp 1,1"); - final Button button5 = new Button("Test remove row 0"); - final Button button6 = new Button("Test remove comp row3"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - button5.setId("testButton5"); - button6.setId("testButton6"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(button5); - baseLayout.addComponent(button6); - baseLayout.addComponent(glo); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - button5.setEnabled(false); - button6.setEnabled(false); - - final HorizontalLayout source = new HorizontalLayout(); - source.addComponent(new Label("MOVE LABEL 1")); - source.addComponent(new Label("MOVE LABEL 2")); - - final AbstractComponent cc1 = getTestTabsheet(); - cc1.setCaption("ADDED COMPONENT"); - - final AbstractComponent cc2 = getTestTabsheet(); - cc2.setCaption("REPLACEMENT COMPONENT"); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.addComponent(cc1); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.replaceComponent(x22, cc2); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.moveComponentsFrom(source); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.removeComponent(1, 1); - button4.setEnabled(false); - button5.setEnabled(true); - } - }); - - button5.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.removeRow(0); - button5.setEnabled(false); - button6.setEnabled(true); - } - }); - button6.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.removeComponent(row3); - button6.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getComponentSizingTests() { - final GridLayout glo = getTestGrid(); - glo.setHeight("350px"); - Layout baseLayout = getBaseLayout(); - final Button button1 = new Button("full size, 3x1"); - final Button button2 = new Button("200 px width, 3x1"); - final Button button3 = new Button("200 px width, table"); - final Button button4 = new Button("undefined size+add, table"); - - glo.replaceComponent(x22, x22 = getTestTable()); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(glo); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x3.setSizeFull(); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x3.setWidth("200px"); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x22.setWidth("200px"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x22.setSizeUndefined(); - ((Table) x22).addItem(new Object[] { "NEW ROW1" }, 3); - ((Table) x22).addItem(new Object[] { "NEW ROW2" }, 4); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getExpandRatiosTests() { - final GridLayout glo = getTestGrid(); - Layout baseLayout = getBaseLayout(); - final Button button1 = new Button("set col 3 expand 1"); - final Button button2 = new Button("set all cols expand 0.25"); - final Button button3 = new Button("set row 0 expand 0.5"); - final Button button4 = new Button("set row 3 expand 0.2"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - glo.setHeight("400px"); - glo.replaceComponent(x22, x22 = getTestTable()); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(glo); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setColumnExpandRatio(3, 1); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setColumnExpandRatio(0, 0.25f); - glo.setColumnExpandRatio(1, 0.25f); - glo.setColumnExpandRatio(2, 0.25f); - glo.setColumnExpandRatio(3, 0.25f); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setRowExpandRatio(0, 0.5f); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setRowExpandRatio(3, 0.3f); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getIconsTests() { - GridLayout glo = getTestGrid(); - glo.setWidth("600px"); - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD")); - glo.replaceComponent(col2, col2 = new Label("LABEL")); - glo.replaceComponent(col3, col3 = new Link("LINK", null)); - - col1.setIcon(icons[0]); - col2.setIcon(icons[1]); - col3.setIcon(icons[0]); - rc1.setIcon(icons[1]); - col3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - col3.setComponentError(new UserError("component error, user error")); - - glo.replaceComponent(row1, row1 = new DateField()); - glo.replaceComponent(row2, row2 = new NativeSelect()); - glo.replaceComponent(row3, row3 = getTestTabsheet()); - - row1.setIcon(icons[1]); - row2.setIcon(icons[0]); - row3.setIcon(icons[1]); - - glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX")); - VerticalLayout pl = new VerticalLayout(); - pl.setMargin(true); - glo.replaceComponent(x22, x22 = new Panel("PANEL", pl)); - x22.setIcon(new ThemeResource(CALENDAR_32_PNG)); - - x3.setIcon(icons[0]); - x22.setIcon(icons[1]); - - return glo; - } - - @Override - protected Layout getLayoutSizingTests() { - final GridLayout glo = getTestGrid(); - Layout baseLayout = getBaseLayout(); - baseLayout.setWidth("500px"); - baseLayout.setHeight("500px"); - final Button button1 = new Button("Set fixed height 350px"); - final Button button2 = new Button( - "Set undefined size and add component"); - final Button button3 = new Button("Set fixed width and height 75%"); - final Button button4 = new Button("Set size full"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - glo.replaceComponent(x22, x22 = getTestTable()); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(glo); - // Don't expand the buttons - ((AbstractOrderedLayout) baseLayout).setExpandRatio(glo, 1); - - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setHeight("350px"); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSizeUndefined(); - glo.addComponent(new Label("--- NEW LABEL ---")); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setWidth("75%"); - glo.setHeight("75%"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSizeFull(); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getMarginSpacingTests() { - final GridLayout glo = getTestGrid(); - Layout baseLayout = getBaseLayout(); - baseLayout.setWidth("500px"); - baseLayout.setHeight("500px"); - final Button button1 = new Button("Set margin on"); - final Button button2 = new Button("Set spacing on"); - final Button button3 = new Button("Set margin off"); - final Button button4 = new Button("Set spacing off"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - baseLayout.addComponent(glo); - - // Don't expand the buttons - ((AbstractOrderedLayout) baseLayout).setExpandRatio(glo, 1); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setMargin(true); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSpacing(true); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setMargin(false); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSpacing(false); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getRequiredErrorIndicatorsTests() { - GridLayout glo = getTestGrid(); - glo.setWidth("600px"); - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD")); - glo.replaceComponent(col2, col2 = new Label("LABEL")); - // Make sure it doesn't shrink to 0px - col2.setWidth(null); - glo.replaceComponent(col3, col3 = new Link("LINK", null)); - - col1.setIcon(icons[0]); - col1.setComponentError(new UserError("component error, user error")); - col2.setComponentError(new SystemError("component error, system error")); - col3.setComponentError(new UserError("component error, user error")); - - glo.replaceComponent(row1, row1 = new DateField()); - glo.replaceComponent(row2, row2 = new NativeSelect()); - glo.replaceComponent(row3, row3 = getTestTabsheet()); - - ((AbstractField<?>) col1).setRequired(true); - ((AbstractField<?>) col1).setValidationVisible(true); - ((AbstractField<?>) col1).setRequiredError("required error"); - - ((AbstractField<?>) row1).setRequired(true); - ((AbstractField<?>) row1).setValidationVisible(true); - ((AbstractField<?>) row1).setRequiredError("required error"); - - ((AbstractField<?>) row2).setRequired(true); - ((AbstractField<?>) row2).setValidationVisible(true); - ((AbstractField<?>) row2).setRequiredError("required error"); - row2.setComponentError(new UserError("component error, user error")); - - row3.setComponentError(new UserError("component error, user error")); - row3.setIcon(icons[1]); - row3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - - glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX")); - VerticalLayout pl = new VerticalLayout(); - pl.setMargin(true); - glo.replaceComponent(x22, x22 = new Panel("PANEL", pl)); - - x3.setComponentError(new UserError("component error, user error")); - x22.setComponentError(new UserError("component error, user error")); - x22.setIcon(icons[0]); - - return glo; - } - - private GridLayout getTestGrid() { - // Create a 4 by 4 grid layout. - GridLayout grid = new GridLayout(4, 4); - // Fill out the first row using the cursor. - grid.addComponent(rc1 = new Button("R/C 1")); - - grid.addComponent(col1 = new Button("Col " + (grid.getCursorX() + 1))); - grid.addComponent(col2 = new Button("Col " + (grid.getCursorX() + 1))); - grid.addComponent(col3 = new Button("Col " + (grid.getCursorX() + 1))); - - // Fill out the first column using coordinates. - - grid.addComponent(row1 = new Button("Row " + 1), 0, 1); - grid.addComponent(row2 = new Button("Row " + 2), 0, 2); - grid.addComponent(row3 = new Button("Row " + 3), 0, 3); - - // Add some components of various shapes. - grid.addComponent(x3 = new Button("3x1 button"), 1, 1, 3, 1); - grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3); - x22 = new InlineDateField("A 2x2 date field"); - ((InlineDateField) x22).setResolution(DateField.RESOLUTION_DAY); - ((InlineDateField) x22).setValue(new Date(128028960000l)); - grid.addComponent(x22, 2, 2, 3, 3); - grid.setWidth("450px"); - grid.setHeight("450px"); - return grid; - } - - private VerticalLayout getBaseLayout() { - VerticalLayout vlo = new VerticalLayout(); - vlo.setSizeUndefined(); - return vlo; - } - - private AbstractComponent getTestTabsheet() { - TabSheet tabsheet = new TabSheet(); - tabsheet.setSizeUndefined(); - tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource( - GLOBE_16_PNG)); - tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null); - return tabsheet; - } - - private Table getTestTable() { - Table t = new Table(); - t.setSizeUndefined(); - t.setPageLength(5); - t.addContainerProperty("test", String.class, null); - t.addItem(new Object[] { "qwertyuiop asdfghjklzxccvbnm,m,." }, 1); - t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); - return t; - } - -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java new file mode 100644 index 0000000000..1c0e992a86 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMove; +import com.vaadin.ui.HorizontalLayout; + + +public class HAddReplaceMove extends BaseAddReplaceMove { + + /** + * @param layoutClass + */ + public HAddReplaceMove() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java new file mode 100644 index 0000000000..367664069d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest; + +public class HAddReplaceMoveTest extends BaseAddReplaceMoveTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java new file mode 100644 index 0000000000..9864fcaa41 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignment; +import com.vaadin.ui.HorizontalLayout; + +public class HAlignment extends BaseAlignment { + + public HAlignment() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java new file mode 100644 index 0000000000..055ad8e607 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest; + +public class HAlignmentTest extends BaseAlignmentTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java new file mode 100644 index 0000000000..bb974a8c68 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseCaption; +import com.vaadin.ui.HorizontalLayout; + + +public class HCaption extends BaseCaption { + + /** + * @param layoutClass + */ + public HCaption() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java new file mode 100644 index 0000000000..c10da9eefe --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseCaptionTest; + +public class HCaptionTest extends BaseCaptionTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.java new file mode 100644 index 0000000000..b042c018eb --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HComponentSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public HComponentSizing() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java new file mode 100644 index 0000000000..86aa330901 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest; + +public class HComponentSizingTest extends BaseComponentSizingTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.java new file mode 100644 index 0000000000..cb4eb321b9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseIcon; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HIcon extends BaseIcon { + + /** + * @param layoutClass + */ + public HIcon() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java new file mode 100644 index 0000000000..e01e1d1726 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseIconTest; + +public class HIconTest extends BaseIconTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.java new file mode 100644 index 0000000000..273ca07bc4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpand; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutExpand extends BaseLayoutExpand { + + /** + * @param layoutClass + */ + public HLayoutExpand() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java new file mode 100644 index 0000000000..f24abba9d2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest; + +public class HLayoutExpandTest extends BaseLayoutExpandTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.java new file mode 100644 index 0000000000..9fea380155 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutForSpacingMargin; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutMarginSpacing extends BaseLayoutForSpacingMargin { + + /** + * @param layoutClass + */ + public HLayoutMarginSpacing() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..1abae12ce6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest; + +public class HLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.java new file mode 100644 index 0000000000..3c7134a061 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseRegError; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutRegError extends BaseRegError { + + /** + * @param layoutClass + */ + public HLayoutRegError() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java new file mode 100644 index 0000000000..673c08d4fa --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; + +public class HLayoutRegErrorTest extends BaseLayoutRegErrorTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.java new file mode 100644 index 0000000000..350037b05c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public HLayoutSizing() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java new file mode 100644 index 0000000000..5f4d52a5d5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest; + +public class HLayoutSizingTest extends BaseLayoutSizingTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java deleted file mode 100644 index afa53c012e..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java +++ /dev/null @@ -1,597 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import com.vaadin.server.LegacyApplication; -import com.vaadin.server.Resource; -import com.vaadin.server.SystemError; -import com.vaadin.server.ThemeResource; -import com.vaadin.server.UserError; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.AbstractField; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.Link; -import com.vaadin.ui.Select; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.Reindeer; - -public class HorizontalLayoutTests extends AbstractLayoutTests { - - public HorizontalLayoutTests(LegacyApplication application) { - super(); - } - - @Override - protected Layout getAlignmentTests() { - Layout baseLayout = getBaseLayout(); - HorizontalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[9]; - String[] styles = { Reindeer.LAYOUT_BLUE, Reindeer.LAYOUT_WHITE }; - Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT, - Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT, - Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER, - Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT, - Alignment.TOP_CENTER, Alignment.TOP_RIGHT }; - - vlo.addStyleName(Reindeer.LAYOUT_WHITE); - baseLayout.addComponent(vlo); - int index = 0; - for (int i = 0; i < components.length; i++) { - if (i > 0 && i % 3 == 0) { - vlo = getTestLaytout(); - vlo.addStyleName(styles[index++]); - baseLayout.addComponent(vlo); - } - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - vlo.addComponent(components[i]); - vlo.setComponentAlignment(components[i], alignments[i]); - } - return baseLayout; - } - - @Override - protected Layout getCaptionsTests() { - Layout baseLayout = getBaseLayout(); - AbstractComponent component = null; - - String[] captions = new String[] { - "", - "abcdefghijklmnopq", - "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" }; - - HorizontalLayout vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new TextField(); - ((TextField) component).setValue("FIELD " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new Label(); - ((Label) component).setValue("Label " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new Select(); - component.setCaption(captions[i]); - component.setIcon(new ThemeResource(LOCK_16_PNG)); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = getTestTabsheet(); - component.setCaption(captions[i]); - component.setComponentError(new UserError("")); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getComponentAddReplaceMoveTests() { - final HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - final HorizontalLayout source = new HorizontalLayout(); - source.addComponent(new Label("OTHER LABEL 1")); - source.addComponent(new Label("OTHER LABEL 2")); - - final AbstractComponent c1 = new Button("BUTTON"); - final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); - final AbstractComponent c3 = new Table("TABLE"); - c3.setHeight("100px"); - c3.setWidth("100%"); - - final Button addButton = new Button("Test add"); - final Button replaceButton = new Button("Test replace"); - final Button moveButton = new Button("Test move"); - final Button removeButton = new Button("Test remove"); - addButton.setId("testButton1"); - replaceButton.setId("testButton2"); - moveButton.setId("testButton3"); - removeButton.setId("testButton4"); - replaceButton.setEnabled(false); - moveButton.setEnabled(false); - removeButton.setEnabled(false); - - addButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.addComponent(new TextField()); - addButton.setEnabled(false); - replaceButton.setEnabled(true); - } - }); - replaceButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.replaceComponent(c1, c3); - replaceButton.setEnabled(false); - moveButton.setEnabled(true); - } - }); - moveButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.moveComponentsFrom(source); - moveButton.setEnabled(false); - removeButton.setEnabled(true); - } - }); - removeButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.removeComponent(c1); - vlo.removeComponent(c2); - removeButton.setEnabled(false); - } - }); - - baseLayout.addComponent(addButton); - baseLayout.addComponent(replaceButton); - baseLayout.addComponent(moveButton); - baseLayout.addComponent(removeButton); - - vlo.addComponent(c1); - vlo.addComponent(c2); - vlo.addComponent(c3); - baseLayout.addComponent(vlo); - - return baseLayout; - } - - @Override - protected Layout getComponentSizingTests() { - final HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - - final AbstractComponent c = getTestTable(); - - final Button biggerButton = new Button("full size"); - final Button smallerButton = new Button("200 px width"); - final Button originalButton = new Button("undefined size+add"); - - biggerButton.setId("testButton1"); - smallerButton.setId("testButton2"); - originalButton.setId("testButton3"); - - baseLayout.addComponent(biggerButton); - baseLayout.addComponent(smallerButton); - baseLayout.addComponent(originalButton); - vlo.addComponent(c); - baseLayout.addComponent(vlo); - - biggerButton.setEnabled(true); - smallerButton.setEnabled(false); - originalButton.setEnabled(false); - - biggerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setSizeFull(); - biggerButton.setEnabled(false); - smallerButton.setEnabled(true); - } - }); - smallerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setWidth("200px"); - smallerButton.setEnabled(false); - originalButton.setEnabled(true); - } - }); - originalButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - originalButton.setEnabled(false); - c.setSizeUndefined(); - ((Table) c) - .addItem( - new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" }, - 3); - } - }); - - return baseLayout; - } - - @Override - protected Layout getLayoutSizingTests() { - final HorizontalLayout vlo = getTestLaytout(); - vlo.setSpacing(false); - vlo.setMargin(false); - Layout baseLayout = getBaseLayout(); - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set fixed height 350px"); - final Button button2 = new Button( - "Set undefined size and add component"); - final Button button3 = new Button("Set fixed width and height 75%"); - final Button button4 = new Button("Set size full"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - vlo.addComponent(c1); - vlo.addComponent(c2); - vlo.setExpandRatio(c1, 0.5f); - vlo.setExpandRatio(c2, 0.5f); - - baseLayout.addComponent(vlo); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setHeight("350px"); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSizeUndefined(); - Label label = new Label("--- NEW LABEL ---"); - label.setWidth(null); - vlo.addComponent(label); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setWidth("75%"); - vlo.setHeight("75%"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSizeFull(); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getExpandRatiosTests() { - final HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Expand to 1/undefined"); - final Button button2 = new Button("Expand to 0.5/0.5"); - final Button button3 = new Button("Expand to 0.75/0.25"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - - vlo.addComponent(c1); - vlo.addComponent(c2); - baseLayout.addComponent(vlo); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setExpandRatio(c1, 1.0f); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setExpandRatio(c1, 0.5f); - vlo.setExpandRatio(c2, 0.5f); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setExpandRatio(c1, 0.75f); - vlo.setExpandRatio(c2, 0.25f); - button3.setEnabled(false); - } - }); - return baseLayout; - } - - @Override - protected Layout getIconsTests() { - HorizontalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[2]; - Layout baseLayout = getBaseLayout(); - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - for (int i = 0; i < components.length; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - components[i].setIcon(icons[i]); - components[i] - .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - vlo.addComponent(components[i]); - } - for (int i = 0; i < components.length; i++) { - components[i] = new Label(); - ((Label) components[i]).setValue("Label " + i); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < components.length; i++) { - components[i] = new Select(); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - for (int i = 0; i < components.length; i++) { - components[i] = new Button(); - components[i].setComponentError(new UserError( - "component error, user error")); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - for (int i = 0; i < components.length; i++) { - components[i] = new Link("Link", null); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getMarginSpacingTests() { - final HorizontalLayout vlo = getTestLaytout(); - vlo.setSpacing(false); - vlo.setMargin(false); - Layout baseLayout = getBaseLayout(); - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set margin on"); - final Button button2 = new Button("Set spacing on"); - final Button button3 = new Button("Set margin off"); - final Button button4 = new Button("Set spacing off"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - vlo.addComponent(c1); - vlo.addComponent(c2); - vlo.setExpandRatio(c1, 0.5f); - vlo.setExpandRatio(c2, 0.5f); - baseLayout.addComponent(vlo); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setMargin(true); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSpacing(true); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setMargin(false); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSpacing(false); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getRequiredErrorIndicatorsTests() { - HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - AbstractComponent[] components = new AbstractComponent[4]; - components[0] = new Label("LABEL"); - components[0].setSizeUndefined(); - components[1] = new Button("BUTTON"); - components[2] = getTestTable(); - components[3] = getTestTabsheet(); - components[3].setIcon(new ThemeResource(LOCK_16_PNG)); - - AbstractField<?>[] fields = new AbstractField<?>[5]; - fields[0] = new TextField(); - fields[0].setRequired(true); - fields[0].setValidationVisible(true); - fields[0].setRequiredError("required error"); - - fields[1] = new TextField(); - ((TextField) fields[1]).setValue("TEXTFIELD2"); - fields[1] - .setComponentError(new UserError("component error, user error")); - - fields[2] = new Select(); - fields[2].setComponentError(new SystemError( - "component error, system error")); - fields[3] = new DateField(); - fields[3].setComponentError(new SystemError( - "component error, system error")); - - fields[4] = new CheckBox(); - fields[4] - .setComponentError(new UserError("component error, user error")); - - for (int i = 0; i < components.length; i++) { - components[i].setComponentError(new UserError( - "component error, user error")); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < fields.length; i++) { - vlo.addComponent(fields[i]); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - private VerticalLayout getBaseLayout() { - VerticalLayout vlo = new VerticalLayout(); - vlo.setSizeUndefined(); - return vlo; - } - - private HorizontalLayout getTestLaytout() { - HorizontalLayout vlo = new HorizontalLayout(); - vlo.setHeight("100px"); - vlo.setWidth("750px"); - return vlo; - } - - private AbstractComponent getTestTabsheet() { - TabSheet tabsheet = new TabSheet(); - tabsheet.setSizeUndefined(); - tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource( - GLOBE_16_PNG)); - tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null); - return tabsheet; - } - - private Table getTestTable() { - Table t = new Table(); - t.setSizeUndefined(); - t.setPageLength(5); - t.addContainerProperty("test", String.class, null); - t.addItem(new Object[] { "qwertyuiop asdfghjkl zxccvbnm,m,." }, 1); - t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); - return t; - } -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java deleted file mode 100644 index 5b68e04144..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import java.lang.reflect.Method; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.tests.components.AbstractTestCase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Layout; -import com.vaadin.ui.LegacyWindow; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.Reindeer; - -@SuppressWarnings("serial") -public class LayoutTesterApplication extends AbstractTestCase { - Button nextButton = new Button("Next"); - private int layoutIndex = -1; - - static final String[] layoutGetters = new String[] { "getCaptionsTests", - "getIconsTests", "getRequiredErrorIndicatorsTests", - "getAlignmentTests", "getExpandRatiosTests", - "getMarginSpacingTests", "getComponentAddReplaceMoveTests", - "getComponentSizingTests", "getLayoutSizingTests" }; - public static final String NEXT_BUTTON_ID = "nextButton"; - private static final String LAYOUT_SELECT_ID = "layoutSelect"; - - private LegacyWindow mainWindow; - private NativeSelect layoutSelector; - - @Override - public void init() { - nextButton.setId(NEXT_BUTTON_ID); - mainWindow = new LegacyWindow("LayoutTesterApplication"); - setMainWindow(mainWindow); - nextLayout(); - - nextButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = -1577298910202253538L; - - @Override - public void buttonClick(ClickEvent event) { - nextLayout(); - } - }); - } - - private void nextLayout() { - try { - mainWindow.removeAllComponents(); - HorizontalLayout vlo = new HorizontalLayout(); - vlo.setSpacing(true); - ++layoutIndex; - if (layoutIndex >= layoutGetters.length) { - layoutIndex = 0; - } - mainWindow.addComponent(vlo); - vlo.addComponent(nextButton); - vlo.addComponent(getLayoutTypeSelect()); - vlo.addComponent(new UndefWideLabel(getLayoutGetterMethod( - layoutGetters[layoutIndex]).getName())); - - Layout lo = null; - if (layoutSelector.getValue() == VerticalLayout.class) { - lo = getVerticalTestLayout(layoutIndex); - } else if (layoutSelector.getValue() == HorizontalLayout.class) { - lo = getHorizontalTestLayout(layoutIndex); - } else if (layoutSelector.getValue() == GridLayout.class) { - lo = getGridTestLayout(layoutIndex); - } - if (lo != null) { - lo.addStyleName(Reindeer.LAYOUT_BLUE); - mainWindow.addComponent(lo); - } - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - private Method getLayoutGetterMethod(String method) { - try { - return AbstractLayoutTests.class.getDeclaredMethod(method); - } catch (SecurityException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - public Layout getVerticalTestLayout(int index) throws Exception { - VerticalLayoutTests vlotest = new VerticalLayoutTests(this); - return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke( - vlotest, (Object[]) null); - } - - public Layout getHorizontalTestLayout(int index) throws Exception { - HorizontalLayoutTests hlotest = new HorizontalLayoutTests(this); - return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke( - hlotest, (Object[]) null); - } - - public Layout getGridTestLayout(int index) throws Exception { - GridLayoutTests hlotest = new GridLayoutTests(this); - return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke( - hlotest, (Object[]) null); - } - - private NativeSelect getLayoutTypeSelect() { - if (layoutSelector == null) { - layoutSelector = new NativeSelect(); - layoutSelector.setId(LAYOUT_SELECT_ID); - layoutSelector.addItem(VerticalLayout.class); - layoutSelector.addItem(HorizontalLayout.class); - layoutSelector.addItem(GridLayout.class); - layoutSelector.setNullSelectionAllowed(false); - layoutSelector.setImmediate(true); - layoutSelector.select(VerticalLayout.class); - layoutSelector.addListener(new Property.ValueChangeListener() { - private static final long serialVersionUID = -605319614765838359L; - - @Override - public void valueChange(ValueChangeEvent event) { - layoutIndex = -1; - nextLayout(); - } - }); - } - return layoutSelector; - } - - @Override - protected String getDescription() { - return "Test application for VerticalLayout, HorizontalLayout, and GridLayout"; - } - - @Override - protected Integer getTicketNumber() { - return 5334; - } - -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java deleted file mode 100644 index 5d8a6e0e7a..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.layouts.layouttester; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.Select; - -import com.vaadin.tests.tb3.MultiBrowserTest; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.VerticalLayout; - -public class LayoutTesterApplicationTest extends MultiBrowserTest { - - @Override - protected DesiredCapabilities getDesiredCapabilities() { - DesiredCapabilities cap = new DesiredCapabilities( - super.getDesiredCapabilities()); - cap.setCapability("nativeEvents", false); - - return cap; - } - - Map<String, Integer> numberOfSubTests = new HashMap<String, Integer>(); - private Set<String> tableOrIconsTests = new HashSet<String>(); - - { - numberOfSubTests.put("getExpandRatiosTests", 3); - numberOfSubTests.put("getLayoutSizingTests", 4); - numberOfSubTests.put("getComponentAddReplaceMoveTests", 4); - numberOfSubTests.put("getMarginSpacingTests", 4); - numberOfSubTests.put("getComponentSizingTests", 3); - - tableOrIconsTests.add("getComponentSizingTests"); - tableOrIconsTests.add("getExpandRatiosTests"); - tableOrIconsTests.add("getLayoutSizingTests"); - tableOrIconsTests.add("getMarginSpacingTests"); - tableOrIconsTests.add("getIconsTests"); - - } - - @Test - public void verticalLayout() throws Exception { - openTestURL(); - runTest(VerticalLayout.class); - } - - @Test - public void horizontalLayout() throws Exception { - openTestURL(); - runTest(HorizontalLayout.class); - } - - @Test - public void gridLayout() throws Exception { - numberOfSubTests.put("getComponentAddReplaceMoveTests", 6); - numberOfSubTests.put("getComponentSizingTests", 4); - numberOfSubTests.put("getExpandRatiosTests", 4); - - openTestURL(); - runTest(GridLayout.class); - } - - private void runTest(Class<?> layoutClass) throws Exception { - new Select(vaadinElementById("layoutSelect").findElement( - By.xpath("select"))) - .selectByVisibleText(layoutClass.toString()); - - for (String subTest : LayoutTesterApplication.layoutGetters) { - compareScreen(subTest); - Integer subTests = numberOfSubTests.get(subTest); - if (subTests != null) { - for (int i = 1; i <= subTests; i++) { - clickAndCompareScreen(subTest, "testButton" + i); - } - } - - hitButton("nextButton"); - } - - } - - /** - * Clicks the button with the given id and compares the result to a - * screenshot named 'screenshotPrefix'-buttonCaption. - * - * @param screenshotPrefix - * @param buttonId - * @throws Exception - */ - private void clickAndCompareScreen(String screenshotPrefix, String buttonId) - throws Exception { - hitButton(buttonId); - - if (needsDelayToStabilize(screenshotPrefix)) { - // Table does some extra layout phase and TestBench does not always - // take this into account, grabbing screenshots before the layout - // phase is done (see #12866). - sleep(500); - } - compareScreen(screenshotPrefix + "-" - + sanitize(driver.findElement(By.id(buttonId)).getText())); - } - - private boolean needsDelayToStabilize(String screenshotPrefix) { - return tableOrIconsTests.contains(screenshotPrefix); - } - - private String sanitize(String text) { - return text.replace("%", "pct").replaceAll("[^a-zA-Z0-9]", "-"); - } -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.java new file mode 100644 index 0000000000..a0ef960f57 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMove; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VAddReplaceMove extends BaseAddReplaceMove { + + /** + * @param layoutClass + */ + public VAddReplaceMove() { + super(VerticalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java new file mode 100644 index 0000000000..70f7237c96 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VAddReplaceMoveTest extends BaseAddReplaceMoveTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java new file mode 100644 index 0000000000..9872b4bfd7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java @@ -0,0 +1,25 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignment; +import com.vaadin.ui.VerticalLayout; + +public class VAlignment extends BaseAlignment { + public VAlignment() { + super(VerticalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java new file mode 100644 index 0000000000..f49787754c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest; + +public class VAlignmentTest extends BaseAlignmentTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.java new file mode 100644 index 0000000000..b2f50961cb --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseCaption; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VCaption extends BaseCaption { + + /** + * @param layoutClass + */ + public VCaption() { + super(VerticalLayout.class); + // TODO Auto-generated constructor stub + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java new file mode 100644 index 0000000000..942736b286 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseCaptionTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VCaptionTest extends BaseCaptionTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.java new file mode 100644 index 0000000000..67fcb85652 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VComponentSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public VComponentSizing() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java new file mode 100644 index 0000000000..bef10a6a58 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest; + +public class VComponentSizingTest extends BaseComponentSizingTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.java new file mode 100644 index 0000000000..1420be4907 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseIcon; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VIcon extends BaseIcon { + + /** + * @param layoutClass + */ + public VIcon() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java new file mode 100644 index 0000000000..221bf2e2db --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseIconTest; + +public class VIconTest extends BaseIconTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.java new file mode 100644 index 0000000000..15a31b16f0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpand; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutExpand extends BaseLayoutExpand { + + /** + * @param layoutClass + */ + public VLayoutExpand() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java new file mode 100644 index 0000000000..57bb134be7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest; + + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VLayoutExpandTest extends BaseLayoutExpandTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.java new file mode 100644 index 0000000000..d6d9040bae --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutForSpacingMargin; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutMarginSpacing extends BaseLayoutForSpacingMargin { + + /** + * @param layoutClass + */ + public VLayoutMarginSpacing() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..89ffdf792f --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest; + +public class VLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.java new file mode 100644 index 0000000000..72fd35b842 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseRegError; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutRegError extends BaseRegError { + + /** + * @param layoutClass + */ + public VLayoutRegError() { + super(VerticalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java new file mode 100644 index 0000000000..e3e5914e3a --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; + + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VLayoutRegErrorTest extends BaseLayoutRegErrorTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.java new file mode 100644 index 0000000000..ea6464cfb7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public VLayoutSizing() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java new file mode 100644 index 0000000000..372eb9cba4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest; + + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VLayoutSizingTest extends BaseLayoutSizingTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java deleted file mode 100644 index df9be8ffd0..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java +++ /dev/null @@ -1,634 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import com.vaadin.server.LegacyApplication; -import com.vaadin.server.Resource; -import com.vaadin.server.SystemError; -import com.vaadin.server.ThemeResource; -import com.vaadin.server.UserError; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.AbstractField; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.Link; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Select; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; - -public class VerticalLayoutTests extends AbstractLayoutTests { - - public VerticalLayoutTests(LegacyApplication application) { - super(); - } - - @Override - protected Layout getAlignmentTests() { - Layout baseLayout = getBaseLayout(); - ((HorizontalLayout) baseLayout).setSpacing(true); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[9]; - Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_CENTER, - Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT, - Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT, - Alignment.MIDDLE_RIGHT, Alignment.TOP_CENTER, - Alignment.TOP_LEFT, Alignment.TOP_RIGHT }; - - for (int i = 0; i < components.length / 2; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - vlo.addComponent(components[i]); - vlo.setComponentAlignment(components[i], alignments[i]); - vlo.addComponent(new Label("<hr />", ContentMode.HTML)); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = components.length / 2; i < components.length; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - vlo.addComponent(components[i]); - vlo.setComponentAlignment(components[i], alignments[i]); - vlo.addComponent(new Label("<hr />", ContentMode.HTML)); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getCaptionsTests() { - Layout baseLayout = getBaseLayout(); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent component = null; - - String[] captions = new String[] { - "", - "abcdefghijklmnopq", - "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" }; - - for (int i = 0; i < captions.length; i++) { - component = new TextField(); - ((TextField) component).setValue("FIELD " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - for (int i = 0; i < captions.length; i++) { - component = new Label(); - ((Label) component).setValue("Label " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new Select(); - component.setCaption(captions[i]); - component.setIcon(new ThemeResource(LOCK_16_PNG)); - vlo.addComponent(component); - } - for (int i = 0; i < captions.length; i++) { - component = getTestTabsheet(); - component.setCaption(captions[i]); - component.setComponentError(new UserError("")); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getComponentAddReplaceMoveTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - final VerticalLayout vlo2 = getTestLaytout(); - - // Set undefined height to avoid expanding - vlo2.setHeight(null); - - final HorizontalLayout source = new HorizontalLayout(); - source.addComponent(new Label("OTHER LABEL 1")); - source.addComponent(new Label("OTHER LABEL 2")); - - final AbstractComponent c1 = new Button("BUTTON"); - final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); - final AbstractComponent c3 = new Table("TABLE"); - c3.setHeight("100px"); - c3.setWidth("100%"); - - final Button addButton = new Button("Test add"); - final Button replaceButton = new Button("Test replace"); - final Button moveButton = new Button("Test move"); - final Button removeButton = new Button("Test remove"); - addButton.setId("testButton1"); - replaceButton.setId("testButton2"); - moveButton.setId("testButton3"); - removeButton.setId("testButton4"); - - replaceButton.setEnabled(false); - moveButton.setEnabled(false); - removeButton.setEnabled(false); - - addButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.addComponent(new TextField()); - addButton.setEnabled(false); - replaceButton.setEnabled(true); - } - }); - replaceButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.replaceComponent(c1, c3); - replaceButton.setEnabled(false); - moveButton.setEnabled(true); - } - }); - moveButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.moveComponentsFrom(source); - moveButton.setEnabled(false); - removeButton.setEnabled(true); - } - }); - removeButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.removeComponent(c1); - vlo2.removeComponent(c2); - removeButton.setEnabled(false); - } - }); - - vlo.addComponent(addButton); - vlo.addComponent(replaceButton); - vlo.addComponent(moveButton); - vlo.addComponent(removeButton); - - baseLayout.addComponent(vlo); - vlo2.addComponent(c1); - vlo2.addComponent(c2); - vlo2.addComponent(c3); - baseLayout.addComponent(vlo2); - return baseLayout; - } - - @Override - protected Layout getComponentSizingTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - - final AbstractComponent c = getTestTable(); - - final Button biggerButton = new Button("full size"); - final Button smallerButton = new Button("200 px width"); - final Button originalButton = new Button("undefined size and add"); - biggerButton.setId("testButton1"); - smallerButton.setId("testButton2"); - originalButton.setId("testButton3"); - vlo.addComponent(biggerButton); - vlo.addComponent(smallerButton); - vlo.addComponent(originalButton); - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - vlo2.addComponent(c); - baseLayout.addComponent(vlo2); - - biggerButton.setEnabled(true); - smallerButton.setEnabled(false); - originalButton.setEnabled(false); - - biggerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setSizeFull(); - biggerButton.setEnabled(false); - smallerButton.setEnabled(true); - } - }); - smallerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setWidth("200px"); - smallerButton.setEnabled(false); - originalButton.setEnabled(true); - } - }); - originalButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - originalButton.setEnabled(false); - c.setSizeUndefined(); - ((Table) c) - .addItem( - new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" }, - 3); - } - }); - - return baseLayout; - } - - @Override - protected Layout getLayoutSizingTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - - vlo.setSpacing(false); - vlo.setMargin(false); - - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set fixed height 350px"); - final Button button2 = new Button( - "Set undefined size and add component"); - final Button button3 = new Button("Set fixed width and height 75%"); - final Button button4 = new Button("Set size full"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - vlo.addComponent(button1); - vlo.addComponent(button2); - vlo.addComponent(button3); - vlo.addComponent(button4); - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - vlo2.addComponent(c1); - vlo2.addComponent(new Label( - "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", - ContentMode.HTML)); - vlo2.addComponent(c2); - vlo2.setExpandRatio(c1, 0.5f); - vlo2.setExpandRatio(c2, 0.5f); - baseLayout.addComponent(vlo2); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setHeight("350px"); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSizeUndefined(); - Label newLabel = new Label("--- NEW LABEL ---"); - newLabel.setSizeUndefined(); - vlo2.addComponent(newLabel); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setWidth("75%"); - vlo2.setHeight("75%"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSizeFull(); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getExpandRatiosTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Expand to 1/undefined"); - button1.setId("testButton1"); - final Button button2 = new Button("Expand to 0.5/0.5"); - button2.setId("testButton2"); - final Button button3 = new Button("Expand to 0.75/0.25"); - button3.setId("testButton3"); - - vlo.addComponent(button1); - vlo.addComponent(button2); - vlo.addComponent(button3); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - - vlo2.addComponent(c1); - vlo2.addComponent(c2); - baseLayout.addComponent(vlo2); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setExpandRatio(c1, 1.0f); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setExpandRatio(c1, 0.5f); - vlo2.setExpandRatio(c2, 0.5f); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setExpandRatio(c1, 0.75f); - vlo2.setExpandRatio(c2, 0.25f); - button3.setEnabled(false); - } - }); - return baseLayout; - } - - @Override - protected Layout getIconsTests() { - Layout baseLayout = getBaseLayout(); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[2]; - - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - for (int i = 0; i < components.length; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - components[i].setIcon(icons[i]); - components[i] - .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - vlo.addComponent(components[i]); - } - - for (int i = 0; i < components.length; i++) { - components[i] = new Label(); - ((Label) components[i]).setValue("Label " + i); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - - for (int i = 0; i < components.length; i++) { - components[i] = new Select(); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - for (int i = 0; i < components.length; i++) { - components[i] = new Button(); - components[i].setComponentError(new UserError( - "component error, user error")); - components[i].setIcon(icons[i]); - vlo2.addComponent(components[i]); - } - - for (int i = 0; i < components.length; i++) { - components[i] = new Link("Link", null); - components[i].setIcon(icons[i]); - vlo2.addComponent(components[i]); - } - baseLayout.addComponent(vlo2); - return baseLayout; - } - - @Override - protected Layout getMarginSpacingTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - vlo.setSpacing(false); - vlo.setMargin(false); - - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set margin on"); - final Button button2 = new Button("Set spacing on"); - final Button button3 = new Button("Set margin off"); - final Button button4 = new Button("Set spacing off"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - vlo.addComponent(button1); - vlo.addComponent(button2); - vlo.addComponent(button3); - vlo.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - - vlo2.addComponent(c1); - // Must add something around the hr to avoid the margins collapsing - vlo2.addComponent(new Label( - "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", - ContentMode.HTML)); - vlo2.addComponent(c2); - vlo2.setExpandRatio(c1, 0.5f); - vlo2.setExpandRatio(c2, 0.5f); - baseLayout.addComponent(vlo2); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setMargin(true); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSpacing(true); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setMargin(false); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSpacing(false); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getRequiredErrorIndicatorsTests() { - Layout baseLayout = getBaseLayout(); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[4]; - components[0] = new Label("LABEL"); - components[0].setSizeUndefined(); - components[1] = new Button("BUTTON"); - components[2] = getTestTable(); - components[3] = getTestTabsheet(); - components[3].setIcon(new ThemeResource(LOCK_16_PNG)); - - AbstractField<?>[] fields = new AbstractField<?>[6]; - fields[0] = new TextField(); - fields[0].setRequired(true); - fields[0].setValidationVisible(true); - fields[0].setRequiredError("required error"); - - fields[1] = new TextField(); - ((TextField) fields[1]).setValue("TEXTFIELD2"); - fields[1] - .setComponentError(new UserError("component error, user error")); - - fields[2] = new Select(); - fields[2].setComponentError(new SystemError( - "component error, system error")); - fields[3] = new DateField(); - fields[3].setComponentError(new SystemError( - "component error, system error")); - - fields[4] = new CheckBox(); - fields[4] - .setComponentError(new UserError("component error, user error")); - - fields[5] = new NativeSelect(); - fields[5].setRequired(true); - fields[5].setValidationVisible(true); - fields[5].setRequiredError("required error"); - fields[5] - .setComponentError(new UserError("component error, user error")); - fields[5].setIcon(new ThemeResource(CALENDAR_32_PNG)); - - for (int i = 0; i < components.length; i++) { - components[i].setComponentError(new UserError( - "component error, user error")); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - for (int i = 0; i < fields.length; i++) { - vlo2.addComponent(fields[i]); - } - - baseLayout.addComponent(vlo2); - return baseLayout; - } - - private HorizontalLayout getBaseLayout() { - HorizontalLayout hlo = new HorizontalLayout(); - hlo.setSizeUndefined(); - return hlo; - } - - private VerticalLayout getTestLaytout() { - VerticalLayout vlo = new VerticalLayout(); - vlo.setHeight("500px"); - vlo.setWidth("400px"); - return vlo; - } - - private AbstractComponent getTestTabsheet() { - TabSheet tabsheet = new TabSheet(); - tabsheet.setSizeUndefined(); - tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource( - GLOBE_16_PNG)); - tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null); - return tabsheet; - } - - private Table getTestTable() { - Table t = new Table(); - t.setSizeUndefined(); - t.setPageLength(5); - t.addContainerProperty("test", String.class, null); - t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1); - t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); - return t; - } -} diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 3745d60fd8..8783a4dc42 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -24,6 +24,7 @@ import java.net.URL; import java.util.Collections; import java.util.List; +import com.vaadin.testbench.TestBenchElement; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; @@ -35,6 +36,8 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.HasInputDevices; import org.openqa.selenium.interactions.Keyboard; import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; @@ -51,6 +54,8 @@ import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.tb3.MultiBrowserTest.Browser; import com.vaadin.ui.UI; +import static com.vaadin.tests.tb3.TB3Runner.localWebDriverIsUsed; + /** * Base class for TestBench 3+ tests. All TB3+ tests in the project should * extend this class. @@ -126,7 +131,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } else { capabilities = getDesiredCapabilities(); - if (System.getProperty("useLocalWebDriver") != null) { + if (localWebDriverIsUsed()) { setupLocalDriver(capabilities); } else { WebDriver dr = TestBench.createDriver(new RemoteWebDriver( @@ -151,6 +156,14 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } + protected WebElement getTooltipElement() { + return getDriver().findElement(com.vaadin.testbench.By.className("v-tooltip-text")); + } + + protected Coordinates getCoordinates(TestBenchElement element) { + return ((Locatable) element.getWrappedElement()).getCoordinates(); + } + @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface RunLocally { diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index 74073af217..ccbb6ca872 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -40,6 +40,16 @@ import org.openqa.selenium.remote.DesiredCapabilities; */ public abstract class MultiBrowserTest extends PrivateTB3Configuration { + protected List<DesiredCapabilities> getBrowsersExcludingIE() { + List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(getAllBrowsers()); + browsers.remove(Browser.IE8.getDesiredCapabilities()); + browsers.remove(Browser.IE9.getDesiredCapabilities()); + browsers.remove(Browser.IE10.getDesiredCapabilities()); + browsers.remove(Browser.IE11.getDesiredCapabilities()); + + return browsers; + } + public enum Browser { FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(33)), SAFARI( BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java index 69880008ff..4d29e479e2 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java @@ -61,7 +61,7 @@ public class TB3Runner extends BlockJUnit4ClassRunner { private static final ExecutorService service; static { - if (System.getProperty("useLocalWebDriver") != null) { + if (localWebDriverIsUsed()) { MAX_CONCURRENT_TESTS = 10; } else { MAX_CONCURRENT_TESTS = 50; @@ -69,6 +69,12 @@ public class TB3Runner extends BlockJUnit4ClassRunner { service = Executors.newFixedThreadPool(MAX_CONCURRENT_TESTS); } + protected static boolean localWebDriverIsUsed() { + String useLocalWebDriver = System.getProperty("useLocalWebDriver"); + + return useLocalWebDriver != null && useLocalWebDriver.toLowerCase().equals("true"); + } + public TB3Runner(Class<?> klass) throws InitializationError { super(klass); setScheduler(new ParallelScheduler(service)); diff --git a/uitest/src/com/vaadin/tests/tb3/TooltipTest.java b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java new file mode 100644 index 0000000000..86ac8c1f12 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.tb3; + +import java.util.NoSuchElementException; + +import org.junit.Assert; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; + +/** + * Base class for TestBench 3+ tests that use tooltips. This class contains + * utility methods for testing tooltip use. + * + * @author Vaadin Ltd + */ +public abstract class TooltipTest extends MultiBrowserTest { + + protected void clearTooltip() throws Exception { + moveToRoot(); + Thread.sleep(500); + checkTooltipNotPresent(); + } + + protected void checkTooltip(String locator, String value) throws Exception { + checkTooltip(By.vaadin(locator), value); + } + + protected void checkTooltip(org.openqa.selenium.By by, String value) + throws Exception { + checkTooltip(getDriver().findElement(by), value); + } + + protected void checkTooltip(WebElement element, String value) + throws Exception { + testBenchElement(element).showTooltip(); + if (null != value) { + checkTooltip(value); + } else { + checkTooltipNotPresent(); + } + } + + protected void checkTooltip(String value) throws Exception { + WebElement tooltip = getTooltip(); + Assert.assertEquals(value, tooltip.getText()); + Assert.assertTrue("Tooltip should be in viewport", tooltip + .getLocation().getX() >= 0); + } + + protected void moveToRoot() { + WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); + moveMouseToTopLeft(uiRoot); + } + + protected WebElement getTooltip() throws InterruptedException { + org.openqa.selenium.By tooltipBy = By.vaadin("Root/VTooltip[0]"); + return getDriver().findElement(tooltipBy); + } + + protected void checkTooltipNotPresent() throws Exception { + try { + WebElement tooltip = getTooltip(); + if (!"".equals(tooltip.getText()) + || tooltip.getLocation().getX() > -999) { + Assert.fail("Found tooltip that shouldn't be visible: " + + tooltip.getText() + " at " + tooltip.getLocation()); + } + } catch (NoSuchElementException e) { + Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools"); + } + } + + protected void moveMouseToTopLeft(WebElement element) { + new Actions(getDriver()).moveToElement(element, 0, 0).perform(); + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java new file mode 100644 index 0000000000..5c7b52d96f --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java @@ -0,0 +1,31 @@ +package com.vaadin.tests.tooltip; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.VerticalLayout; + +public class StationaryTooltip extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout vl = new VerticalLayout(); + Button button = new Button("Button"); + button.setDescription("description"); + + button.setWidth("200px"); + vl.addComponent(button); + + addComponent(vl); + } + + @Override + protected String getTestDescription() { + return null; + } + + @Override + protected Integer getTicketNumber() { + return null; + } +} diff --git a/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java new file mode 100644 index 0000000000..6b751e7a6b --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java @@ -0,0 +1,77 @@ +package com.vaadin.tests.tooltip; + +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class StationaryTooltipTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // With IEDriver, the cursor seems to jump to default position after the + // mouse move, + // so we are not able to test the tooltip behaviour properly. + return getBrowsersExcludingIE(); + } + + @Test + public void tooltipShouldBeStationary() throws InterruptedException { + openTestURL(); + + Mouse mouse = getMouse(); + + moveMouseToButtonUpperLeftCorner(mouse); + sleep(3000); // wait for the tooltip to become visible + int originalTooltipLocationX = getTooltipLocationX(); + + moveMouseToButtonBottomRightCorner(mouse); + int actualTooltipLocationX = getTooltipLocationX(); + + assertThat(actualTooltipLocationX, is(greaterThan(0))); + assertThat(actualTooltipLocationX, is(originalTooltipLocationX)); + } + + private Coordinates getButtonCoordinates() { + return getCoordinates(getButtonElement()); + } + + private ButtonElement getButtonElement() { + return $(ButtonElement.class).first(); + } + + private void moveMouseToButtonBottomRightCorner(Mouse mouse) { + Coordinates buttonCoordinates = getButtonCoordinates(); + Dimension buttonDimensions = getButtonDimensions(); + + mouse.mouseMove(buttonCoordinates, buttonDimensions.getWidth() - 1, + buttonDimensions.getHeight() - 1); + } + + private void moveMouseToButtonUpperLeftCorner(Mouse mouse) { + Coordinates buttonCoordinates = getButtonCoordinates(); + + mouse.mouseMove(buttonCoordinates, 0, 0); + } + + private org.openqa.selenium.Dimension getButtonDimensions() { + ButtonElement buttonElement = getButtonElement(); + + return buttonElement.getWrappedElement().getSize(); + } + + private int getTooltipLocationX() { + return getTooltipElement().getLocation().getX(); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/widgetset/client/AbstractSuperclassForBean.java b/uitest/src/com/vaadin/tests/widgetset/client/AbstractSuperclassForBean.java new file mode 100644 index 0000000000..0ea19bd965 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/AbstractSuperclassForBean.java @@ -0,0 +1,26 @@ +/* + * 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.widgetset.client; + +import java.io.Serializable; + +/** + * Dummy state bean used just to check that nothing breaks when generating code + * to serialize beans with properties in abstract superclasses + */ +public abstract class AbstractSuperclassForBean implements Serializable { + public String propertyInAbstractSuperclass; +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/BeanWithAbstractSuperclass.java b/uitest/src/com/vaadin/tests/widgetset/client/BeanWithAbstractSuperclass.java new file mode 100644 index 0000000000..a3530f19e9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/BeanWithAbstractSuperclass.java @@ -0,0 +1,24 @@ +/* + * 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.widgetset.client; + +/** + * Dummy state bean used just to check that nothing breaks when generating code + * to serialize beans with properties in abstract superclasses + */ +public class BeanWithAbstractSuperclass extends AbstractSuperclassForBean { + public String propertyInsubclass; +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java index d22165b2bb..faf41fbf88 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java @@ -97,4 +97,6 @@ public class SerializerTestState extends AbstractComponentState { public Date date1; public Date date2; + public BeanWithAbstractSuperclass beanWithAbstractSuperclass; + } diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml index 6e0f25a8f7..a39725f1bb 100644 --- a/uitest/tb3test.xml +++ b/uitest/tb3test.xml @@ -7,6 +7,7 @@ <property name="browsers.exclude" value="" /> <property name="categories.include" value="" /> <property name="categories.exclude" value="" /> + <property name="useLocalWebDriver" value="false" /> <ivy:resolve file="${tb3test.dir}/ivy.xml" conf="build, build-provided" /> <ivy:cachepath pathid="classpath.tb3.lib" conf="build, build-provided" /> @@ -37,6 +38,7 @@ <jvmarg value="-Dbrowsers.exclude=${browsers.exclude}" /> <jvmarg value="-Dcategories.include=${categories.include}" /> <jvmarg value="-Dcategories.exclude=${categories.exclude}" /> + <jvmarg value="-DuseLocalWebDriver=${useLocalWebDriver}" /> <test name="${junit.test.suite}" todir="${report.dir}" /> </junit> |