]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case for Label modes
authorArtur Signell <artur.signell@itmill.com>
Tue, 19 Jan 2010 07:08:25 +0000 (07:08 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 19 Jan 2010 07:08:25 +0000 (07:08 +0000)
svn changeset:10797/svn branch:6.2

tests/src/com/vaadin/tests/components/label/LabelModes.java [new file with mode: 0644]

diff --git a/tests/src/com/vaadin/tests/components/label/LabelModes.java b/tests/src/com/vaadin/tests/components/label/LabelModes.java
new file mode 100644 (file)
index 0000000..16568c5
--- /dev/null
@@ -0,0 +1,109 @@
+package com.vaadin.tests.components.label;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.Label;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class LabelModes extends ComponentTestCase {
+
+    Label label[] = new Label[20];
+
+    @Override
+    protected void setup() {
+        super.setup();
+
+        Label l;
+        l = createLabel("This is an undefined wide label with default content mode");
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nbut is in\ndefault content mode");
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nand is in\npreformatted mode");
+        l.setContentMode(Label.CONTENT_PREFORMATTED);
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nand is in\nhtml mode");
+        l.setContentMode(Label.CONTENT_XHTML);
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nand is in\nraw mode");
+        l.setContentMode(Label.CONTENT_RAW);
+        l.setWidth(null);
+        addTestComponent(l);
+
+    }
+
+    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;
+    }
+
+}