diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-11-01 20:05:44 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-11-01 20:05:44 +0000 |
commit | 34a1a6f8ca690efc293b999bda9b6c2700cd3f39 (patch) | |
tree | 2e69017fff0fd57c1c709765d67844b705736fe7 | |
parent | 24bc7fa8324d9c32507c4df913ddd237cc43a36f (diff) | |
download | vaadin-framework-34a1a6f8ca690efc293b999bda9b6c2700cd3f39.tar.gz vaadin-framework-34a1a6f8ca690efc293b999bda9b6c2700cd3f39.zip |
Merged (partly manually) test updates from [9345],[9346],[9357]
svn changeset:9556/svn branch:6.2
4 files changed, 365 insertions, 91 deletions
diff --git a/tests/src/com/vaadin/tests/components/ComponentTestCase.java b/tests/src/com/vaadin/tests/components/ComponentTestCase.java new file mode 100644 index 0000000000..3c6d6cbcb3 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/ComponentTestCase.java @@ -0,0 +1,110 @@ +package com.vaadin.tests.components; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.terminal.UserError; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Layout.SpacingHandler; + +public abstract class ComponentTestCase extends TestBase { + + private List<AbstractComponent> testComponents = new ArrayList<AbstractComponent>(); + + @Override + protected void setup() { + ((SpacingHandler) getLayout()).setSpacing(true); + addComponent(createActionLayout()); + } + + @Override + protected String getDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + + protected abstract List<Component> createActions(); + + private Component createActionLayout() { + HorizontalLayout actionLayout = new HorizontalLayout(); + actionLayout.setSpacing(true); + actionLayout.setMargin(true); + for (Component c : createActions()) { + actionLayout.addComponent(c); + } + addComponent(actionLayout); + return actionLayout; + } + + protected void addTestComponent(AbstractComponent c) { + testComponents.add(c); + addComponent(c); + } + + protected List<AbstractComponent> getTestComponents() { + return testComponents; + } + + protected void setErrorIndicators(boolean on) { + for (AbstractComponent c : getTestComponents()) { + if (c == null) { + continue; + } + + if (on) { + c.setComponentError(new UserError("It failed!")); + } else { + c.setComponentError(null); + + } + } + + } + + protected void setRequired(boolean on) { + + for (AbstractComponent c : getTestComponents()) { + if (c == null) { + continue; + } + + if (c instanceof AbstractField) { + ((AbstractField) c).setRequired(on); + } + + } + + } + + protected void setEnabled(boolean on) { + for (AbstractComponent c : getTestComponents()) { + if (c == null) { + continue; + } + + c.setEnabled(on); + } + + } + + protected void setReadOnly(boolean on) { + for (AbstractComponent c : getTestComponents()) { + if (c == null) { + continue; + } + + c.setReadOnly(on); + } + + } + +} diff --git a/tests/src/com/vaadin/tests/components/label/Labels.html b/tests/src/com/vaadin/tests/components/label/Labels.html new file mode 100644 index 0000000000..214db23b4b --- /dev/null +++ b/tests/src/com/vaadin/tests/components/label/Labels.html @@ -0,0 +1,92 @@ +<?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://192.168.2.75:8888/" /> +<title>Labels</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">Labels</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.label.Labels</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>enabled</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentslabelLabels::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>9,9</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentslabelLabels::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>8,2</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>errorindicators</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentslabelLabels::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>0,10</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentslabelLabels::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[0]</td> + <td>2,5</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentslabelLabels::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[1]</td> + <td>0,8</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>disabled</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/label/Labels.java b/tests/src/com/vaadin/tests/components/label/Labels.java new file mode 100644 index 0000000000..a1acf403ee --- /dev/null +++ b/tests/src/com/vaadin/tests/components/label/Labels.java @@ -0,0 +1,132 @@ +package com.vaadin.tests.components.label; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.tests.util.LoremIpsum; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Button.ClickEvent; + +public class Labels extends ComponentTestCase { + + Label label[] = new Label[20]; + + @Override + protected void setup() { + super.setup(); + + Label l; + l = createLabel("This is an undefined wide label which do not wrap. It should be clipped at the end of the screen" + + LoremIpsum.get(1000)); + l.setWidth(null); + addTestComponent(l); + + l = createLabel("This is a 200px wide simple label which wrap"); + l.setWidth("200px"); + addTestComponent(l); + + l = createLabel("This is a 100% wide simple label which should wrap. " + + LoremIpsum.get(1500)); + l.setWidth("100%"); + addTestComponent(l); + + l = createLabel("This is a 100% wide simple with fixed 65px height. It should wrap. " + + LoremIpsum.get(5000)); + l.setWidth("100%"); + l.setHeight("65px"); + addTestComponent(l); + + l = createLabel( + "<div style='border: 1px solid red'><h1>Hello</h1><p/><h2>I am a rich Label</h3></div>", + "This is an XHTML label with rich content"); + l.setContentMode(Label.CONTENT_XHTML); + addTestComponent(l); + + l = createLabel( + "<div style='border: 1px solid blue'><h1>Hello</h1><p/><h2>I am a rich Label</h3></div>", + "This is an XHTML label with fixed 200px width and rich content"); + l.setContentMode(Label.CONTENT_XHTML); + l.setWidth("200px"); + addTestComponent(l); + + } + + private Component createActionLayout() { + HorizontalLayout actionLayout = new HorizontalLayout(); + actionLayout.setSpacing(true); + actionLayout.setMargin(true); + for (Component c : createActions()) { + actionLayout.addComponent(c); + } + addComponent(actionLayout); + return actionLayout; + } + + private Label createLabel(String text, String caption) { + Label l = new Label(text); + l.setCaption(caption); + + return l; + } + + private Label createLabel(String text) { + return createLabel(text, null); + } + + @Override + protected String getDescription() { + return "A generic test for Labels in different configurations"; + } + + @Override + protected List<Component> createActions() { + ArrayList<Component> actions = new ArrayList<Component>(); + + CheckBox errorIndicators = new CheckBox("Error indicators", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setErrorIndicators(enabled); + + } + }); + + CheckBox enabled = new CheckBox("Enabled", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setEnabled(enabled); + } + }); + + CheckBox readonly = new CheckBox("Readonly", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setReadOnly(enabled); + } + }); + + errorIndicators.setValue(new Boolean(false)); + readonly.setValue(new Boolean(false)); + enabled.setValue(new Boolean(true)); + + errorIndicators.setImmediate(true); + readonly.setImmediate(true); + enabled.setImmediate(true); + + actions.add(errorIndicators); + actions.add(readonly); + actions.add(enabled); + + return actions; + } + +} diff --git a/tests/src/com/vaadin/tests/components/textfield/TextFields.java b/tests/src/com/vaadin/tests/components/textfield/TextFields.java index 7b7c3b3415..9be2c73c41 100644 --- a/tests/src/com/vaadin/tests/components/textfield/TextFields.java +++ b/tests/src/com/vaadin/tests/components/textfield/TextFields.java @@ -3,66 +3,55 @@ package com.vaadin.tests.components.textfield; import java.util.ArrayList; import java.util.List; -import com.vaadin.terminal.UserError; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.ComponentTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; -import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TextField; import com.vaadin.ui.Button.ClickEvent; -public class TextFields extends TestBase { - - private TextField textFields[] = new TextField[20]; +public class TextFields extends ComponentTestCase { @Override protected void setup() { - HorizontalLayout actionLayout = new HorizontalLayout(); - actionLayout.setSpacing(true); - actionLayout.setMargin(true); - for (Component c : createActions()) { - actionLayout.addComponent(c); - } - addComponent(actionLayout); + super.setup(); - int index = 0; + TextField tf; - textFields[index] = createTextField("TextField 100% wide"); - textFields[index].setWidth("100%"); - addComponent(textFields[index++]); + tf = createTextField("TextField 100% wide"); + tf.setWidth("100%"); + addTestComponent(tf); - textFields[index] = createTextField(null, - "TextField 100% wide, no caption"); - textFields[index].setWidth("100%"); - addComponent(textFields[index++]); + tf = createTextField(null, "TextField 100% wide, no caption"); + tf.setWidth("100%"); + addTestComponent(tf); - textFields[index] = createTextField("TextField auto wide"); - addComponent(textFields[index++]); + tf = createTextField("TextField auto wide"); + addTestComponent(tf); - textFields[index] = createTextField("TextField with input prompt"); - textFields[index].setInputPrompt("Please enter a value"); - addComponent(textFields[index++]); + tf = createTextField("TextField with input prompt"); + tf.setInputPrompt("Please enter a value"); + addTestComponent(tf); - textFields[index] = createTextField("100px wide textfield"); - textFields[index].setWidth("100px"); - addComponent(textFields[index++]); + tf = createTextField("100px wide textfield"); + tf.setWidth("100px"); + addTestComponent(tf); - textFields[index] = createTextField("150px wide, 120px high textfield"); - textFields[index].setWidth("150px"); - textFields[index].setHeight("120px"); - addComponent(textFields[index++]); + tf = createTextField("150px wide, 120px high textfield"); + tf.setWidth("150px"); + tf.setHeight("120px"); + addTestComponent(tf); - textFields[index] = createTextField("50px high textfield"); - textFields[index].setHeight("50px"); - addComponent(textFields[index++]); + tf = createTextField("50px high textfield"); + tf.setHeight("50px"); + addTestComponent(tf); - textFields[index] = createTextField(null, "No caption"); - addComponent(textFields[index++]); + tf = createTextField(null, "No caption"); + addTestComponent(tf); - textFields[index] = createTextField(null, "No caption and input prompt"); - textFields[index].setInputPrompt("Enter a value"); - addComponent(textFields[index++]); + tf = createTextField(null, "No caption and input prompt"); + tf.setInputPrompt("Enter a value"); + addTestComponent(tf); } @@ -88,6 +77,7 @@ public class TextFields extends TestBase { return null; } + @Override protected List<Component> createActions() { ArrayList<Component> actions = new ArrayList<Component>(); @@ -145,54 +135,4 @@ public class TextFields extends TestBase { return actions; } - protected void setRequired(boolean on) { - - for (TextField tf : textFields) { - if (tf == null) { - continue; - } - - tf.setRequired(on); - } - - } - - protected void setErrorIndicators(boolean on) { - for (TextField tf : textFields) { - if (tf == null) { - continue; - } - - if (on) { - tf.setComponentError(new UserError("It failed!")); - } else { - tf.setComponentError(null); - - } - } - - } - - protected void setEnabled(boolean on) { - for (TextField tf : textFields) { - if (tf == null) { - continue; - } - - tf.setEnabled(on); - } - - } - - protected void setReadOnly(boolean on) { - for (TextField tf : textFields) { - if (tf == null) { - continue; - } - - tf.setReadOnly(on); - } - - } - } |