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-2007 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: /*
043: * CLD_InterfaceTests.java
044: *
045: * Created on May 13, 2005, 10:41 AM
046: *
047: * To change this template, choose Tools | Options and locate the template under
048: * the Source Creation and Management node. Right-click the template and choose
049: * Open. You can then make changes to the template in the Source Editor.
050: */
051:
052: package org.netbeans.test.uml.classdiagram;
053:
054: import java.io.BufferedReader;
055: import java.io.File;
056: import java.io.FileNotFoundException;
057: import java.io.FileOutputStream;
058: import java.io.PrintStream;
059: import org.netbeans.jemmy.JemmyProperties;
060: import org.netbeans.jemmy.TestOut;
061: import org.netbeans.junit.NbTestSuite;
062: import org.netbeans.test.uml.classdiagram.utils.CLDUtils;
063: import org.netbeans.test.umllib.ElementTypes;
064: import org.netbeans.test.umllib.LinkTypes;
065: import org.netbeans.test.umllib.NewDiagramWizardOperator;
066: import org.netbeans.test.umllib.exceptions.NotFoundException;
067: import org.netbeans.test.umllib.vrf.DiagramElementVerifier;
068:
069: /**
070: *
071: * @author Administrator
072: */
073: public class CLD_InterfaceElementTests extends ClassDiagramTestCase {
074:
075: private static String prName = "UMLProjectForInterface";
076: private static String dpdName = "ClassDiagramForInterface";
077:
078: private static final String workDir = System
079: .getProperty("xtest.workdir");
080: private static String OUT_LOG_FILE = "";
081: private static String ERR_LOG_FILE = "";
082: private static PrintStream myOut = null;
083: private static PrintStream myErr = null;
084: private static BufferedReader myIn = null;
085:
086: /** Need to be defined because of JUnit */
087: public CLD_InterfaceElementTests(String name) {
088: super (name);
089: }
090:
091: public static NbTestSuite suite() {
092: NbTestSuite suite = new NbTestSuite(
093: org.netbeans.test.uml.classdiagram.CLD_InterfaceElementTests.class);
094: return suite;
095: }
096:
097: /** Use for execution inside IDE */
098: public static void main(java.lang.String[] args) {
099: // junit.textui.TestRunner.run(suite());
100: // run only selected test case
101: junit.textui.TestRunner
102: .run(new org.netbeans.test.uml.classdiagram.CLD_PackageElementTests(
103: "testCopyAndPasteClassElement"));
104: }
105:
106: public void testCopyAndPasteByPopup() {
107: boolean result = verifier.checkCopyPasteByPopup();
108: if (!result) {
109: fail("Test failed. Details in log file.");
110: }
111: }
112:
113: public void testCopyAndPasteByShortcut() {
114: boolean result = verifier.checkCopyPasteByShortcut();
115: if (!result) {
116: fail("Test failed. Details in log file.");
117: }
118: }
119:
120: public void testCutAndPasteByPopup() {
121: boolean result = verifier.checkCutPasteByPopup();
122: if (!result) {
123: fail("Test failed. Details in log file.");
124: }
125: }
126:
127: public void testCutAndPasteByShortcut() {
128: boolean result = verifier.checkCutPasteByShortcut();
129: if (!result) {
130: fail("Test failed. Details in log file.");
131: }
132: }
133:
134: public void testDeleteByPopup() throws NotFoundException {
135: boolean result = verifier.checkDeleteByPopup();
136: if (!result) {
137: fail("Test failed. Details in log file.");
138: }
139: }
140:
141: public void testDeleteByShortcut() throws NotFoundException {
142: boolean result = verifier.checkDeleteByShortcut();
143: if (!result) {
144: fail("Test failed. Details in log file.");
145: }
146: }
147:
148: public void testLockEdit() throws NotFoundException {
149: boolean result = verifier.checkLockEdit();
150: if (!result) {
151: fail("Test failed. Details in log file.");
152: }
153: }
154:
155: public void testSelectAllByPopup() throws NotFoundException {
156: boolean result = verifier
157: .checkSelectAllByPopup(new ElementTypes[] {
158: ElementTypes.INTERFACE, ElementTypes.ARTIFACT });
159: if (!result) {
160: fail("Test failed. Details in log file.");
161: }
162: }
163:
164: public void testSelectAllByShortcut() throws NotFoundException {
165: boolean result = verifier
166: .checkSelectAllByShortcut(new ElementTypes[] {
167: ElementTypes.INTERFACE, ElementTypes.ARTIFACT });
168: if (!result) {
169: fail("Test failed. Details in log file.");
170: }
171: }
172:
173: public void testSelectAllSimilar() throws NotFoundException {
174: boolean result = verifier
175: .checkSelectAllSimilar(new ElementTypes[] {
176: ElementTypes.INTERFACE, ElementTypes.CLASS });
177: if (!result) {
178: fail("Test failed. Details in log file.");
179: }
180: }
181:
182: public void testInvertSelection() throws NotFoundException {
183: boolean result = verifier.checkInvertSelection(
184: new ElementTypes[] { ElementTypes.CLASS },
185: new ElementTypes[] { ElementTypes.INTERFACE,
186: ElementTypes.PACKAGE });
187: if (!result) {
188: fail("Test failed. Details in log file.");
189: }
190: }
191:
192: public void testHideChildrenOneLevel() throws NotFoundException {
193: boolean result = verifier.checkHideChildrenOneLevel(2, 2,
194: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
195: if (!result) {
196: fail("Test failed. Details in log file.");
197: }
198: }
199:
200: public void testHideChildrenAllLevels() throws NotFoundException {
201: boolean result = verifier.checkHideChildrenAllLevels(2, 2,
202: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
203: if (!result) {
204: fail("Test failed. Details in log file.");
205: }
206: }
207:
208: public void testHideParentsOneLevel() throws NotFoundException {
209: boolean result = verifier.checkHideParentsOneLevel(2, 2,
210: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
211: if (!result) {
212: fail("Test failed. Details in log file.");
213: }
214: }
215:
216: public void testHideParentsAllLevels() throws NotFoundException {
217: boolean result = verifier.checkHideParentsAllLevels(2, 2,
218: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
219: if (!result) {
220: fail("Test failed. Details in log file.");
221: }
222: }
223:
224: public void testShowChildrenOneLevel() throws NotFoundException {
225: boolean result = verifier.checkShowChildrenOneLevel(2, 2,
226: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
227: if (!result) {
228: fail("Test failed. Details in log file.");
229: }
230: }
231:
232: public void testShowChildrenAllLevels() throws NotFoundException {
233: boolean result = verifier.checkShowChildrenAllLevels(2, 2,
234: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
235: if (!result) {
236: fail(78350, "Test failed. Details in log file.");
237: }
238: }
239:
240: public void testShowParentsOneLevel() throws NotFoundException {
241: boolean result = verifier.checkShowParentsOneLevel(2, 2,
242: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
243: if (!result) {
244: fail("Test failed. Details in log file.");
245: }
246: }
247:
248: public void testShowParentsAllLevels() throws NotFoundException {
249: boolean result = verifier.checkShowParentsAllLevels(2, 2,
250: LinkTypes.DEPENDENCY, ElementTypes.INTERFACE);
251: if (!result) {
252: fail(78350, "Test failed. Details in log file.");
253: }
254: }
255:
256: public void testBorderColor() throws NotFoundException {
257: boolean result = verifier.checkBorderColor(255, 0, 0);
258: if (!result) {
259: fail("Test failed. Details in log file.");
260: }
261: }
262:
263: public void testBackgroundColor() throws NotFoundException {
264: boolean result = verifier.checkBackgroundColor(0, 255, 0);
265: if (!result) {
266: fail("Test failed. Details in log file.");
267: }
268: }
269:
270: public void testFont() throws NotFoundException {
271: boolean result = verifier.checkFont();
272: if (!result) {
273: fail("Test failed. Details in log file.");
274: }
275: }
276:
277: public void testFontColor() throws NotFoundException {
278: boolean result = verifier.checkFontColor(100, 100, 100);
279: if (!result) {
280: fail("Test failed. Details in log file.");
281: }
282: }
283:
284: //------------------------------------------------------------------------------
285:
286: protected void setUp() throws FileNotFoundException {
287: System.out.println("######## " + getName() + " #######");
288: JemmyProperties.setCurrentTimeout(
289: "DialogWaiter.WaitDialogTimeout", 5000);
290: JemmyProperties.setCurrentTimeout("Waiter.WaitingTime", 3000);
291: JemmyProperties.setCurrentTimeout(
292: "DiagramElementOperator.WaitDiagramElementTime", 5000);
293:
294: OUT_LOG_FILE = workDir + File.separator + "jout_" + getName()
295: + ".log";
296: ERR_LOG_FILE = workDir + File.separator + "jerr_" + getName()
297: + ".log";
298:
299: myOut = new PrintStream(new FileOutputStream(OUT_LOG_FILE),
300: true);
301: myErr = new PrintStream(new FileOutputStream(ERR_LOG_FILE),
302: true);
303: JemmyProperties.setCurrentOutput(new TestOut(System.in, myOut,
304: myErr));
305:
306: diagram = CLDUtils.openDiagram(prName, dpdName,
307: NewDiagramWizardOperator.CLASS_DIAGRAM, workDir);
308: if (diagram == null) {
309: fail("Can't open diagram '" + dpdName + "', project '"
310: + prName + "'.");
311: }
312: verifier = new DiagramElementVerifier(diagram,
313: ElementTypes.INTERFACE, "CLD_", getLog());
314: }
315:
316: private DiagramElementVerifier verifier = null;
317: }
|