KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > propertyeditors > PropertyType_Rectangle


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  * Tests of Rectangle Property Editor.
32  *
33  * @author Marian.Mirilovic@Sun.Com
34  */

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

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