From e63b51a831676bdcc15b889c1636c0dcccbc0bc0 Mon Sep 17 00:00:00 2001 From: Pekka Hyvönen Date: Mon, 12 Dec 2016 16:32:59 +0200 Subject: Change Upload to be in immediate mode by default (#111) Fixes vaadin/framework8-issues#547 --- server/src/main/java/com/vaadin/ui/Upload.java | 12 ++++++++---- .../tests/server/component/upload/UploadDeclarativeTest.java | 12 ++++++++++++ .../com/vaadin/tests/server/component/upload/UploadTest.java | 8 ++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) (limited to 'server/src') diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index 866bc96d25..d67fa07641 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -1128,11 +1128,13 @@ public class Upload extends AbstractComponent /** * Sets the immediate mode of the upload. *

- * If the upload is in immediate mode, it displays the browser file choosing - * button immediately, whereas a non-immediate upload only shows a Vaadin - * button. + * If the upload is in immediate mode, the file upload is started + * immediately after the user has selected the file. *

- * The default mode of an Upload component is non-immediate. + * If the upload is not in immediate mode, after selecting the file the user + * must click another button to start the upload. + *

+ * The default mode of an Upload component is immediate. * * @param immediateMode * {@code true} for immediate mode, {@code false} for not @@ -1143,6 +1145,8 @@ public class Upload extends AbstractComponent /** * Returns the immediate mode of the upload. + *

+ * The default mode of an Upload component is immediate. * * @return {@code true} if the upload is in immediate mode, {@code false} if * the upload is not in immediate mode diff --git a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java index d84a32c7b5..22695f3918 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java @@ -15,6 +15,7 @@ */ package com.vaadin.tests.server.component.upload; +import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.design.DeclarativeTestBase; @@ -58,4 +59,15 @@ public class UploadDeclarativeTest extends DeclarativeTestBase { public void testWriteEmpty() { testWrite("", new Upload()); } + + @Test + public void testImmediateModeDefault() { + Assert.assertTrue( + testRead("", new Upload()).isImmediateMode()); + + Upload upload = new Upload(); + upload.setImmediateMode(false); + Assert.assertFalse(testRead("", upload) + .isImmediateMode()); + } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java index 5620e48a97..a2364b132d 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java @@ -41,6 +41,14 @@ public class UploadTest { Assert.assertFalse(upload.isUploading()); } + @Test + public void setImmediateMode_defaultTrue() { + Upload upload = new Upload(); + + Assert.assertTrue("Upload should be in immediate mode by default", + upload.isImmediateMode()); + } + @Test public void getState_uploadHasCustomState() { TestUpload upload = new TestUpload(); -- cgit v1.2.3