aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/label/Labels.java
blob: 1da588576b7d2a29bf7a63d625d27aff9da35ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.vaadin.tests.components.label;

import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.ComponentTestCase;
import com.vaadin.tests.util.LoremIpsum;
import com.vaadin.ui.Label;

public class Labels extends ComponentTestCase<Label> {

    @Override
    protected Class<Label> getTestClass() {
        return Label.class;
    }

    @Override
    protected void initializeComponents() {
        Label l;
        l = createLabel("This is an undefined\nwide\nlabel               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\n\n\nwrap");
        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\n\n     100%\t\t\t   \twide 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\n\n\n</h1><p/><h2>I am a rich Label</h3></div>",
                "This is an XHTML label with rich content");
        l.setContentMode(ContentMode.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(ContentMode.XHTML);
        l.setWidth("200px");
        addTestComponent(l);

        l = createLabel("Some UTF8 characters: äöÄÖ≤≠∉Ġå2²");
        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";
    }

}