aboutsummaryrefslogtreecommitdiffstats
path: root/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderDeclarativeTest.java
blob: 7147f71dea712e1571a65a8c9ce87ad2342db83a (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.vaadin.tests.server.component.slider;

import org.junit.Test;

import com.vaadin.shared.ui.slider.SliderOrientation;
import com.vaadin.tests.server.component.abstractfield.AbstractFieldDeclarativeTest;
import com.vaadin.ui.Slider;

/**
 * Tests declarative support for implementations of {@link Slider}.
 *
 * @since
 * @author Vaadin Ltd
 */
public class SliderDeclarativeTest
        extends AbstractFieldDeclarativeTest<Slider, Double> {

    @Override
    @Test
    public void valueDeserialization()
            throws InstantiationException, IllegalAccessException {
        Double value = 12.3;
        int resolution = 1;
        String design = String.format("<%s resolution=%d value='%s'/>",
                getComponentTag(), resolution, value);

        Slider component = new Slider();
        component.setResolution(resolution);
        component.setValue(value);

        testRead(design, component);
        testWrite(design, component);
    }

    @Test
    public void testVertical() {
        String design = "<vaadin-slider vertical>";

        Slider expected = new Slider();
        expected.setOrientation(SliderOrientation.VERTICAL);

        testRead(design, expected);
        testWrite(design, expected);
    }

    @Override
    public void readOnlyValue()
            throws InstantiationException, IllegalAccessException {
        Double value = 12.3;
        int resolution = 1;
        String design = String.format("<%s resolution=%d readonly value='%s'/>",
                getComponentTag(), resolution, value);

        Slider component = new Slider();
        component.setResolution(resolution);
        component.setValue(value);

        component.setReadOnly(true);
        testRead(design, component);
        testWrite(design, component);
    }

    @Test
    public void remainingAttributeDeserialization() {
        int min = 3;
        int max = 47;
        String design = String.format("<%s min=%d value=%d max='%d'/>",
                getComponentTag(), min, min, max);

        Slider component = new Slider();
        component.setMin(min);
        component.setMax(max);
        component.setOrientation(SliderOrientation.HORIZONTAL);

        testRead(design, component);
        testWrite(design, component);
    }

    @Override
    protected String getComponentTag() {
        return "vaadin-slider";
    }

    @Override
    protected Class<Slider> getComponentClass() {
        return Slider.class;
    }

}