diff options
author | Artur Signell <artur@vaadin.com> | 2012-01-31 15:33:01 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-01-31 15:33:01 +0200 |
commit | c1f26940cd893dc5e89d2c6eb39d83ce668557fe (patch) | |
tree | cbe03a6cba732d0bcb1ddce2ece938dd07165489 /tests | |
parent | 1d01f9204bd760789592238be039acef57616109 (diff) | |
parent | b1ae3cd70e2ca4656bb28f77ca79fe0efd29dd67 (diff) | |
download | vaadin-framework-c1f26940cd893dc5e89d2c6eb39d83ce668557fe.tar.gz vaadin-framework-c1f26940cd893dc5e89d2c6eb39d83ce668557fe.zip |
Merged 'b1ae3cd70e2ca4656bb28f77ca79fe0efd29dd67' (origin/6.8)
Conflicts:
WebContent/release-notes.html
tests/server-side/com/vaadin/tests/server/LicenseInJavaFiles.java
Diffstat (limited to 'tests')
7 files changed, 385 insertions, 3 deletions
diff --git a/tests/integration_tests.xml b/tests/integration_tests.xml index 1b37347ddd..6572de59eb 100644 --- a/tests/integration_tests.xml +++ b/tests/integration_tests.xml @@ -131,6 +131,7 @@ <target name="integration-test-jetty8">
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="300" />
<param name="target-server" value="jetty8" />
</antcall>
</target>
@@ -259,6 +260,7 @@ </antcall>
</target>
+
<target name="integration-test-weblogicPortal">
<fileset dir="integration-testscripts" id="html-test-files" includes="weblogic-portal/integration-test-WebLogic-Portal-10.3.2-portlet2.html" />
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
diff --git a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java new file mode 100644 index 0000000000..91aaf131f5 --- /dev/null +++ b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java @@ -0,0 +1,114 @@ +package com.vaadin.tests.server; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashSet; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.commons.io.IOUtils; + +public class SourceFileChecker extends TestCase { + + /** + * The tests are run in the build directory. + */ + public static String baseDirectory = null; + public static final String SRC_DIR = getBaseDir() + "src"; + public static final String TESTBENCH_SRC_DIR = getBaseDir() + + "tests/testbench"; + public static final String SERVERSIDE_SRC_DIR = getBaseDir() + + "tests/server-side"; + public static final String CLIENTSIDE_SRC_DIR = getBaseDir() + + "tests/client-side"; + + public static String getBaseDir() { + if (baseDirectory != null) { + return baseDirectory; + } + // Run in the "build" directory by build, in the project root by Eclipse + for (File f : new File("..").listFiles()) { + if (f.getName().equals("buildhelpers")) { + // We are in "build" + baseDirectory = "../"; + return baseDirectory; + } + } + + baseDirectory = ""; + return baseDirectory; + } + + private static final String[] ALL_SRC_DIRS = new String[] { SRC_DIR, + TESTBENCH_SRC_DIR, SERVERSIDE_SRC_DIR, CLIENTSIDE_SRC_DIR }; + + public void testJavaFilesContainsLicense() throws IOException { + validateJavaFiles(SRC_DIR, new LicenseChecker(), + "The following files are missing license information:\n{0}"); + } + + public void testJavaFilesUseUnixNewline() throws IOException { + for (String dir : ALL_SRC_DIRS) { + validateJavaFiles(dir, new DosNewlineDetector(), + "The following files contain CRLF instead of LF:\n{0}"); + } + } + + public interface FileValidator { + void validateFile(File f) throws Exception; + } + + private void validateJavaFiles(String directory, FileValidator validator, + String errorMessage) { + File srcDir = new File(directory); + System.out.println(new File(".").getAbsolutePath()); + HashSet<String> missing = new HashSet<String>(); + validateFiles(srcDir, missing, validator, ".java"); + if (!missing.isEmpty()) { + throw new RuntimeException(errorMessage.replace("{0}", + missing.toString())); + } + + } + + private void validateFiles(File srcDir, HashSet<String> missing, + FileValidator validator, String suffix) { + Assert.assertTrue("Directory " + srcDir + " does not exist", + srcDir.exists()); + + for (File f : srcDir.listFiles()) { + if (f.isDirectory()) { + validateFiles(f, missing, validator, suffix); + } else if (f.getName().endsWith(suffix)) { + try { + validator.validateFile(f); + } catch (Throwable t) { + missing.add(f.getPath()); + } + } + } + } + + class DosNewlineDetector implements FileValidator { + + public void validateFile(File f) throws Exception { + String contents = IOUtils.toString(new FileInputStream(f)); + if (contents.contains("\r\n")) { + throw new IllegalArgumentException(); + } + + } + } + + class LicenseChecker implements FileValidator { + public void validateFile(File f) throws Exception { + String contents = IOUtils.toString(new FileInputStream(f)); + if (!contents.contains("@" + "VaadinApache2LicenseForJavaFiles" + + "@")) { + throw new IllegalArgumentException(); + } + } + } +} diff --git a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html new file mode 100644 index 0000000000..97398b4964 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html @@ -0,0 +1,142 @@ +<?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>PopupDateFieldExtendedRange</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">PopupDateFieldExtendedRange</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.datefield.PopupDateFieldExtendedRange?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>12,18</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]#prevmon</td> + <td>11,9</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]#prevy</td> + <td>10,13</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>18,10</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>16,12</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>17,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#popupButton</td> + <td>11,8</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>left</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>left</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>up</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>up</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>shift left</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>shift down</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#popupButton</td> + <td>9,4</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> + <td>9,9</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldExtendedRangeInMonthView::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> + <td>21,4</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java new file mode 100644 index 0000000000..4fc8f87398 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java @@ -0,0 +1,69 @@ +package com.vaadin.tests.components.datefield;
+
+import java.util.Calendar;
+import java.util.Locale;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.PopupDateField;
+
+@SuppressWarnings("serial")
+public class PopupDateFieldExtendedRange extends TestBase {
+
+ private Calendar date = Calendar.getInstance();
+
+ @Override
+ protected void setup() {
+ date.set(2011, 0, 1);
+
+ getLayout().setSpacing(true);
+
+ final PopupDateField[] fields = new PopupDateField[3];
+
+ fields[0] = makeDateField();
+ fields[0].setLocale(new Locale("fi", "FI"));
+ fields[0].setCaption("Finnish locale");
+
+ fields[1] = makeDateField();
+ fields[1].setLocale(new Locale("en", "US"));
+ fields[1].setCaption("US English locale");
+
+ fields[2] = makeDateField();
+ fields[2].setLocale(new Locale("fi", "FI"));
+ fields[2].setShowISOWeekNumbers(true);
+ fields[2].setCaption("Finnish locale with week numbers");
+
+ for (PopupDateField f : fields) {
+ addComponent(f);
+ }
+
+ addComponent(new Button("Change date", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ date.set(2010, 1, 16);
+ for (PopupDateField f : fields) {
+ f.setValue(date.getTime());
+ }
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Show a few days of the preceding and following months in the datefield popup";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6718;
+ }
+
+ private PopupDateField makeDateField() {
+ PopupDateField pdf = new PopupDateField();
+ pdf.setResolution(DateField.RESOLUTION_DAY);
+ pdf.setValue(date.getTime());
+ return pdf;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java index 447b5b4be6..2f30b623fd 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -177,7 +177,11 @@ public class OrderedLayoutCases extends AbstractTestRoot { newLayout.setWidth(currentLayout.getWidth(), currentLayout.getWidthUnits()); + newLayout.setMargin(currentLayout.getMargin()); + newLayout.setSpacing(currentLayout.isSpacing()); + getLayout().replaceComponent(currentLayout, newLayout); + getLayout().setExpandRatio(newLayout, 1); currentLayout = newLayout; } }, "Horizontal", "Vertical")); diff --git a/tests/testbench/com/vaadin/tests/components/table/TextFieldValueGoesMissing.html b/tests/testbench/com/vaadin/tests/components/table/TextFieldValueGoesMissing.html new file mode 100644 index 0000000000..4573cf4c50 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TextFieldValueGoesMissing.html @@ -0,0 +1,47 @@ +<?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>TextFieldValueGoesMissing</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TextFieldValueGoesMissing</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TextFieldValueGoesMissing?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTextFieldValueGoesMissing::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
+ <td>73,10</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentstableTextFieldValueGoesMissing::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
+ <td>test</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTextFieldValueGoesMissing::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>contextmenu</td>
+ <td>vaadin=runcomvaadintestscomponentstableTextFieldValueGoesMissing::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentstableTextFieldValueGoesMissing::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
+ <td>test</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java b/tests/testbench/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java index 254f1b0a90..f3ff5e983e 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java +++ b/tests/testbench/com/vaadin/tests/components/table/TextFieldValueGoesMissing.java @@ -17,11 +17,15 @@ public class TextFieldValueGoesMissing extends TestBase { final Label label1 = new Label("1"); final Label label2 = new Label("2"); - Button button = new Button("Refresh"); + Button button = new Button("Replace label"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { - verticalLayout.replaceComponent(label1, label2); + if (verticalLayout.getComponentIndex(label1) > -1) { + verticalLayout.replaceComponent(label1, label2); + } else { + verticalLayout.replaceComponent(label2, label1); + } } }); verticalLayout.addComponent(button); @@ -41,7 +45,7 @@ public class TextFieldValueGoesMissing extends TestBase { @Override protected String getDescription() { - return "Enter a text in the TextField in the table and press the 'replace label' button. This replaces the label which is in the same layout as the table but should not cause the TextField in the table to lose its contents"; + return "Enter a text in the TextField in the table and press the 'Replace label' button. This replaces the label which is in the same layout as the table but should not cause the TextField in the table to lose its contents"; } @Override |