diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-05-17 15:10:48 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-05-17 15:10:48 +0300 |
commit | 9b6b735752e2f30bcdf6a521e031a8de22343bb0 (patch) | |
tree | cb40f3a2bb238057a3875aa4d2581ecda83667a7 /uitest | |
parent | 2f6d5e0d8c7cf4912bb82207c0dbe26101d168cb (diff) | |
parent | 42545ac81ae49cb9a3af2a8b3b06ba9525886b22 (diff) | |
download | vaadin-framework-9b6b735752e2f30bcdf6a521e031a8de22343bb0.tar.gz vaadin-framework-9b6b735752e2f30bcdf6a521e031a8de22343bb0.zip |
Merge changes from origin/7.0
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)
29eeda5 Merge "Clean up Table popup menu close handler to prevent a memory leak" from 6.8 (#11840)
6d7f5e4 Eliminate unnecessary conversions of option keys
b8c6a15 Clear items in ComboBox only if changed (#10924)
42545ac Fix NPE if there's no query in the URI (#11836)
Change-Id: I2e50ba59b45720a879c6e476333369523a730b9c
Diffstat (limited to 'uitest')
4 files changed, 246 insertions, 0 deletions
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..ec6cf0c57d 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,68 @@ 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 + String query = getPage().getLocation().getQuery(); + if (query != null && query.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() { diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboPushTiming.java b/uitest/src/com/vaadin/tests/components/combobox/ComboPushTiming.java new file mode 100644 index 0000000000..fe2cffdc4c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboPushTiming.java @@ -0,0 +1,110 @@ +package com.vaadin.tests.components.combobox; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.event.FieldEvents; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.server.VaadinSession; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.ProgressIndicator; +import com.vaadin.ui.TextField; + +public class ComboPushTiming extends TestBase { + + private int counter = 0; + private final MyExecutor executor = new MyExecutor(); + + @Override + protected void setup() { + + List<String> list = new ArrayList<String>(); + for (int i = 0; i < 100; i++) { + list.add("Item " + i); + } + + final ComboBox cb = new ComboBox("Combobox", list); + cb.setImmediate(true); + cb.setInputPrompt("Enter text"); + cb.setDescription("Some Combobox"); + addComponent(cb); + + final ObjectProperty<String> log = new ObjectProperty<String>(""); + + cb.addListener(new FieldEvents.FocusListener() { + @Override + public void focus(FocusEvent event) { + log.setValue(log.getValue().toString() + "<br>" + counter + + ": Focus event!"); + counter++; + changeValue(cb); + } + }); + + cb.addListener(new FieldEvents.BlurListener() { + @Override + public void blur(BlurEvent event) { + log.setValue(log.getValue().toString() + "<br>" + counter + + ": Blur event!"); + counter++; + } + }); + + TextField field = new TextField("Some textfield"); + field.setImmediate(true); + addComponent(field); + + Label output = new Label(log); + output.setCaption("Events:"); + + output.setContentMode(ContentMode.HTML); + addComponent(output); + + ProgressIndicator progressIndicator = new ProgressIndicator(); + addComponent(progressIndicator); + progressIndicator.setPollingInterval(3000); + } + + private void changeValue(final ComboBox cb) { + executor.execute(new Runnable() { + public void run() { + VaadinSession.getCurrent().lock(); + try { + cb.setEnabled(true); + cb.setValue("B"); + cb.setEnabled(true); + + // If this isn't sent by push or poll in the background, the + // problem will go away + } finally { + VaadinSession.getCurrent().unlock(); + } + } + }); + } + + class MyExecutor extends ThreadPoolExecutor { + public MyExecutor() { + super(5, 20, 20, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); + } + } + + @Override + protected String getDescription() { + return "When an update is received while the popup is open, the suggestion popup blurs away"; + } + + @Override + protected Integer getTicketNumber() { + return 10924; + } + +} |