KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > propertyeditors > PropertyType_Font


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 org.netbeans.jellytools.properties.FontProperty;
23 import org.netbeans.jellytools.properties.PropertySheetOperator;
24
25 import org.netbeans.jellytools.properties.editors.FontCustomEditorOperator;
26
27 import org.netbeans.junit.NbTestSuite;
28
29 /**
30  * Tests of Font Property Editor.
31  *
32  * @author Marian.Mirilovic@Sun.Com
33  */

34 public class PropertyType_Font extends PropertyEditorsTest {
35     
36     public String JavaDoc propertyName_L;
37     public String JavaDoc propertyValue_L;
38     public String JavaDoc propertyValueExpectation_L;
39     
40     public boolean waitDialog = false;
41     
42     /** Creates a new instance of PropertyType_Font */
43     public PropertyType_Font(String JavaDoc testName) {
44         super(testName);
45     }
46     
47     
48     public void setUp(){
49         propertyName_L = "Font";
50         super.setUp();
51     }
52     
53     public static NbTestSuite suite() {
54         NbTestSuite suite = new NbTestSuite();
55         suite.addTest(new PropertyType_Font("verifyCustomizer"));
56         suite.addTest(new PropertyType_Font("testCustomizerCancel"));
57         suite.addTest(new PropertyType_Font("testCustomizerOk"));
58         suite.addTest(new PropertyType_Font("testCustomizerOkUnknownSize"));
59         suite.addTest(new PropertyType_Font("testCustomizerInvalid"));
60         return suite;
61     }
62     
63     public void testCustomizerOk() {
64         propertyValue_L = "Monospaced, 10, Bold";
65         propertyValueExpectation_L = "Monospaced 10 Bold";
66         waitDialog = false;
67         setByCustomizerOk(propertyName_L, true);
68     }
69     
70     public void testCustomizerOkUnknownSize() {
71         propertyValue_L = "Monospaced, 13, Bold";
72         propertyValueExpectation_L = "Monospaced 13 Bold";
73         waitDialog = false;
74         setByCustomizerOk(propertyName_L, true);
75     }
76     
77     public void testCustomizerCancel(){
78         propertyValue_L = "Monospaced, 100, Bold";
79         propertyValueExpectation_L = "Monospaced 100 Bold";
80         waitDialog = false;
81         setByCustomizerCancel(propertyName_L, false);
82     }
83     
84     public void testCustomizerInvalid(){
85         propertyValue_L = "Monospaced, xx, Bold Italic";
86         propertyValueExpectation_L = "Monospaced xx Bold Italic";
87         waitDialog = false;
88         setByCustomizerOk(propertyName_L, false);
89     }
90     
91     public void verifyCustomizer() {
92         verifyCustomizer(propertyName_L);
93     }
94     
95     public void setCustomizerValue() {
96         FontCustomEditorOperator customizer = new FontCustomEditorOperator(propertyCustomizer);
97         
98         int index1,index2,index3;
99         index1 = propertyValue_L.indexOf(", ");
100         
101         if(index1>0){
102             customizer.setFontName(propertyValue_L.substring(0,index1).trim());
103             index2 = propertyValue_L.indexOf(", ", index1+1);
104             
105             if(index2>0){
106                 customizer.setFontSize(propertyValue_L.substring(index1+1,index2).trim());
107                 customizer.setFontStyle(propertyValue_L.substring(index2+1).trim());
108             }
109         }
110         
111     }
112     
113     public void verifyPropertyValue(boolean expectation) {
114         verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog);
115     }
116     
117     public String JavaDoc getValue(String JavaDoc propertyName) {
118         String JavaDoc returnValue;
119         PropertySheetOperator propertiesTab = new PropertySheetOperator(propertiesWindow);
120         
121         returnValue = new FontProperty(propertiesTab, propertyName_L).getValue();
122         err.println("GET VALUE = [" + returnValue + "].");
123         
124         // hack for color poperty, this action expects, that right value is displayed as tooltip
125
// returnValue = new Property(propertiesTab, propertyName_L).valueButtonOperator().getToolTipText();
126
// err.println("GET VALUE TOOLTIP = [" + returnValue + "].");
127

128         return returnValue;
129     }
130     
131     public void verifyCustomizerLayout() {
132         FontCustomEditorOperator customizer = new FontCustomEditorOperator(propertyCustomizer);
133         customizer.verify();
134         customizer.btOK();
135         customizer.btCancel();
136     }
137     
138     /** Test could be executed internaly in Forte without XTest
139      * @param args arguments from command line
140      */

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