From 2607f1c317f8e85e145fd346fb630fa255eceaf6 Mon Sep 17 00:00:00 2001 From: Marko Grönroos Date: Tue, 4 Jan 2011 13:07:42 +0000 Subject: Test case for #5927. svn changeset:16791/svn branch:6.5 --- .../tests/components/datefield/CommitInvalid.java | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/datefield/CommitInvalid.java diff --git a/tests/src/com/vaadin/tests/components/datefield/CommitInvalid.java b/tests/src/com/vaadin/tests/components/datefield/CommitInvalid.java new file mode 100644 index 0000000000..9ce38624e8 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/datefield/CommitInvalid.java @@ -0,0 +1,65 @@ +package com.vaadin.tests.components.datefield; + +import java.util.Date; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.DateField; +import com.vaadin.ui.Form; +import com.vaadin.ui.Label; + +public class CommitInvalid extends TestBase { + + @Override + protected String getDescription() { + return "DateField with error is committed regardless of the invalidity."; + } + + @Override + protected Integer getTicketNumber() { + return 5927; + } + + @Override + protected void setup() { + final Form form = new Form(); + addComponent(form); + + @SuppressWarnings("deprecation") + ObjectProperty property = new ObjectProperty(new Date( + 2009 - 1900, 4 - 1, 1)); + + final DateField df = new DateField("Year", property); + df.setResolution(DateField.RESOLUTION_DAY); + df.setReadThrough(false); + df.setWriteThrough(false); + df.setImmediate(true); + form.addField("date", df); + + Button validate = new Button("Validate"); + form.getFooter().addComponent(validate); + + Button commit = new Button("Commit"); + form.getFooter().addComponent(commit); + + Label value = new Label("Value"); + addComponent(value); + value.setPropertyDataSource(property); + + validate.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + df.validate(); + } + }); + + commit.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + df.commit(); + } + }); + + + } +} -- cgit v1.2.3