KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > propertyeditors > PropertyType_Point


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

35 public class PropertyType_Point 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_Point */
44     public PropertyType_Point(String JavaDoc testName) {
45         super(testName);
46     }
47     
48     
49     public void setUp(){
50         propertyName_L = "Point";
51         super.setUp();
52     }
53     
54     public static NbTestSuite suite() {
55         NbTestSuite suite = new NbTestSuite();
56         suite.addTest(new PropertyType_Point("verifyCustomizer"));
57         suite.addTest(new PropertyType_Point("testCustomizerCancel"));
58         suite.addTest(new PropertyType_Point("testCustomizerOk"));
59         suite.addTest(new PropertyType_Point("testByInPlace"));
60         suite.addTest(new PropertyType_Point("testByInPlaceOneValue"));
61         suite.addTest(new PropertyType_Point("testByInPlaceInvalid"));
62         suite.addTest(new PropertyType_Point("testCustomizerInvalid"));
63         return suite;
64     }
65     
66     public void testCustomizerOk() {
67         propertyValue_L = "10, 20";
68         propertyValueExpectation_L = "["+propertyValue_L+"]";
69         waitDialog = false;
70         setByCustomizerOk(propertyName_L, true);
71     }
72     
73     public void testCustomizerCancel(){
74         propertyValue_L = "100, 100";
75         propertyValueExpectation_L = "["+propertyValue_L+"]";
76         waitDialog = false;
77         setByCustomizerCancel(propertyName_L, false);
78     }
79     
80     public void testCustomizerInvalid(){
81         propertyValue_L = "xx, 20";
82         propertyValueExpectation_L = "["+propertyValue_L+"]";
83         waitDialog = true;
84         setByCustomizerOk(propertyName_L, false);
85     }
86     
87     public void testByInPlace(){
88         propertyValue_L = "30, 50";
89         propertyValueExpectation_L = "["+propertyValue_L+"]";
90         waitDialog = false;
91         setByInPlace(propertyName_L, propertyValue_L, true);
92     }
93     
94     public void testByInPlaceOneValue(){
95         propertyValue_L = "20";
96         propertyValueExpectation_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 Point";
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         DimensionCustomEditorOperator customizer = new DimensionCustomEditorOperator(propertyCustomizer);
114
115         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(propertyValue_L, ", ");
116         int x = st.countTokens();
117         
118         if(x>2)
119             throw new JemmyException("ERROR: DimensionPointCustomizer.setValue(\""+propertyValue_L+"\") - {number values="+x+"}.");
120         
121         customizer.setDimensionValue(st.nextToken(), st.nextToken());
122         
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         DimensionCustomEditorOperator customizer = new DimensionCustomEditorOperator(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_Point.class));
141
junit.textui.TestRunner.run(suite());
142     }
143     
144 }
145
Popular Tags