]> source.dussan.org Git - vaadin-framework.git/blob
11d97d191bca1072548af72bc4b8ad1b680908db
[vaadin-framework.git] /
1 /*
2  * Copyright 2000-2014 Vaadin Ltd.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  * 
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 package com.vaadin.tests.server.component.abstractsplitpanel;
17
18 import org.junit.Test;
19
20 import com.vaadin.server.Sizeable.Unit;
21 import com.vaadin.tests.design.DeclarativeTestBase;
22 import com.vaadin.ui.AbstractSplitPanel;
23 import com.vaadin.ui.Button;
24 import com.vaadin.ui.HorizontalSplitPanel;
25 import com.vaadin.ui.Table;
26 import com.vaadin.ui.VerticalLayout;
27 import com.vaadin.ui.VerticalSplitPanel;
28
29 /**
30  * Tests declarative support for AbstractSplitPanel.
31  * 
32  * @since
33  * @author Vaadin Ltd
34  */
35 public class AbstractSplitPanelDeclarativeTest extends
36         DeclarativeTestBase<AbstractSplitPanel> {
37
38     @Test
39     public void testWithBothChildren() {
40         String design = "<v-horizontal-split-panel split-position=20.5% "
41                 + "min-split-position=20% max-split-position=50px locked='' "
42                 + "reversed=\"\"> <v-table /> <v-vertical-layout />"
43                 + "</v-horizontal-split-panel>";
44         AbstractSplitPanel sp = new HorizontalSplitPanel();
45         sp.setSplitPosition(20.5f, Unit.PERCENTAGE, true);
46         sp.setMinSplitPosition(20, Unit.PERCENTAGE);
47         sp.setMaxSplitPosition(50, Unit.PIXELS);
48         sp.setLocked(true);
49         sp.addComponent(new Table());
50         sp.addComponent(new VerticalLayout());
51         testRead(design, sp);
52         testWrite(design, sp);
53     }
54
55     @Test
56     public void testWithFirstChild() {
57         String design = "<v-vertical-split-panel><v-table caption=\"First slot\"/>"
58                 + "</v-vertical-split-panel>";
59         AbstractSplitPanel sp = new VerticalSplitPanel();
60         Table t = new Table();
61         t.setCaption("First slot");
62         sp.addComponent(t);
63         testRead(design, sp);
64         testWrite(design, sp);
65     }
66
67     @Test
68     public void testWithSecondChild() {
69         String design = "<v-horizontal-split-panel><v-button :second>Second slot</v-button>"
70                 + "</v-vertical-split-panel>";
71         AbstractSplitPanel sp = new HorizontalSplitPanel();
72         Button b = new Button("Second slot");
73         b.setCaptionAsHtml(true);
74         sp.setSecondComponent(b);
75         testRead(design, sp);
76         testWrite(design, sp);
77     }
78
79     @Test
80     public void testEmpty() {
81         String design = "<v-horizontal-split-panel/>";
82         AbstractSplitPanel sp = new HorizontalSplitPanel();
83         testRead(design, sp);
84         testWrite(design, sp);
85     }
86 }