KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > propertyeditors > PropertyType_ExtensionList


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.editors.StringArrayCustomEditorOperator;
23
24 import org.netbeans.junit.NbTestSuite;
25
26 /**
27  * Tests of Extension List Property Editor.
28  *
29  * @author Marian.Mirilovic@Sun.Com
30  */

31 public class PropertyType_ExtensionList extends PropertyEditorsTest {
32
33     public String JavaDoc propertyName_L;
34     public String JavaDoc propertyValue_L;
35     public String JavaDoc propertyValueExpectation_L;
36
37     public boolean waitDialog = false;
38
39     private final String JavaDoc ADD = "Add:";
40     private final String JavaDoc REMOVE = "Remove:";
41     private final String JavaDoc EDIT = "Edit:";
42     private final String JavaDoc UP = "Up:";
43     private final String JavaDoc DOWN = "Down:";
44     
45     private final String JavaDoc EE = "; ";
46     
47     /** Creates a new instance of PropertyType_ExtensionList */
48     public PropertyType_ExtensionList(String JavaDoc testName) {
49         super(testName);
50     }
51     
52     
53     public void setUp(){
54         propertyName_L = "Extension List";
55         super.setUp();
56     }
57     
58     public static NbTestSuite suite() {
59         NbTestSuite suite = new NbTestSuite();
60         suite.addTest(new PropertyType_ExtensionList("testByInPlace"));
61         suite.addTest(new PropertyType_ExtensionList("verifyCustomizer"));
62         suite.addTest(new PropertyType_ExtensionList("testCustomizerCancel"));
63         suite.addTest(new PropertyType_ExtensionList("testCustomizerAdd"));
64         suite.addTest(new PropertyType_ExtensionList("testCustomizerRemove"));
65         suite.addTest(new PropertyType_ExtensionList("testCustomizerEdit"));
66         return suite;
67     }
68     
69     
70     public void testCustomizerAdd() {
71         propertyValue_L = ADD + "java";
72         propertyValueExpectation_L = "gif, html, java, jpg, png";
73         waitDialog = false;
74         setByCustomizerOk(propertyName_L, true);
75     }
76     
77     public void testCustomizerEdit() {
78         propertyValue_L = EDIT + "html" + EE + "newHtml";
79         propertyValueExpectation_L = "java, jpg, newHtml, png";
80         waitDialog = false;
81         setByCustomizerOk(propertyName_L, true);
82     }
83     
84     public void testCustomizerRemove() {
85         propertyValue_L = REMOVE + "gif";
86         propertyValueExpectation_L = "html, java, jpg, png";
87         waitDialog = false;
88         setByCustomizerOk(propertyName_L, true);
89     }
90
91     public void testCustomizerCancel(){
92         propertyValue_L = ADD + "cancel";
93         propertyValueExpectation_L = propertyValue_L;
94         waitDialog = false;
95         setByCustomizerCancel(propertyName_L, false);
96     }
97     
98     public void testByInPlace(){
99         propertyValue_L = "gif, jpg, png, html";
100         propertyValueExpectation_L = "gif, html, jpg, png";
101         waitDialog = false;
102         setByInPlace(propertyName_L, propertyValue_L, true);
103     }
104     
105     public void verifyCustomizer() {
106         verifyCustomizer(propertyName_L);
107     }
108     
109     public void setCustomizerValue() {
110         StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(propertyCustomizer);
111         
112         if(propertyValue_L.startsWith(ADD)){
113             customizer.add(getItem(propertyValue_L,ADD));
114         }
115         
116         if(propertyValue_L.startsWith(REMOVE)){
117             customizer.remove(getItem(propertyValue_L,REMOVE));
118         }
119         
120         if(propertyValue_L.startsWith(EDIT)){
121             customizer.edit(getItem(propertyValue_L,EDIT), getItem(propertyValue_L,EE));
122         }
123         
124     }
125     
126     public void verifyPropertyValue(boolean expectation) {
127         verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog);
128     }
129     
130     private String JavaDoc getItem(String JavaDoc str, String JavaDoc delim) {
131         int first = str.indexOf(delim);
132         int end = str.indexOf(EE);
133
134         if(end > 0 && !delim.equals(EE)){
135             return str.substring(delim.length(), end);
136         } else {
137             return str.substring(first + delim.length());
138         }
139     }
140     
141     public void verifyCustomizerLayout() {
142         StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(propertyCustomizer);
143         customizer.btAdd();
144         customizer.btRemove();
145         customizer.btEdit();
146         customizer.lstItemList();
147         customizer.txtItemText();
148         customizer.btOK();
149         customizer.btCancel();
150     }
151     
152     /** Test could be executed internaly in Forte without XTest
153      * @param args arguments from command line
154      */

155     public static void main(String JavaDoc[] args) {
156         //junit.textui.TestRunner.run(new NbTestSuite(PropertyType_ExtensionList.class));
157
junit.textui.TestRunner.run(suite());
158     }
159     
160 }
161
Popular Tags