From a6c37ff58af1088c03d6ca3e8c9c09f893e97dda Mon Sep 17 00:00:00 2001 From: John Alhroos Date: Mon, 17 May 2010 10:14:28 +0000 Subject: [PATCH] Added Test application and TB test for #4582 svn changeset:13210/svn branch:6.3 --- .../com/vaadin/tests/tickets/Ticket4582.html | 42 ++++++ .../com/vaadin/tests/tickets/Ticket4582.java | 133 ++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 tests/src/com/vaadin/tests/tickets/Ticket4582.html create mode 100644 tests/src/com/vaadin/tests/tickets/Ticket4582.java diff --git a/tests/src/com/vaadin/tests/tickets/Ticket4582.html b/tests/src/com/vaadin/tests/tickets/Ticket4582.html new file mode 100644 index 0000000000..ff38dbc988 --- /dev/null +++ b/tests/src/com/vaadin/tests/tickets/Ticket4582.html @@ -0,0 +1,42 @@ + + + + + + +Ticket4582 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Ticket4582
open/run/com.vaadin.tests.tickets.Ticket4582?restartApplication
waitForVaadin
clickvaadin=runcomvaadinteststicketsTicket4582::/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
screenCapture
+ + diff --git a/tests/src/com/vaadin/tests/tickets/Ticket4582.java b/tests/src/com/vaadin/tests/tickets/Ticket4582.java new file mode 100644 index 0000000000..7e93ba249a --- /dev/null +++ b/tests/src/com/vaadin/tests/tickets/Ticket4582.java @@ -0,0 +1,133 @@ +package com.vaadin.tests.tickets; + +import java.util.Date; + +import com.vaadin.Application; +import com.vaadin.data.Item; +import com.vaadin.data.util.BeanItem; +import com.vaadin.ui.Button; +import com.vaadin.ui.Component; +import com.vaadin.ui.DateField; +import com.vaadin.ui.DefaultFieldFactory; +import com.vaadin.ui.Field; +import com.vaadin.ui.Form; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; +import com.vaadin.ui.Button.ClickEvent; + +public class Ticket4582 extends Application{ + + @SuppressWarnings("serial") + public class TestCaseWindow extends Window { + + public class MyBean{ + private Date myDate; + private String myString; + + public Date getMyDate() { + return myDate; + } + + public void setMyDate(Date myDate) { + this.myDate = myDate; + } + + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + + } + private MyBean myBean; + + public TestCaseWindow() { + super("Test Case Window"); + setModal(true); + setWidth("400px"); + myBean = new MyBean(); + + + initWindow(); + } + + protected class CustomerFieldFactory extends DefaultFieldFactory { + + public static final String COMMON_FIELD_WIDTH = "12em"; + + @Override + public Field createField(Item item, Object propertyId, Component uiContext) { + Field f = super.createField(item, propertyId, uiContext); + + if ("myDate".equals(propertyId)) { + ((DateField) f).setResolution(DateField.RESOLUTION_MIN); + ((DateField) f).setCaption("This is my date"); + + } + + return f; + } + } + + protected void initWindow() { + VerticalLayout layout = (VerticalLayout) getContent(); + layout.setMargin(true); + layout.setSpacing(true); + + /** + * This causes the window to add the .v-readonly style! + */ + setClosable(false); + + CustomerFieldFactory fieldFactory = new CustomerFieldFactory(); + final Form generalForm = new Form(); + { + generalForm.setCaption("My form"); + generalForm.setWriteThrough(true); + generalForm.setFormFieldFactory(fieldFactory); + + BeanItem myBeanItem = new BeanItem(myBean); + generalForm.setItemDataSource(myBeanItem); + + generalForm.setVisibleItemProperties(new String[]{"myDate","myString"}); + generalForm.setValidationVisible(true); + addComponent(generalForm); + } + + + HorizontalLayout buttons = new HorizontalLayout(); + { + buttons.setSpacing(true); + + + Button b = new Button("Close", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ((Window) getParent()).removeWindow(TestCaseWindow.this); + } + }); + buttons.addComponent(b); + layout.addComponent(buttons); + + } + } + } + + @Override + public void init() { + Window mainWindow = new Window(); + setMainWindow(mainWindow); + Button open = new Button("Open window", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + getMainWindow().addWindow(new TestCaseWindow()); + } + }); + + mainWindow.addComponent(open); + } + +} -- 2.39.5