KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > propertyeditors > PropertyType_Insets


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.RectangleCustomEditorOperator;
25
26 import org.netbeans.jemmy.JemmyException;
27
28 import org.netbeans.junit.NbTestSuite;
29
30
31
32 /**
33  * Tests of Insets Property Editor.
34  *
35  * @author Marian.Mirilovic@Sun.Com
36  */

37 public class PropertyType_Insets 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_Insets */
46     public PropertyType_Insets(String JavaDoc testName) {
47         super(testName);
48     }
49     
50     
51     public void setUp(){
52         propertyName_L = "Insets";
53         super.setUp();
54     }
55     
56     public static NbTestSuite suite() {
57         NbTestSuite suite = new NbTestSuite();
58         suite.addTest(new PropertyType_Insets("verifyCustomizer"));
59         suite.addTest(new PropertyType_Insets("testCustomizerCancel"));
60         suite.addTest(new PropertyType_Insets("testCustomizerOk"));
61         suite.addTest(new PropertyType_Insets("testByInPlace"));
62         suite.addTest(new PropertyType_Insets("testByInPlaceOneValue"));
63         suite.addTest(new PropertyType_Insets("testByInPlaceInvalid"));
64         suite.addTest(new PropertyType_Insets("testCustomizerInvalid"));
65         return suite;
66     }
67     
68     public void testCustomizerOk() {
69         propertyValue_L = "10, 20, 30, 40";
70         propertyValueExpectation_L = "["+propertyValue_L+"]";
71         waitDialog = false;
72         setByCustomizerOk(propertyName_L, true);
73     }
74     
75     public void testCustomizerCancel(){
76         propertyValue_L = "100, 100, 200, 200";
77         propertyValueExpectation_L = "["+propertyValue_L+"]";
78         waitDialog = false;
79         setByCustomizerCancel(propertyName_L, false);
80     }
81     
82     public void testCustomizerInvalid(){
83         propertyValue_L = "xx, 20, 30, 50";
84         propertyValueExpectation_L = "["+propertyValue_L+"]";
85         waitDialog = true;
86         setByCustomizerOk(propertyName_L, false);
87     }
88     
89     public void testByInPlace(){
90         propertyValue_L = "30, 40, 50, 60";
91         propertyValueExpectation_L = "["+propertyValue_L+"]";
92         waitDialog = false;
93         setByInPlace(propertyName_L, propertyValue_L, true);
94     }
95     
96     public void testByInPlaceOneValue(){
97         propertyValue_L = "70";
98         propertyValueExpectation_L = "["+propertyValue_L+", "+propertyValue_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 Insets";
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         RectangleCustomEditorOperator customizer = new RectangleCustomEditorOperator(propertyCustomizer);
116         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(propertyValue_L, ", ");
117         int x = st.countTokens();
118         
119         if(x>4)
120             throw new JemmyException("ERROR: InsetsCustomizer.setValue(\""+propertyValue_L+"\") - {number values="+x+"}.");
121         
122         customizer.setRectangleValue(st.nextToken(), st.nextToken(), st.nextToken(), st.nextToken());
123     }
124     
125     public void verifyPropertyValue(boolean expectation) {
126         verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog);
127     }
128     
129     public void verifyCustomizerLayout() {
130         RectangleCustomEditorOperator customizer = new RectangleCustomEditorOperator(propertyCustomizer);
131         customizer.verify();
132         customizer.btOK();
133         customizer.btCancel();
134     }
135     
136     /** Test could be executed internaly in Forte without XTest
137      * @param args arguments from command line
138      */

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