KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > propertyeditors > PropertyType_Dimension


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package gui.propertyeditors;
21
22 import java.util.StringTokenizer JavaDoc;
23
24 import org.netbeans.jellytools.properties.editors.DimensionCustomEditorOperator;
25
26 import org.netbeans.jemmy.JemmyException;
27
28 import org.netbeans.junit.NbTestSuite;
29
30
31
32 /**
33  * Tests of Dimension Property Editor.
34  *
35  * @author Marian.Mirilovic@Sun.Com
36  */

37 public class PropertyType_Dimension extends PropertyEditorsTest {
38
39     public String JavaDoc propertyName_L;
40     public String JavaDoc propertyValue_L;
41     public String JavaDoc propertyValueExpectation_L;
42
43     public boolean waitDialog = false;
44     
45     /** Creates a new instance of PropertyType_Dimension */
46     public PropertyType_Dimension(String JavaDoc testName) {
47         super(testName);
48     }
49     
50     
51     public void setUp(){
52         propertyName_L = "Dimension";
53         super.setUp();
54     }
55     
56     public static NbTestSuite suite() {
57         NbTestSuite suite = new NbTestSuite();
58         suite.addTest(new PropertyType_Dimension("verifyCustomizer"));
59         suite.addTest(new PropertyType_Dimension("testCustomizerCancel"));
60         suite.addTest(new PropertyType_Dimension("testCustomizerOk"));
61         suite.addTest(new PropertyType_Dimension("testByInPlace"));
62         suite.addTest(new PropertyType_Dimension("testByInPlaceOneValue"));
63         suite.addTest(new PropertyType_Dimension("testByInPlaceInvalid"));
64         suite.addTest(new PropertyType_Dimension("testCustomizerInvalid"));
65         return suite;
66     }
67     
68     public void testCustomizerOk() {
69         propertyValue_L = "10, 20";
70         propertyValueExpectation_L = "["+propertyValue_L+"]";
71         waitDialog = false;
72         setByCustomizerOk(propertyName_L, true);
73     }
74     
75     public void testCustomizerCancel(){
76         propertyValue_L = "100, 200";
77         propertyValueExpectation_L = "["+propertyValue_L+"]";
78         waitDialog = false;
79         setByCustomizerCancel(propertyName_L, false);
80     }
81     
82     public void testCustomizerInvalid(){
83         propertyValue_L = "xx, ww";
84         propertyValueExpectation_L = "["+propertyValue_L+"]";
85         waitDialog = true;
86         setByCustomizerOk(propertyName_L, false);
87     }
88     
89     public void testByInPlace(){
90         propertyValue_L = "30, 50";
91         propertyValueExpectation_L = "["+propertyValue_L+"]";
92         waitDialog = false;
93         setByInPlace(propertyName_L, propertyValue_L, true);
94     }
95     
96     public void testByInPlaceOneValue(){
97         propertyValue_L = "20";
98         propertyValueExpectation_L = "["+propertyValue_L+", "+propertyValue_L+"]";
99         waitDialog = false;
100         setByInPlace(propertyName_L, propertyValue_L, true);
101     }
102     
103     public void testByInPlaceInvalid(){
104         propertyValue_L = "xx Dimension";
105         propertyValueExpectation_L = propertyValue_L;
106         waitDialog = true;
107         setByInPlace(propertyName_L, propertyValue_L, false);
108     }
109     
110     public void verifyCustomizer() {
111         verifyCustomizer(propertyName_L);
112     }
113     
114     public void setCustomizerValue() {
115         DimensionCustomEditorOperator customizer = new DimensionCustomEditorOperator(propertyCustomizer);
116
117         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(propertyValue_L, ", ");
118         int x = st.countTokens();
119         
120         if(x>2)
121             throw new JemmyException("ERROR: DimensionPointCustomizer.setValue(\""+propertyValue_L+"\") - {number values="+x+"}.");
122         
123         customizer.setDimensionValue(st.nextToken(), st.nextToken());
124     }
125     
126     public void verifyPropertyValue(boolean expectation) {
127         verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog);
128     }
129     
130     public void verifyCustomizerLayout() {
131         DimensionCustomEditorOperator customizer = new DimensionCustomEditorOperator(propertyCustomizer);
132         customizer.verify();
133         customizer.btOK();
134         customizer.btCancel();
135     }
136     
137     /** Test could be executed internaly in Forte without XTest
138      * @param args arguments from command line
139      */

140     public static void main(String JavaDoc[] args) {
141         //junit.textui.TestRunner.run(new NbTestSuite(PropertyType_Dimension.class));
142
junit.textui.TestRunner.run(suite());
143     }
144     
145 }
146
Popular Tags