diff options
author | Artur Signell <artur@vaadin.com> | 2013-01-02 11:47:00 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-01-02 11:47:00 +0000 |
commit | cc26765c48ca63542389ae5f6045017876f26620 (patch) | |
tree | 58c2ceccae9060f1c3edcbc6a5fb05d2950a1494 /uitest | |
parent | 7ed4e5e6ff8ca08ab50225ac5c33bed59a226217 (diff) | |
parent | a06d0ef0799d2c1f2f831eefc6a1351093ae85bd (diff) | |
download | vaadin-framework-cc26765c48ca63542389ae5f6045017876f26620.tar.gz vaadin-framework-cc26765c48ca63542389ae5f6045017876f26620.zip |
Merge "Merge of (#9825) test to Vaadin 7."
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.html | 42 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java | 170 |
2 files changed, 212 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.html b/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.html new file mode 100644 index 0000000000..a4e36b6f44 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.html @@ -0,0 +1,42 @@ +<?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://localhost:9999/" /> +<title>ButtonWithShortcutNotRendered</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">ButtonWithShortcutNotRendered</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.button.ButtonWithShortcutNotRendered?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsbuttonButtonWithShortcutNotRendered::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VSplitPanelVertical[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>190,7</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>button-initial</td> +</tr> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.button.ButtonWithShortcutNotRendered</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>button-with-caption</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java b/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java new file mode 100644 index 0000000000..b01e0a85d0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java @@ -0,0 +1,170 @@ +package com.vaadin.tests.components.button; + +import com.vaadin.annotations.PreserveOnRefresh; +import com.vaadin.data.Item; +import com.vaadin.data.Property; +import com.vaadin.data.util.HierarchicalContainer; +import com.vaadin.event.ShortcutAction.KeyCode; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Component; +import com.vaadin.ui.DefaultFieldFactory; +import com.vaadin.ui.Field; +import com.vaadin.ui.Form; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalSplitPanel; + +@PreserveOnRefresh +@SuppressWarnings("deprecation") +public class ButtonWithShortcutNotRendered extends AbstractTestUI { + + @Override + protected String getTestDescription() { + return "Button with shortcut broken if the shortcut is rendered before the button"; + } + + @Override + protected Integer getTicketNumber() { + return 9825; + } + + Button defaultButton; + Button otherButton; + + @SuppressWarnings("unchecked") + @Override + protected void setup(VaadinRequest request) { + getLayout().setWidth(100, Unit.PERCENTAGE); + getLayout().setHeight(null); + getLayout().setMargin(new MarginInfo(true, false, false, false)); + + HierarchicalContainer container = new HierarchicalContainer(); + container.addContainerProperty("t1", String.class, ""); + container.addContainerProperty("t2", String.class, ""); + + Item item = container.addItem("r1"); + item.getItemProperty("t1").setValue("Row1 t1"); + item.getItemProperty("t2").setValue("Row1 t2"); + + item = container.addItem("r2"); + item.getItemProperty("t1").setValue("Row2 t1"); + item.getItemProperty("t2").setValue("Row2 t2"); + + MyForm form = new MyForm(); + MyTable table = new MyTable(form, container); + + VerticalSplitPanel splitPanel = new VerticalSplitPanel(); + splitPanel.setWidth(100, Unit.PERCENTAGE); + splitPanel.setHeight(400, Unit.PIXELS); + splitPanel.setFirstComponent(table); + splitPanel.setSecondComponent(form); + splitPanel.setSplitPosition(50, Unit.PERCENTAGE); + + addComponent(splitPanel); + } + + public class MyTable extends Table { + final MyForm form; + + public MyTable(MyForm pform, HierarchicalContainer container) { + form = pform; + setContainerDataSource(container); + setSelectable(true); + setImmediate(true); + setWidth(100, Unit.PERCENTAGE); + setHeight(null); + + addValueChangeListener(new Property.ValueChangeListener() { + + public void valueChange( + com.vaadin.data.Property.ValueChangeEvent event) { + final Item item = getItem(getValue()); + form.setItemDataSource(item); + } + + }); + } + } + + public class MyForm extends Form implements ClickListener { + final GridLayout layout; + + @SuppressWarnings("unchecked") + public MyForm() { + setWidth(100, Unit.PERCENTAGE); + setHeight(null); + setImmediate(true); + + setFormFieldFactory(new DefaultFieldFactory() { + + @Override + public TextField createField(Item item, Object propertyId, + Component uiContext) { + TextField t = new TextField(); + t.setWidth(100, Unit.PERCENTAGE); + t.setHeight(null); + t.setCaption((String) propertyId); + t.setImmediate(false); + return t; + } + }); + + layout = new GridLayout(2, 1); + layout.setWidth(100, Unit.PERCENTAGE); + layout.setHeight(null); + layout.setColumnExpandRatio(0, 0.5f); + layout.setColumnExpandRatio(1, 0.5f); + layout.setMargin(true); + layout.setSpacing(true); + setLayout(layout); + + HorizontalLayout footer = new HorizontalLayout(); + footer.setSpacing(true); + footer.setMargin(false); + footer.setVisible(false); + setFooter(footer); + + defaultButton = new Button("Default Button", this); + defaultButton.setClickShortcut(KeyCode.ENTER); + footer.addComponent(defaultButton); + + otherButton = new Button("Other button", this); + footer.addComponent(otherButton); + } + + @Override + public void setItemDataSource(Item newDataSource) { + if (newDataSource != null) { + super.setItemDataSource(newDataSource); + layout.setVisible(true); + getFooter().setVisible(true); + } else { + super.setItemDataSource(null); + layout.setVisible(false); + getFooter().setVisible(false); + } + } + + @Override + @SuppressWarnings("rawtypes") + protected void attachField(Object propertyId, Field field) { + if (propertyId.equals("t1")) { + layout.addComponent(field, 0, 0); + } else if (propertyId.equals("t2")) { + layout.addComponent(field, 1, 0); + } + } + + public void buttonClick(ClickEvent event) { + // NOP + } + + } +} |