diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-05-17 16:29:58 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-05-17 16:29:59 +0300 |
commit | 71d2af2a6b3b2f4d1cce608a32e69e77ee585104 (patch) | |
tree | b5eb29ad5621b0a6e2d2457c90dcae140eef07c9 | |
parent | f7ee755e7dd94612c84e0b99735cc602fdbe7634 (diff) | |
parent | 936439dfe4be81637e63f539e281e190c1155460 (diff) | |
download | vaadin-framework-71d2af2a6b3b2f4d1cce608a32e69e77ee585104.tar.gz vaadin-framework-71d2af2a6b3b2f4d1cce608a32e69e77ee585104.zip |
Merge changes from origin/7.1
55ea6dc More specific workaround for no rows in TreeTable with pagelenght = 0 (#9203)
dca728c Warn if using old widgetset (#11836)
936439d Verify that tests are run with the expected JRE version (#11835)
Change-Id: I0a19ce453cd4215d3bc48a67494d06ff4fe85e8e
6 files changed, 292 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index d9dd542b15..b03fa945cd 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -2104,6 +2104,15 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * might have been (incorrectly) calculated earlier */ + /* + * TreeTable updates stuff in a funky order, so we must set the + * height as zero here before doing the real update to make it + * realize that there is no content, + */ + if (pageLength == totalRows && pageLength == 0) { + scrollBody.setHeight("0px"); + } + int bodyHeight; if (pageLength == totalRows) { /* @@ -4796,8 +4805,20 @@ public class VScrollTable extends FlowPanel implements HasWidgets, prepx = 0; } preSpacer.getStyle().setPropertyPx("height", prepx); - int postpx = measureRowHeightOffset(totalRows - 1) - - measureRowHeightOffset(lastRendered); + int postpx; + if (pageLength == 0 && totalRows == pageLength) { + /* + * TreeTable depends on having lastRendered out of sync in some + * situations, which makes this method miss the special + * situation in which one row worth of post spacer to be added + * if there are no rows in the table. #9203 + */ + postpx = measureRowHeightOffset(1); + } else { + postpx = measureRowHeightOffset(totalRows - 1) + - measureRowHeightOffset(lastRendered); + } + if (postpx < 0) { postpx = 0; } diff --git a/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.html b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.html new file mode 100644 index 0000000000..e8cb0ccfe6 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.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>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.treetable.RowHeightWithoutRows?restartApplication=</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>two</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstreetableRowHeightWithoutRows::/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>empty</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstreetableRowHeightWithoutRows::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>five</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java new file mode 100644 index 0000000000..5e94fc1270 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java @@ -0,0 +1,87 @@ +package com.vaadin.tests.components.treetable; + +import com.vaadin.data.util.BeanItemContainer; +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.TreeTable; + +public class RowHeightWithoutRows extends TestBase { + + private TreeTable treeTable = new TreeTable(); + + private BeanItemContainer<User> container = new BeanItemContainer<User>( + User.class); + + @Override + public void setup() { + treeTable.setContainerDataSource(container); + treeTable.setPageLength(0); + + addComponent(treeTable); + + Button refresh = new Button("Add two elements"); + addComponent(refresh); + refresh.addListener(new ClickListener() { + public void buttonClick(ClickEvent event) { + addTwoElements(); + } + }); + + Button reset = new Button("Reset"); + addComponent(reset); + reset.addListener(new ClickListener() { + public void buttonClick(ClickEvent event) { + container.removeAllItems(); + } + }); + + Button refresh5 = new Button("Add five elements"); + addComponent(refresh5); + refresh5.addListener(new ClickListener() { + public void buttonClick(ClickEvent event) { + container.addBean(new User("John", "Doe")); + container.addBean(new User("Mark", "Twain")); + container.addBean(new User("M", "T")); + container.addBean(new User("J", "D")); + container.addBean(new User("J", "T")); + } + }); + addTwoElements(); + } + + private void addTwoElements() { + container.addBean(new User("John", "Doe")); + container.addBean(new User("Mark", "Twain")); + } + + public static class User { + private String firstName; + + private String lastName; + + public User(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + } + + @Override + protected String getDescription() { + return "Reseting the tree table and then adding five elements should properly update the height of the TreeTable"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(9203); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/VerifyJreVersion.html b/uitest/src/com/vaadin/tests/VerifyJreVersion.html new file mode 100644 index 0000000000..abf53883c1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/VerifyJreVersion.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.VerifyJreVersion?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsVerifyJreVersion::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]</td> + <td>Using Java 1.6.0_32 by Sun Microsystems Inc.</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/VerifyJreVersion.java b/uitest/src/com/vaadin/tests/VerifyJreVersion.java new file mode 100644 index 0000000000..fe3e4bd870 --- /dev/null +++ b/uitest/src/com/vaadin/tests/VerifyJreVersion.java @@ -0,0 +1,45 @@ +/* + * 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; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +public class VerifyJreVersion extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + String jreVersion = "Using Java " + System.getProperty("java.version") + + " by " + System.getProperty("java.vendor"); + addComponent(new Label(jreVersion)); + } + + @Override + protected String getTestDescription() { + return "Test used to detect when the JRE used to run these tests have changed."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(11835); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index a044b52f18..45809e3270 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -1,10 +1,16 @@ package com.vaadin.tests.components; +import java.io.File; + +import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; import com.vaadin.server.WebBrowser; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Component; import com.vaadin.ui.Label; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Notification.Type; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; @@ -27,9 +33,67 @@ public abstract class AbstractTestUI extends UI { rootLayout.addComponent(layout); ((VerticalLayout) getContent()).setExpandRatio(layout, 1); + warnIfWidgetsetMaybeNotCompiled(); + setup(request); } + protected void warnIfWidgetsetMaybeNotCompiled() { + // Ignore if using debug mode + if (getPage().getLocation().getQuery().matches(".*[&?]gwt\\.codesvr.*")) { + return; + } + + // Find out the widgetset of this UI based on @Widgetset annotation + Class<?> currentType = getClass(); + String usedWidgetset = VaadinServlet.DEFAULT_WIDGETSET; + while (currentType != Object.class) { + Widgetset annotation = currentType.getAnnotation(Widgetset.class); + if (annotation != null) { + usedWidgetset = annotation.value(); + break; + } else { + currentType = currentType.getSuperclass(); + } + } + + // Assuming the same folder structure as in git repo + // Assuming project root is the working dir of this process + File widgetsetsFolder = new File("WebContent/VAADIN/widgetsets"); + if (!widgetsetsFolder.isDirectory()) { + return; + } + + // Find the most newly compiled widgetset + long newestWidgetsetTimestamp = -1; + String newestWidgetsetName = null; + File[] children = widgetsetsFolder.listFiles(); + for (File child : children) { + if (!child.isDirectory() || child.getName().equals("WEB-INF")) { + continue; + } + long lastModified = child.lastModified(); + if (lastModified > newestWidgetsetTimestamp) { + newestWidgetsetTimestamp = lastModified; + newestWidgetsetName = child.getName(); + } + } + + // Compare to currently used widgetset, with a 30 minute grace period + File currentWidgetsetFolder = new File(widgetsetsFolder, usedWidgetset); + long currentWidgetsetTimestamp = currentWidgetsetFolder.lastModified(); + int halfHour = 30 * 60 * 1000; + if (currentWidgetsetTimestamp + halfHour < newestWidgetsetTimestamp) { + Notification + .show("The currently used widgetset (" + + usedWidgetset + + ") was compiled long before the most recently compiled one (" + + newestWidgetsetName + + "). Are you sure you have compiled the right widgetset?", + Type.WARNING_MESSAGE); + } + } + private VerticalLayout layout; protected VerticalLayout getLayout() { |