001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package gui.propertyeditors;
043:
044: import org.netbeans.jellytools.properties.editors.StringArrayCustomEditorOperator;
045:
046: import org.netbeans.junit.NbTestSuite;
047:
048: /**
049: * Tests of Extension List Property Editor.
050: *
051: * @author Marian.Mirilovic@Sun.Com
052: */
053: public class PropertyType_ExtensionList extends PropertyEditorsTest {
054:
055: public String propertyName_L;
056: public String propertyValue_L;
057: public String propertyValueExpectation_L;
058:
059: public boolean waitDialog = false;
060:
061: private final String ADD = "Add:";
062: private final String REMOVE = "Remove:";
063: private final String EDIT = "Edit:";
064: private final String UP = "Up:";
065: private final String DOWN = "Down:";
066:
067: private final String EE = "; ";
068:
069: /** Creates a new instance of PropertyType_ExtensionList */
070: public PropertyType_ExtensionList(String testName) {
071: super (testName);
072: }
073:
074: public void setUp() {
075: propertyName_L = "Extension List";
076: super .setUp();
077: }
078:
079: public static NbTestSuite suite() {
080: NbTestSuite suite = new NbTestSuite();
081: suite.addTest(new PropertyType_ExtensionList("testByInPlace"));
082: suite
083: .addTest(new PropertyType_ExtensionList(
084: "verifyCustomizer"));
085: suite.addTest(new PropertyType_ExtensionList(
086: "testCustomizerCancel"));
087: suite.addTest(new PropertyType_ExtensionList(
088: "testCustomizerAdd"));
089: suite.addTest(new PropertyType_ExtensionList(
090: "testCustomizerRemove"));
091: suite.addTest(new PropertyType_ExtensionList(
092: "testCustomizerEdit"));
093: return suite;
094: }
095:
096: public void testCustomizerAdd() {
097: propertyValue_L = ADD + "java";
098: propertyValueExpectation_L = "gif, html, java, jpg, png";
099: waitDialog = false;
100: setByCustomizerOk(propertyName_L, true);
101: }
102:
103: public void testCustomizerEdit() {
104: propertyValue_L = EDIT + "html" + EE + "newHtml";
105: propertyValueExpectation_L = "java, jpg, newHtml, png";
106: waitDialog = false;
107: setByCustomizerOk(propertyName_L, true);
108: }
109:
110: public void testCustomizerRemove() {
111: propertyValue_L = REMOVE + "gif";
112: propertyValueExpectation_L = "html, java, jpg, png";
113: waitDialog = false;
114: setByCustomizerOk(propertyName_L, true);
115: }
116:
117: public void testCustomizerCancel() {
118: propertyValue_L = ADD + "cancel";
119: propertyValueExpectation_L = propertyValue_L;
120: waitDialog = false;
121: setByCustomizerCancel(propertyName_L, false);
122: }
123:
124: public void testByInPlace() {
125: propertyValue_L = "gif, jpg, png, html";
126: propertyValueExpectation_L = "gif, html, jpg, png";
127: waitDialog = false;
128: setByInPlace(propertyName_L, propertyValue_L, true);
129: }
130:
131: public void verifyCustomizer() {
132: verifyCustomizer(propertyName_L);
133: }
134:
135: public void setCustomizerValue() {
136: StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(
137: propertyCustomizer);
138:
139: if (propertyValue_L.startsWith(ADD)) {
140: customizer.add(getItem(propertyValue_L, ADD));
141: }
142:
143: if (propertyValue_L.startsWith(REMOVE)) {
144: customizer.remove(getItem(propertyValue_L, REMOVE));
145: }
146:
147: if (propertyValue_L.startsWith(EDIT)) {
148: customizer.edit(getItem(propertyValue_L, EDIT), getItem(
149: propertyValue_L, EE));
150: }
151:
152: }
153:
154: public void verifyPropertyValue(boolean expectation) {
155: verifyExpectationValue(propertyName_L, expectation,
156: propertyValueExpectation_L, propertyValue_L, waitDialog);
157: }
158:
159: private String getItem(String str, String delim) {
160: int first = str.indexOf(delim);
161: int end = str.indexOf(EE);
162:
163: if (end > 0 && !delim.equals(EE)) {
164: return str.substring(delim.length(), end);
165: } else {
166: return str.substring(first + delim.length());
167: }
168: }
169:
170: public void verifyCustomizerLayout() {
171: StringArrayCustomEditorOperator customizer = new StringArrayCustomEditorOperator(
172: propertyCustomizer);
173: customizer.btAdd();
174: customizer.btRemove();
175: customizer.btEdit();
176: customizer.lstItemList();
177: customizer.txtItemText();
178: customizer.btOK();
179: customizer.btCancel();
180: }
181:
182: /** Test could be executed internaly in Forte without XTest
183: * @param args arguments from command line
184: */
185: public static void main(String[] args) {
186: //junit.textui.TestRunner.run(new NbTestSuite(PropertyType_ExtensionList.class));
187: junit.textui.TestRunner.run(suite());
188: }
189:
190: }
|