]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged test changes from 6.1 branch
authorArtur Signell <artur.signell@itmill.com>
Fri, 23 Oct 2009 10:55:53 +0000 (10:55 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 23 Oct 2009 10:55:53 +0000 (10:55 +0000)
svn changeset:9332/svn branch:6.2

src/com/vaadin/tests/components/textfield/TextFields.html [new file with mode: 0644]
src/com/vaadin/tests/components/textfield/TextFields.java [new file with mode: 0644]
tests/Run selected test (all browsers).launch [new file with mode: 0644]
tests/test.xml

diff --git a/src/com/vaadin/tests/components/textfield/TextFields.html b/src/com/vaadin/tests/components/textfield/TextFields.html
new file mode 100644 (file)
index 0000000..4b6f845
--- /dev/null
@@ -0,0 +1,122 @@
+<?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>TextFields</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TextFields</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.textfield.TextFields</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>enabled</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstextfieldTextFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[1]</td>
+       <td>3,12</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstextfieldTextFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[1]</td>
+       <td>31,13</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>required-and-error</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstextfieldTextFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[0]</td>
+       <td>17,8</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>required-error-readonly</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstextfieldTextFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td>
+       <td>16,8</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstextfieldTextFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[1]</td>
+       <td>32,8</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstextfieldTextFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>
+       <td>23,4</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>readonly-disabled</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstextfieldTextFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[1]</td>
+       <td>30,11</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>disabled</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/src/com/vaadin/tests/components/textfield/TextFields.java b/src/com/vaadin/tests/components/textfield/TextFields.java
new file mode 100644 (file)
index 0000000..7b7c3b3
--- /dev/null
@@ -0,0 +1,198 @@
+package com.vaadin.tests.components.textfield;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class TextFields extends TestBase {
+
+    private TextField textFields[] = new TextField[20];
+
+    @Override
+    protected void setup() {
+        HorizontalLayout actionLayout = new HorizontalLayout();
+        actionLayout.setSpacing(true);
+        actionLayout.setMargin(true);
+        for (Component c : createActions()) {
+            actionLayout.addComponent(c);
+        }
+        addComponent(actionLayout);
+
+        int index = 0;
+
+        textFields[index] = createTextField("TextField 100% wide");
+        textFields[index].setWidth("100%");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField(null,
+                "TextField 100% wide, no caption");
+        textFields[index].setWidth("100%");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField("TextField auto wide");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField("TextField with input prompt");
+        textFields[index].setInputPrompt("Please enter a value");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField("100px wide textfield");
+        textFields[index].setWidth("100px");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField("150px wide, 120px high textfield");
+        textFields[index].setWidth("150px");
+        textFields[index].setHeight("120px");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField("50px high textfield");
+        textFields[index].setHeight("50px");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField(null, "No caption");
+        addComponent(textFields[index++]);
+
+        textFields[index] = createTextField(null, "No caption and input prompt");
+        textFields[index].setInputPrompt("Enter a value");
+        addComponent(textFields[index++]);
+
+    }
+
+    private TextField createTextField(String caption, String value) {
+        TextField tf = new TextField(caption);
+        tf.setValue(value);
+
+        return tf;
+    }
+
+    private TextField createTextField(String caption) {
+        return createTextField(caption, "");
+    }
+
+    @Override
+    protected String getDescription() {
+        return "A generic test for TextFields in different configurations";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    protected List<Component> createActions() {
+        ArrayList<Component> actions = new ArrayList<Component>();
+
+        CheckBox errorIndicators = new CheckBox("Error indicators",
+                new Button.ClickListener() {
+                    public void buttonClick(ClickEvent event) {
+                        Button b = event.getButton();
+                        boolean enabled = (Boolean) b.getValue();
+                        setErrorIndicators(enabled);
+
+                    }
+                });
+
+        CheckBox required = new CheckBox("Required",
+                new Button.ClickListener() {
+                    public void buttonClick(ClickEvent event) {
+                        Button b = event.getButton();
+                        boolean enabled = (Boolean) b.getValue();
+                        setRequired(enabled);
+                    }
+                });
+
+        CheckBox enabled = new CheckBox("Enabled", new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                Button b = event.getButton();
+                boolean enabled = (Boolean) b.getValue();
+                setEnabled(enabled);
+            }
+        });
+
+        CheckBox readonly = new CheckBox("Readonly",
+                new Button.ClickListener() {
+                    public void buttonClick(ClickEvent event) {
+                        Button b = event.getButton();
+                        boolean enabled = (Boolean) b.getValue();
+                        setReadOnly(enabled);
+                    }
+                });
+
+        errorIndicators.setValue(new Boolean(false));
+        required.setValue(new Boolean(false));
+        readonly.setValue(new Boolean(false));
+        enabled.setValue(new Boolean(true));
+
+        errorIndicators.setImmediate(true);
+        required.setImmediate(true);
+        readonly.setImmediate(true);
+        enabled.setImmediate(true);
+
+        actions.add(errorIndicators);
+        actions.add(required);
+        actions.add(readonly);
+        actions.add(enabled);
+
+        return actions;
+    }
+
+    protected void setRequired(boolean on) {
+
+        for (TextField tf : textFields) {
+            if (tf == null) {
+                continue;
+            }
+
+            tf.setRequired(on);
+        }
+
+    }
+
+    protected void setErrorIndicators(boolean on) {
+        for (TextField tf : textFields) {
+            if (tf == null) {
+                continue;
+            }
+
+            if (on) {
+                tf.setComponentError(new UserError("It failed!"));
+            } else {
+                tf.setComponentError(null);
+
+            }
+        }
+
+    }
+
+    protected void setEnabled(boolean on) {
+        for (TextField tf : textFields) {
+            if (tf == null) {
+                continue;
+            }
+
+            tf.setEnabled(on);
+        }
+
+    }
+
+    protected void setReadOnly(boolean on) {
+        for (TextField tf : textFields) {
+            if (tf == null) {
+                continue;
+            }
+
+            tf.setReadOnly(on);
+        }
+
+    }
+
+}
diff --git a/tests/Run selected test (all browsers).launch b/tests/Run selected test (all browsers).launch
new file mode 100644 (file)
index 0000000..6bd7c95
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<launchConfiguration type="org.eclipse.ant.AntLaunchConfigurationType">\r
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>\r
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1255941973781_71&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/vaadin/tests/screenshots/errors&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>\r
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">\r
+<listEntry value="/vaadin/tests/test.xml"/>\r
+</listAttribute>\r
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">\r
+<listEntry value="1"/>\r
+</listAttribute>\r
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">\r
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>\r
+</listAttribute>\r
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_12"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="vaadin"/>\r
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>\r
+<mapAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES">\r
+<mapEntry key="browsers" value="winxp-opera10"/>\r
+<mapEntry key="com.vaadin.testbench.deployment.url" value="http://192.168.2.75:8888/"/>\r
+<mapEntry key="com.vaadin.testbench.lib.dir" value="c:\temp\tb"/>\r
+<mapEntry key="com.vaadin.testbench.screenshot.softfail" value="true"/>\r
+<mapEntry key="testfiles" value="${resource_loc}"/>\r
+</mapAttribute>\r
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/vaadin/tests/test.xml}"/>\r
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-v"/>\r
+<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>\r
+</launchConfiguration>\r
index d3c499beb5481e69b1ef048090c4ec463775416e..20d7649e96aeac87e0ecf9df55dde3131ce1000a 100644 (file)
@@ -1,15 +1,23 @@
 <?xml version="1.0"?>
 
 <project name="Run Vaadin Testbench Tests" basedir="." default="run-and-clean-up">
