1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.renderer.impl;
17
18 import junit.framework.TestCase;
19
20 import org.eclipse.swt.widgets.Control;
21 import org.seasar.uruma.component.UICompositeComponent;
22 import org.seasar.uruma.component.UIControlComponent;
23 import org.seasar.uruma.component.jface.ButtonComponent;
24 import org.seasar.uruma.component.jface.CommonAttriburtesImpl;
25 import org.seasar.uruma.component.jface.CompositeComponent;
26 import org.seasar.uruma.component.jface.ControlComponent;
27 import org.seasar.uruma.component.jface.GridDataInfo;
28 import org.seasar.uruma.component.jface.GridLayoutInfo;
29
30
31
32
33
34
35 public class AbstractControlRendererTest extends TestCase {
36 private ControlRenderer controlRenderer;
37
38
39
40
41 @Override
42 protected void setUp() throws Exception {
43 this.controlRenderer = new ControlRenderer();
44 }
45
46
47
48
49
50 public void testInheritLayoutData() {
51 UICompositeComponent parentComponent = new CompositeComponent();
52 GridLayoutInfo gridLayoutInfo = new GridLayoutInfo();
53 parentComponent.setLayoutInfo(gridLayoutInfo);
54 GridDataInfo parentGridData = new GridDataInfo();
55 parentGridData.heightHint = "200";
56 parentGridData.widthHint = "400";
57 parentGridData.minimumHeight = "150";
58 gridLayoutInfo.setCommonLayoutDataInfo(parentGridData);
59
60 UIControlComponent component = new ButtonComponent();
61 parentComponent.addChild(component);
62 GridDataInfo gridDataInfo = new GridDataInfo();
63 gridDataInfo.minimumHeight = "50";
64 gridDataInfo.minimumWidth = "100";
65 gridDataInfo.horizontalSpan = "3";
66 component.setLayoutDataInfo(gridDataInfo);
67
68 controlRenderer.inheritLayoutData(component);
69
70 assertEquals("1", "200", gridDataInfo.heightHint);
71 assertEquals("2", "400", gridDataInfo.widthHint);
72 assertEquals("3", "50", gridDataInfo.minimumHeight);
73 assertEquals("4", "100", gridDataInfo.minimumWidth);
74 assertEquals("5", "3", gridDataInfo.horizontalSpan);
75 }
76
77
78
79
80
81 public void testSetCommonAttributes() {
82 UICompositeComponent parentComponent = new CompositeComponent();
83 CommonAttriburtesImpl commonAttributes = new CommonAttriburtesImpl();
84 commonAttributes.setBackGround("WHITE");
85 commonAttributes.setFontHeight("20");
86 parentComponent.setCommonAttributes(commonAttributes);
87
88 ButtonComponent component = new ButtonComponent();
89 parentComponent.addChild(component);
90 component.fontHeight = "15";
91
92 controlRenderer.setCommonAttributes(component);
93
94 assertEquals("1", "WHITE", component.background);
95 assertEquals("2", "15", component.fontHeight);
96 }
97
98
99
100
101 private static class ControlRenderer extends
102 AbstractControlRenderer<ControlComponent, Control> {
103
104 @Override
105 protected void doRenderControl(final ControlComponent controlComponent,
106 final Control control) {
107 }
108
109 @Override
110 protected Class<Control> getWidgetType() {
111 return Control.class;
112 }
113 }
114 }