summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-16 17:24:54 +0200
committerArtur Signell <artur@vaadin.com>2012-11-19 12:33:26 +0200
commit02a808548472a8aa66631fdbf5ee119b24061a92 (patch)
tree33fbd1105e7d55d6cfad83a1256e4f3608f6a334 /uitest
parent17ec88776b8ef9118d964b7de54f492aaaa64f26 (diff)
downloadvaadin-framework-02a808548472a8aa66631fdbf5ee119b24061a92.tar.gz
vaadin-framework-02a808548472a8aa66631fdbf5ee119b24061a92.zip
Fix NPE when removing FileDownloader (#10198)
Change-Id: I2423e3fbe88becfd76ed17c15d911d9253bf6e35
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/FileDownloaderTest.html36
-rw-r--r--uitest/src/com/vaadin/tests/components/FileDownloaderTest.java36
2 files changed, 71 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/components/FileDownloaderTest.html b/uitest/src/com/vaadin/tests/components/FileDownloaderTest.html
new file mode 100644
index 0000000000..bfe87091cc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/FileDownloaderTest.html
@@ -0,0 +1,36 @@
+<?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: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.FileDownloaderTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementPresent</td>
+ <td>vaadin=runcomvaadintestscomponentsFileDownloaderTest::PID_Scom.vaadin.ui.ButtonDynamicimage/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsFileDownloaderTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentsFileDownloaderTest::PID_Scom.vaadin.ui.ButtonDynamicimage/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/FileDownloaderTest.java b/uitest/src/com/vaadin/tests/components/FileDownloaderTest.java
index e773c8c75b..55d2afd32d 100644
--- a/uitest/src/com/vaadin/tests/components/FileDownloaderTest.java
+++ b/uitest/src/com/vaadin/tests/components/FileDownloaderTest.java
@@ -37,6 +37,7 @@ import com.vaadin.server.StreamResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinResponse;
import com.vaadin.tests.components.embedded.EmbeddedPdf;
+import com.vaadin.tests.util.Log;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -45,12 +46,18 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
import com.vaadin.ui.NativeButton;
public class FileDownloaderTest extends AbstractTestUI {
+ private AbstractComponent firstDownloadComponent;
+ private Log log = new Log(5);
+
@Override
protected void setup(VaadinRequest request) {
+ addComponent(log);
+
List<Class<? extends Component>> components = new ArrayList<Class<? extends Component>>();
components.add(Button.class);
components.add(NativeButton.class);
@@ -104,6 +111,29 @@ public class FileDownloaderTest extends AbstractTestUI {
// addComponents(resource, components);
resource = new ClassResource(new EmbeddedPdf().getClass(), "test.pdf");
addComponents("Class resource pdf", resource, components);
+
+ addComponent(new Button("Remove first download button",
+ new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Layout parent = (Layout) firstDownloadComponent
+ .getParent();
+ parent.removeComponent(firstDownloadComponent);
+ }
+ }));
+ addComponent(new Button(
+ "Detach FileDownloader from first download button",
+ new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ FileDownloader e = (FileDownloader) firstDownloadComponent
+ .getExtensions().iterator().next();
+ e.removeFromTarget();
+ log.log("FileDownload detached");
+ }
+ }));
}
public void addComponents(String caption, ConnectorResource resource,
@@ -113,7 +143,11 @@ public class FileDownloaderTest extends AbstractTestUI {
for (Class<? extends Component> cls : components) {
try {
AbstractComponent c = (AbstractComponent) cls.newInstance();
- c.setId(cls.getName());
+ if (firstDownloadComponent == null) {
+ firstDownloadComponent = c;
+ }
+
+ c.setId(cls.getName() + caption.replace(" ", ""));
c.setCaption(cls.getName());
c.setDescription(resource.getMIMEType() + " / "
+ resource.getClass());