-    <!-- ================================================================== -->
-    <!-- Configuration                                                      -->
-    <!-- ================================================================== -->
+       <!-- ================================================================== -->
+       <!-- Configuration                                                      -->
+       <!-- ================================================================== -->
        <!-- Temporary output directory, created and removed by this script -->
        <property name="test-output-dir" value="../build/test-output" />
        <property name="class-dir" value="${test-output-dir}/classes" />
+       <property name="com.vaadin.testbench.screenshot.directory" value="../tests/screenshots" />
+       <property name="com.vaadin.testbench.tester.host" value="192.168.1.44" />
        <!-- Browsers to use for testing -->
-       <property name="test-browsers" value="firefox,ie,safari,googlechrome,opera" />
-       
+       <property name="test-browsers" value="winxp-ie6,winxp-ie7,winxp-ie8,winxp-firefox35,winxp-safari4,winxp-googlechrome3,winxp-opera10" />
+
+       <taskdef resource="net/sf/antcontrib/antcontrib.properties">
+               <classpath>
+                       <pathelement location="../build/lib/ant-contrib-1.0b3.jar"/>
+               </classpath>
+       </taskdef>
+
        <!-- classpath must include test bench jar and its dependencies -->
        <path id="classpath">
                <fileset dir="${com.vaadin.testbench.lib.dir}" includes="**/*.jar" />
        </target>
 
 
