diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-05-04 09:05:58 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-05-04 09:05:58 +0300 |
commit | e6738e64dc2f7db1733aa568fd2713632b9f8966 (patch) | |
tree | 1353d11c5d37ddfe4b15dd97cf11d50149d9286b /tests | |
parent | 46c74e7362271ccbcf54c506657d8c0846a61858 (diff) | |
parent | b1ef06fdb8d1dc03dba2afb397aed89089ac5445 (diff) | |
download | vaadin-framework-e6738e64dc2f7db1733aa568fd2713632b9f8966.tar.gz vaadin-framework-e6738e64dc2f7db1733aa568fd2713632b9f8966.zip |
Merge remote branch 'origin/6.8'
Conflicts:
src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
src/com/vaadin/terminal/gwt/client/BrowserInfo.java
src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java
src/com/vaadin/terminal/gwt/client/ui/VButton.java
src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java
src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
src/com/vaadin/terminal/gwt/client/ui/VNotification.java
src/com/vaadin/terminal/gwt/client/ui/VView.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
src/com/vaadin/terminal/gwt/server/RequestTimer.java
src/com/vaadin/ui/Button.java
tests/test.xml
tests/testbench/com/vaadin/tests/components/TouchScrollables.java
Diffstat (limited to 'tests')
17 files changed, 950 insertions, 67 deletions
diff --git a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java index f661b6cf15..fedce98ecf 100644 --- a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java +++ b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java @@ -2,8 +2,6 @@ package com.vaadin.terminal.gwt.client; import junit.framework.TestCase; -import com.vaadin.terminal.gwt.client.VBrowserDetails; - public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"; @@ -37,6 +35,15 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String SAFARI3_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29"; private static final String SAFARI4_MAC = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7"; + private static final String IPHONE_IOS_5_1 = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3"; + private static final String IPHONE_IOS_4_0 = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7"; + private static final String IPAD_IOS_4_3_1 = "Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5"; + + private static final String ANDROID_HTC_2_1 = "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; ADR6300 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"; + private static final String ANDROID_GOOGLE_NEXUS_2_2 = "Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"; + private static final String ANDROID_MOTOROLA_3_0 = "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13"; + private static final String ANDROID_GALAXY_NEXUS_4_0_4_CHROME = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"; + public void testSafari3() { VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS); assertWebKit(bd); @@ -57,6 +64,86 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertMacOSX(bd); } + public void testIPhoneIOS5() { + VBrowserDetails bd = new VBrowserDetails(IPHONE_IOS_5_1); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 5); + assertBrowserMinorVersion(bd, 1); + assertEngineVersion(bd, 534f); + assertIOS(bd, 5, 1); + } + + public void testIPhoneIOS4() { + VBrowserDetails bd = new VBrowserDetails(IPHONE_IOS_4_0); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 532f); + assertIOS(bd, 4, 0); + } + + public void testIPadIOS4() { + VBrowserDetails bd = new VBrowserDetails(IPAD_IOS_4_3_1); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 5); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 533f); + assertIOS(bd, 4, 3); + } + + public void testAndroid21() { + VBrowserDetails bd = new VBrowserDetails(ANDROID_HTC_2_1); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 530f); + assertAndroid(bd, 2, 1); + + } + + public void testAndroid22() { + VBrowserDetails bd = new VBrowserDetails(ANDROID_GOOGLE_NEXUS_2_2); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 533f); + assertAndroid(bd, 2, 2); + } + + public void testAndroid30() { + VBrowserDetails bd = new VBrowserDetails(ANDROID_MOTOROLA_3_0); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 534f); + assertAndroid(bd, 3, 0); + } + + public void testAndroid40Chrome() { + VBrowserDetails bd = new VBrowserDetails( + ANDROID_GALAXY_NEXUS_4_0_4_CHROME); + assertWebKit(bd); + assertChrome(bd); + assertBrowserMajorVersion(bd, 18); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 535f); + assertAndroid(bd, 4, 0); + } + + private void assertOSMajorVersion(VBrowserDetails bd, int i) { + assertEquals(i, bd.getOperatingSystemMajorVersion()); + } + + private void assertOSMinorVersion(VBrowserDetails bd, int i) { + assertEquals(i, bd.getOperatingSystemMinorVersion()); + } + public void testChrome3() { VBrowserDetails bd = new VBrowserDetails(CHROME3_MAC); assertWebKit(bd); @@ -352,18 +439,47 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertFalse(browserDetails.isLinux()); assertFalse(browserDetails.isWindows()); assertTrue(browserDetails.isMacOSX()); + assertFalse(browserDetails.isAndroid()); + } + + private void assertAndroid(VBrowserDetails browserDetails, + int majorVersion, int minorVersion) { + assertFalse(browserDetails.isLinux()); + assertFalse(browserDetails.isWindows()); + assertFalse(browserDetails.isMacOSX()); + assertFalse(browserDetails.isIOS()); + assertTrue(browserDetails.isAndroid()); + + assertOSMajorVersion(browserDetails, majorVersion); + assertOSMinorVersion(browserDetails, minorVersion); + } + + private void assertIOS(VBrowserDetails browserDetails, int majorVersion, + int minorVersion) { + assertFalse(browserDetails.isLinux()); + assertFalse(browserDetails.isWindows()); + assertFalse(browserDetails.isMacOSX()); + assertTrue(browserDetails.isIOS()); + assertFalse(browserDetails.isAndroid()); + + assertOSMajorVersion(browserDetails, majorVersion); + assertOSMinorVersion(browserDetails, minorVersion); } private void assertWindows(VBrowserDetails browserDetails) { assertFalse(browserDetails.isLinux()); assertTrue(browserDetails.isWindows()); assertFalse(browserDetails.isMacOSX()); + assertFalse(browserDetails.isIOS()); + assertFalse(browserDetails.isAndroid()); } private void assertLinux(VBrowserDetails browserDetails) { assertTrue(browserDetails.isLinux()); assertFalse(browserDetails.isWindows()); assertFalse(browserDetails.isMacOSX()); + assertFalse(browserDetails.isIOS()); + assertFalse(browserDetails.isAndroid()); } } diff --git a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java index 453aab5af8..9906990165 100644 --- a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java +++ b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java @@ -5,6 +5,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.util.HashSet; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import junit.framework.Assert; import junit.framework.TestCase; @@ -81,6 +83,17 @@ public class SourceFileChecker extends TestCase { } } + public void testGwtFilesUsingEntry() { + Set<String> ignore = new HashSet<String>(alwaysIgnore); + ignore.add(externalJavaFiles); + validateFiles( + SRC_DIR, + new GwtEntryChecker(), + ignore, + "The following files might export javscript callbacks without $entry:\n{0}", + ".java"); + } + public interface FileValidator { void validateFile(File f) throws Exception; } @@ -171,4 +184,33 @@ public class SourceFileChecker extends TestCase { } } } + + class GwtEntryChecker extends FileContentsValidator { + // Matches e.g. + // @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::escapeHtml( + private final Matcher matcher = Pattern.compile("@[\\w.]+::\\w+\\(") + .matcher(""); + + @Override + protected void validateContents(File f, String contents) + throws Exception { + matcher.reset(contents); + while (matcher.find()) { + int start = matcher.start(); + + // Search backwards to find index of native block start + int nativeBlockStart = contents.lastIndexOf("/*-{", start); + + // Get contents between block start and our match + String beforeMatchInBlock = contents.substring( + nativeBlockStart, start); + + // Fail if there's no $entry + if (!beforeMatchInBlock.contains("$entry")) { + throw new IllegalArgumentException(); + } + } + } + + } } diff --git a/tests/server-side/com/vaadin/tests/server/component/tree/TestHasChildren.java b/tests/server-side/com/vaadin/tests/server/component/tree/TestHasChildren.java new file mode 100644 index 0000000000..66535d3ffb --- /dev/null +++ b/tests/server-side/com/vaadin/tests/server/component/tree/TestHasChildren.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.server.component.tree; + +import junit.framework.TestCase; + +import com.vaadin.ui.Tree; + +public class TestHasChildren extends TestCase { + + private Tree tree; + + @Override + protected void setUp() { + tree = new Tree(); + tree.addItem("parent"); + tree.addItem("child"); + tree.setChildrenAllowed("parent", true); + tree.setParent("child", "parent"); + } + + public void testRemoveChildren() { + assertTrue(tree.hasChildren("parent")); + tree.removeItem("child"); + assertFalse(tree.hasChildren("parent")); + } +} diff --git a/tests/test.xml b/tests/test.xml index 28459c37e9..67e48ee137 100644 --- a/tests/test.xml +++ b/tests/test.xml @@ -11,7 +11,7 @@ <!-- Configuration --> <!-- ================================================================== --> <!-- Browsers to use for testing --> - <property name="browsers-windows" value="winxp-ie8,win7-ie9,winxp-firefox11,winxp-safari5,winxp-googlechrome18,winxp-opera11" /> + <property name="browsers-windows" value="winxp-ie8,win7-ie9,winxp-firefox12,winxp-safari5,winxp-googlechrome18,winxp-opera11" /> <property name="browsers-linux" value="linux-firefox3,linux-opera10,linux-googlechrome8" /> <property name="browsers-mac" value="osx-firefox3,osx-opera10,osx-googlechrome8,osx-safari4,osx-safari5" /> diff --git a/tests/testbench/com/vaadin/tests/components/TouchScrollables.java b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java index 636bddead8..053691e738 100644 --- a/tests/testbench/com/vaadin/tests/components/TouchScrollables.java +++ b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java @@ -15,27 +15,102 @@ import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; import com.vaadin.tests.util.Person; import com.vaadin.tests.util.PersonContainer; import com.vaadin.tests.util.TestUtils; -import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; +import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; -import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; +import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; public class TouchScrollables extends TestBase { java.util.Random r = new java.util.Random(1); - private HorizontalLayout testSelector; + private TabSheet testSelector = new TabSheet(); @Override public void setup() { - testSelector = new HorizontalLayout(); getLayout().addComponent(testSelector); + testSelector.setHeight("500px"); + addTest(getPanelTest()); + addTest(getSimpleTableTest()); + addTest(getDDSortableTableTest()); + addTest(getTabSheetTest()); + addTest(getSplitPanelTest()); + addTest(getAccordionTest()); + addTest(getSubWindowTest()); + + TestUtils + .injectCSS( + getLayout().getRoot(), + "body * {-webkit-user-select: none;} .v-table-row-drag-middle .v-table-cell-content {" + + " background-color: inherit ; border-bottom: 1px solid cyan;" + + "}" + + ".v-table-row-drag-middle .v-table-cell-wrapper {" + + " margin-bottom: -1px;" + "}" + "" + + ); + } + + private Component getPanelTest() { + Layout cssLayout = new CssLayout(); + cssLayout.setCaption("Panel"); + + final Panel p = new Panel(); + p.setHeight("400px"); + Label l50 = null; + for (int i = 0; i < 100; i++) { + Label c = new Label("Label" + i); + p.addComponent(c); + if (i == 50) { + l50 = c; + } + } + + final Label l = l50; + Button button = new Button("Scroll to label 50", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getLayout().getRoot().scrollIntoView(l); + } + }); + cssLayout.addComponent(button); + button = new Button("Scroll to 100px", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + p.setScrollTop(100); + } + }); + cssLayout.addComponent(button); + cssLayout.addComponent(p); + return cssLayout; + } + + private Component getTabSheetTest() { + TabSheet ts = new TabSheet(); + ts.setCaption("Tabsheet"); + ts.setHeight("100%"); + ts.addTab(getBigComponent(), "Tab 1"); + ts.addTab(getBigComponent(), "Tab 2"); + return ts; + } + + private Component getSplitPanelTest() { + HorizontalSplitPanel sp = new HorizontalSplitPanel(); + sp.setCaption("Splitpanel"); + sp.addComponent(getBigComponent()); + sp.addComponent(getBigComponent()); + return sp; + } + + private Component getSimpleTableTest() { CssLayout cssLayout = new CssLayout(); final Table table = new Table(); @@ -68,57 +143,33 @@ public class TouchScrollables extends TestBase { } cssLayout.addComponent(table); cssLayout.setCaption("Table"); + return cssLayout; + } - addTest(cssLayout); - - cssLayout = new CssLayout(); - cssLayout.setCaption("Panel"); - - final Panel p = new Panel(); - p.setHeight("400px"); - p.setCaption("Panel"); - Label l50 = null; - for (int i = 0; i < 100; i++) { - Label c = new Label("Label" + i); - p.addComponent(c); - if (i == 50) { - l50 = c; - } - } + private Component getAccordionTest() { + Accordion a = new Accordion(); + a.setCaption("Accordion"); + a.setHeight("100%"); + a.addTab(getBigComponent(), "Tab 1"); + a.addTab(getBigComponent(), "Tab 2"); + a.addTab(getBigComponent(), "Tab 3"); + return a; + } - final Label l = l50; - button = new Button("Scroll to label 50", new Button.ClickListener() { + private Component getSubWindowTest() { + Button b = new Button("Open subwindow", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - getLayout().getRoot().scrollIntoView(l); + Window w = new Window("Subwindow"); + w.center(); + w.setHeight("200px"); + w.addComponent(getBigComponent()); + getMainWindow().addWindow(w); } }); - cssLayout.addComponent(button); - button = new Button("Scroll to 100px", new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - p.setScrollTop(100); - } - }); - cssLayout.addComponent(button); - cssLayout.addComponent(p); - - addTest(cssLayout); - - TestUtils - .injectCSS( - getLayout().getRoot(), - "body * {-webkit-user-select: none;} .v-table-row-drag-middle .v-table-cell-content {" - + " background-color: inherit ; border-bottom: 1px solid cyan;" - + "}" - + ".v-table-row-drag-middle .v-table-cell-wrapper {" - + " margin-bottom: -1px;" + "}" + "" - - ); - - addDDSortableTable(); - + return b; } - private void addDDSortableTable() { + private Component getDDSortableTableTest() { final Table table; table = new Table(); table.setCaption("DD sortable table with context menus"); @@ -219,7 +270,7 @@ public class TouchScrollables extends TestBase { } }); - addTest(table); + return table; } private void populateTable(Table table) { @@ -238,21 +289,17 @@ public class TouchScrollables extends TestBase { } - private Component testComponent; - - private void addTest(final AbstractComponent t) { - Button button = new Button(t.getCaption()); - testSelector.addComponent(button); - button.addListener(new Button.ClickListener() { + private void addTest(final Component t) { + testSelector.addComponent(t); + } - public void buttonClick(ClickEvent event) { - if (testComponent != null) { - getLayout().removeComponent(testComponent); - } - testComponent = t; - getLayout().addComponent(t); - } - }); + private Component getBigComponent() { + Layout l = new VerticalLayout(); + for (int i = 0; i < 100; i++) { + Label c = new Label("Label" + i); + l.addComponent(c); + } + return l; } @Override diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.html b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.html new file mode 100644 index 0000000000..2d58d0e2e1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.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="" /> +<title>ButtonHtml</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">ButtonHtml</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.button.ButtonHtml?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>initial</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsbuttonButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>after_1_click</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsbuttonButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>after_2_clicks</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.java b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.java new file mode 100644 index 0000000000..253de5b43c --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/button/ButtonHtml.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.button; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class ButtonHtml extends TestBase { + + @Override + protected void setup() { + Button b = new Button("<b>Plain text button</b>"); + addComponent(b); + + b = new Button( + "<span style=\"color: red; font-weight: bold;\">HTML</span> button"); + b.setHtmlContentAllowed(true); + addComponent(b); + + final Button swapButton = new Button("<i>Swap button<i>"); + swapButton.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + swapButton.setHtmlContentAllowed(!swapButton + .isHtmlContentAllowed()); + } + }); + addComponent(swapButton); + } + + @Override + protected String getDescription() { + return "Verify that Button HTML rendering works"; + } + + @Override + protected Integer getTicketNumber() { + return 8663; + } +} diff --git a/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java b/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java new file mode 100644 index 0000000000..37b0fe21a1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java @@ -0,0 +1,62 @@ +package com.vaadin.tests.components.combobox; + +import com.vaadin.tests.components.AbstractTestCase; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; +import com.vaadin.ui.Root; +import com.vaadin.ui.Select; + +@SuppressWarnings("serial") +public class GridLayoutComboBoxZoomOut extends AbstractTestCase { + + @Override + public void init() { + Root.LegacyWindow mainWindow = new Root.LegacyWindow( + "Gridlayoutbug Application"); + setMainWindow(mainWindow); + + Label description = new Label( + "Open this application in Chrome, zoom out (cmd + \"-\") and " + + "open the ComboBox for weird behaviour."); + mainWindow.addComponent(description); + + Layout formLayout = new GridLayout(2, 1); + // formLayout.setWidth("100%"); + formLayout.setWidth("1000px"); + + Select countryField = new ComboBox(); + countryField.addItem("Finland"); + countryField.addItem("Sweden"); + countryField.addItem("Canada"); + countryField.addItem("USA"); + countryField.setCaption("Country"); + countryField.setWidth("100%"); + formLayout.addComponent(countryField); + + Select statusField = new ComboBox(); + statusField.addItem("Available"); + statusField.addItem("On vacation"); + statusField.addItem("Busy"); + statusField.addItem("Left the building"); + statusField.setCaption("Status"); + statusField.setWidth("100%"); + formLayout.addComponent(statusField); + + mainWindow.addComponent(formLayout); + } + + @Override + protected String getDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java index de08477dd3..b8c5be57bf 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java @@ -25,6 +25,10 @@ public class InlineDateFields extends ComponentTestCase<InlineDateField> { @Override protected void initializeComponents() { + InlineDateField hidden = new InlineDateField(); + hidden.setVisible(false); // Used to break rest of layout #8693 + addComponent(hidden); + Locale locale = LOCALES[0]; InlineDateField pd = createInlineDateField("Undefined width", "-1", diff --git a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldsHiddenOnStart.html b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldsHiddenOnStart.html new file mode 100644 index 0000000000..6b79ef419b --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldsHiddenOnStart.html @@ -0,0 +1,26 @@ +<?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.datefield.InlineDateFields?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFields::PID_SLocale-en_US-undefined-wide/VCalendarPanel[0]#header</td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.html b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.html new file mode 100644 index 0000000000..8a1b21c35d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.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="" /> +<title>NativeButtonHtml</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">NativeButtonHtml</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.nativebutton.NativeButtonHtml?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>initial</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsnativebuttonNativeButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VNativeButton[0]</td> + <td>116,9</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>after_1_click</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsnativebuttonNativeButtonHtml::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VNativeButton[0]</td> + <td>74,10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>after_2_clicks</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java new file mode 100644 index 0000000000..011439f810 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java @@ -0,0 +1,41 @@ +package com.vaadin.tests.components.nativebutton; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.NativeButton; + +public class NativeButtonHtml extends TestBase { + + @Override + protected void setup() { + NativeButton b = new NativeButton("<b>Plain text button</b>"); + addComponent(b); + + b = new NativeButton( + "<span style=\"color: red; font-weight: bold;\">HTML</span> button"); + b.setHtmlContentAllowed(true); + addComponent(b); + + final NativeButton swapButton = new NativeButton("<i>Swap button<i>"); + swapButton.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + swapButton.setHtmlContentAllowed(!swapButton + .isHtmlContentAllowed()); + } + }); + addComponent(swapButton); + } + + @Override + protected String getDescription() { + return "Verify that NativeButton HTML rendering works"; + } + + @Override + protected Integer getTicketNumber() { + // 8663 was for normal button (see ButtonHtml test) + return null; + } +} diff --git a/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html new file mode 100644 index 0000000000..5364b1cd1e --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.html @@ -0,0 +1,97 @@ +<?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://arturwin.office.itmill.com:9999/" /> +<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.table.TableWithContainerRequiringEqualsForItemId?debug&restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[0]</td> + <td>523,81</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> + <td>1. Button Button999 clicked</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> + <td>2. Button Button985 clicked</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>19,7</td> +</tr> +<tr> + <td>contextmenu</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>0</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> + <td>3. Button Button0 clicked</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>8,15</td> +</tr> +<tr> + <td>contextmenu</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>999</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithContainerRequiringEqualsForItemId::PID_SLog_row_0</td> + <td>4. Button Button999 clicked</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java new file mode 100644 index 0000000000..1b0335b673 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java @@ -0,0 +1,128 @@ +package com.vaadin.tests.components.table; + +import java.util.Date; + +import com.vaadin.data.util.BeanContainer; +import com.vaadin.data.util.BeanItem; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Component; +import com.vaadin.ui.Table; +import com.vaadin.ui.themes.Reindeer; + +public class TableWithContainerRequiringEqualsForItemId extends TestBase { + + private MyEntityContainer container = new MyEntityContainer(); + private Log log = new Log(10); + + public static class MyEntityContainer extends BeanContainer<Long, MyEntity> { + + public MyEntityContainer() { + super(MyEntity.class); + setBeanIdResolver(new BeanIdResolver<Long, TableWithContainerRequiringEqualsForItemId.MyEntity>() { + + public Long getIdForBean(MyEntity bean) { + // Return a new instance every time to ensure Table can + // handle it + return new Long(bean.getId()); + } + }); + + } + + @Override + public Long getIdByIndex(int index) { + // Explicitly get the id using the resolver to make sure the + // instance does not stay the same + BeanItem<MyEntity> beanItem = getItem(super.getIdByIndex(index)); + return getBeanIdResolver().getIdForBean(beanItem.getBean()); + }; + + } + + @Override + protected void setup() { + Table t = new Table("Table with 1000 item"); + t.addGeneratedColumn("Actions", new Table.ColumnGenerator() { + public Component generateCell(final Table source, + final Object itemId, final Object columnId) { + Button tripFolderLink = new Button("Button" + itemId); + tripFolderLink.addListener(new Button.ClickListener() { + public void buttonClick(final ClickEvent event) { + log.log("Button " + event.getButton().getCaption() + + " clicked"); + } + }); + tripFolderLink.setStyleName(Reindeer.BUTTON_SMALL); + return tripFolderLink; + } + }); + + for (int i = 0; i < 1000; i++) { + MyEntity myEntity = new MyEntity(i + "st"); + myEntity.setCreated(new Date(new Date().getTime() - 24 * 60 * 60 + * 1000L)); + myEntity.setId(i); + container.addBean(myEntity); + // entityProvider.addEntity(myEntity); + } + + t.setContainerDataSource(container); + t.setVisibleColumns(new String[] { "id", "created", "name", "Actions" }); + + addComponent(t); + addComponent(log); + + t.sort(new Object[] { "id" }, new boolean[] { false }); + + } + + @Override + protected String getDescription() { + return "Test that verifies that Table works correctly with containers which do not return the same instance of the itemId object but instead requires an itemId.equals(otherItemId) check"; + } + + @Override + protected Integer getTicketNumber() { + return 8712; + } + + public static class MyEntity { + + private long id; + + private String name; + + private Date created; + + public MyEntity() { + } + + public MyEntity(String string) { + name = string; + } + + public String getName() { + return name; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + } + +} diff --git a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.html b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.html new file mode 100644 index 0000000000..fd45e7284d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.html @@ -0,0 +1,71 @@ +<?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>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.dd.NotPaintedAcceptSource?restartApplication</td> + <td></td> +</tr> +<!--Drag value 0 to target--> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>50,9</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>124,20</td> +</tr> +<!--Assert drag was successful--> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>Source 1 value 0</td> +</tr> +<!--Swap source and verify it was properly painted--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>Source 2</td> +</tr> +<!--Drag value 0 from source 2 and verify--> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>19,8</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td> + <td>139,18</td> +</tr> +<tr> + <td>contextmenu</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsddNotPaintedAcceptSource::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td> + <td>Source 2 value 0</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java new file mode 100644 index 0000000000..74774f09ab --- /dev/null +++ b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java @@ -0,0 +1,91 @@ +package com.vaadin.tests.dd; + +import com.vaadin.data.Item; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.event.dd.acceptcriteria.SourceIs; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.TableDragMode; +import com.vaadin.ui.Table.TableTransferable; + +public class NotPaintedAcceptSource extends TestBase { + + @Override + protected void setup() { + final Table source1 = createTable("Source 1"); + final Table source2 = createTable("Source 2"); + final Table target = createTable("Target"); + + source1.setDragMode(TableDragMode.ROW); + source2.setDragMode(TableDragMode.ROW); + + target.setDropHandler(new DropHandler() { + public AcceptCriterion getAcceptCriterion() { + return new SourceIs(source1, source2); + } + + public void drop(DragAndDropEvent event) { + TableTransferable transferable = (TableTransferable) event + .getTransferable(); + Item item = transferable.getSourceComponent().getItem( + transferable.getItemId()); + Object value = item.getItemProperty("value").getValue(); + AbstractSelectTargetDetails targetDetails = (AbstractSelectTargetDetails) event + .getTargetDetails(); + Object targetItemId = targetDetails.getItemIdOver(); + Object addItemAfter = target.addItemAfter(targetItemId); + target.getItem(addItemAfter).getItemProperty("value") + .setValue(value); + transferable.getSourceComponent().removeItem( + transferable.getItemId()); + } + }); + + final HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.setSpacing(true); + horizontalLayout.addComponent(source1); + horizontalLayout.addComponent(target); + + addComponent(horizontalLayout); + + addComponent(new Button("Swap sources", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + if (source1.getParent() != null) { + horizontalLayout.replaceComponent(source1, source2); + } else { + horizontalLayout.replaceComponent(source2, source1); + } + target.requestRepaint(); + } + })); + + } + + private Table createTable(String caption) { + Table table = new Table(caption); + table.addContainerProperty("value", String.class, ""); + for (int i = 0; i < 10; i++) { + table.addItem(new Object[] { caption + " value " + i }, + Integer.valueOf(i)); + } + table.setWidth("300px"); + return table; + } + + @Override + protected String getDescription() { + return "Including a component in an accept criterion when the actual component is not included in a layout and thus not painted should still allow painting the component properly when it is added to a layout."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8730); + } + +} diff --git a/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html b/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html index 4bc409b881..8408aba9fd 100644 --- a/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html +++ b/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html @@ -13,7 +13,7 @@ </thead><tbody> <tr> <td>open</td> - <td>/run/com.vaadin.tests.layouts.layouttester.LayoutTesterApplication</td> + <td>/run/com.vaadin.tests.layouts.layouttester.LayoutTesterApplication?restartApplication</td> <td></td> </tr> <tr> |