diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2016-12-12 16:32:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-12 16:32:59 +0200 |
commit | e63b51a831676bdcc15b889c1636c0dcccbc0bc0 (patch) | |
tree | d1a9a81d394b9e44830d106bda0b5fed76dc596d /server | |
parent | f1f4be9dc2134270256d8338f9cac562bc1ba1fd (diff) | |
download | vaadin-framework-e63b51a831676bdcc15b889c1636c0dcccbc0bc0.tar.gz vaadin-framework-e63b51a831676bdcc15b889c1636c0dcccbc0bc0.zip |
Change Upload to be in immediate mode by default (#111)
Fixes vaadin/framework8-issues#547
Diffstat (limited to 'server')
3 files changed, 28 insertions, 4 deletions
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. * <p> - * 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. * <p> - * 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. + * <p> + * 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. + * <p> + * 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<Upload> { public void testWriteEmpty() { testWrite("<vaadin-upload />", new Upload()); } + + @Test + public void testImmediateModeDefault() { + Assert.assertTrue( + testRead("<v-upload />", new Upload()).isImmediateMode()); + + Upload upload = new Upload(); + upload.setImmediateMode(false); + Assert.assertFalse(testRead("<v-upload immediate-mode=false />", 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 @@ -42,6 +42,14 @@ public class UploadTest { } @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(); UploadState state = upload.getState(); |