-    <!-- ================================================================== -->
-    <!-- Toolkit Server Management                                          -->
-    <!-- ================================================================== -->
-
-    <target name="server-start">
-        <fail unless="package.name" message="The 'package.name' property must be defined."/>
-        <fail unless="package.filename" message="The 'package.filename' property must be defined."/>
-        <fail unless="testing.testarea" message="The 'testing.testarea' property must be defined."/>
-
-        <echo>Package name: ${package.name}</echo>
-        <echo>Package filename: ${package.filename}</echo>
-        <echo>Testing area: ${testing.testarea}</echo>
-
-        <exec executable="python" searchpath="true" dir=".."  resultproperty="server.start.result">
-            <arg value="build/testing/toolkit-server.py"/>
-            <arg value="start"/>
-            <arg value="${package.name}"/>
-            <arg value="${package.filename}"/>
-            <arg value="${output-dir}"/>
-            <arg value="${testing.testarea}"/>
-        </exec>
-
-        <condition property="server.start.succeeded">
-            <equals arg1="${server.start.result}" arg2="0"/>
-        </condition>
-    </target>
-
-    <target name="server-stop">
-        <exec executable="python" dir=".." searchpath="true" resultproperty="server.stop.result">
-            <arg value="build/testing/toolkit-server.py"/>
-            <arg value="stop"/>
-        </exec>
-    </target>
-       
-    <!-- ================================================================== -->
-    <!-- Running Tests                                                      -->
-    <!-- ================================================================== -->
-       
+       <!-- ================================================================== -->
+       <!-- Toolkit Server Management                                          -->
+       <!-- ================================================================== -->
+
+       <target name="server-start">
+               <fail unless="output-dir" message="The 'output-dir' (usually build/result/vaadin-xxx) should be given to test script." />
+               <fail unless="package.name" message="The 'package.name' property must be defined." />
+               <fail unless="package.filename" message="The 'package.filename' property must be defined." />
+               <fail unless="testing.testarea" message="The 'testing.testarea' property must be defined." />
+
+               <echo>Package name: ${package.name}</echo>
+               <echo>Package filename: ${package.filename}</echo>
+               <echo>Testing area: ${testing.testarea}</echo>
+
+               <exec executable="python" searchpath="true" dir=".." resultproperty="server.start.result">
+                       <arg value="build/testing/toolkit-server.py" />
+                       <arg value="start" />
+                       <arg value="${package.name}" />
+                       <arg value="${package.filename}" />
+                       <arg value="${output-dir}" />
+                       <arg value="${testing.testarea}" />
+               </exec>
+
+               <condition property="server.start.succeeded">
+                       <equals arg1="${server.start.result}" arg2="0" />
+               </condition>
+       </target>
+
+       <target name="server-stop">
+               <exec executable="python" dir=".." searchpath="true" resultproperty="server.stop.result">
+                       <arg value="build/testing/toolkit-server.py" />
+                       <arg value="stop" />
+               </exec>
+       </target>
+
+       <!-- ================================================================== -->
+       <!-- Running Tests                                                      -->
+       <!-- ================================================================== -->
+
        <target name="check-parameters">
-        <fail unless="output-dir" message="The 'output-dir' (usually build/result/vaadin-xxx) should be given to test script."/>
-        <fail unless="com.vaadin.testbench.lib.dir" message="The 'com.vaadin.testbench.lib.dir' property must be defined."/>
-        <fail unless="com.vaadin.testbench.tester.host" message="The 'com.vaadin.testbench.tester.host' property must be defined."/>
-        <fail unless="com.vaadin.testbench.deployment.url" message="The 'com.vaadin.testbench.deployment.url' property must be defined."/>
-    </target>
-               
-       <target name="run-tests" if="server.start.succeeded" depends="execute-tests">
+               <fail unless="com.vaadin.testbench.lib.dir" message="The 'com.vaadin.testbench.lib.dir' property must be defined." />
+               <fail unless="com.vaadin.testbench.tester.host" message="The 'com.vaadin.testbench.tester.host' property must be defined." />
+               <fail unless="com.vaadin.testbench.deployment.url" message="The 'com.vaadin.testbench.deployment.url' property must be defined." />
        </target>
-       
+
+       <target name="run-tests" depends="remove-error-screens,compile-tests">
+               <foreach parallel="true" target="execute-tests" param="target">
+                       <path>
+                               <fileset dir="${test-output-dir}" includes="**/**.java" />
+                       </path>
+               </foreach>
+       </target>
+
        <!-- This target runs the generated and compiled junit tests -->
-       <target name="execute-tests" depends="remove-error-screens,compile-tests">
+       <target name="execute-tests">
                <junit fork="yes" printsummary="withOutAndErr">
                        <classpath>
                                <path refid="classpath" />
                        <jvmarg value="-Dcom.vaadin.testbench.screenshot.reference.debug=${com.vaadin.testbench.screenshot.reference.debug}" />
 
                        <batchtest>
-                               <fileset dir="${test-output-dir}">
-                                       <include name="**/**.java" />
-                               </fileset>
+                               <filelist dir="${test-output-dir}" files="${target}" />
                        </batchtest>
                </junit>
 
                        </fileset>
                </delete>
        </target>
-       
+
        <!-- Remove old error screenshots -->
        <target name="remove-error-screens">
                <mkdir dir="${com.vaadin.testbench.screenshot.directory}/errors" />
                <delete>
                        <fileset dir="${com.vaadin.testbench.screenshot.directory}/errors">
-                               <include name="**/**.*" />      
+                               <include name="**/**.*" />
                        </fileset>
                </delete>
        </target>
 
-    <!-- ================================================================== -->
-    <!-- Main Targets                                                       -->
-    <!-- ================================================================== -->
+       <!-- ================================================================== -->
+       <!-- Main Targets                                                       -->
+       <!-- ================================================================== -->
 
-    <!-- The default target. -->
+       <!-- The default target. -->
        <target name="run-and-clean-up" depends="check-parameters, run-tests,remove-temp-testclasses">
        </target>
 
-    <!-- Also starts the server. -->
-    <target name="test-package" depends="server-start, run-and-clean-up, server-stop">
-    </target>
-       
+       <!-- Also starts the server. -->
+       <target name="test-package" depends="server-start, run-and-clean-up, server-stop">
+       </target>
+
 </project>