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: package org.netbeans.test.uml.activitydiagram;
043:
044: import java.awt.event.KeyEvent;
045: import org.netbeans.jellytools.MainWindowOperator;
046: import org.netbeans.jellytools.ProjectsTabOperator;
047: import org.netbeans.jellytools.nodes.Node;
048: import org.netbeans.jellytools.properties.PropertySheetOperator;
049: import org.netbeans.jemmy.EventTool;
050:
051: import org.netbeans.junit.NbTestSuite; //import org.netbeans.test.umllib.UMLClassOperator;
052: import org.netbeans.test.umllib.DiagramElementOperator;
053: import org.netbeans.test.umllib.DiagramOperator;
054: import org.netbeans.test.umllib.DrawingAreaOperator;
055: import org.netbeans.test.umllib.ElementTypes;
056: import org.netbeans.test.umllib.NewDiagramWizardOperator;
057: import org.netbeans.test.umllib.UMLPaletteOperator;
058: import org.netbeans.test.umllib.exceptions.NotFoundException;
059: import org.netbeans.test.umllib.testcases.UMLTestCase;
060:
061: /**
062: *
063: * @author psb
064: * @spec uml/UML-EditControl.xml
065: */
066: public class ActivityDiagramNameElements extends UMLTestCase {
067:
068: //some system properties
069: private static String contextPropItemName = "Properties";
070: private static String umlPropertyWindowTitle = "Project Properties";
071: private static String umlSourcePackagesLabel = "Source Packages";
072: private static String umlSourcePackagesColumn = "Folder Label";
073: private static String umlSourceUsageColumn = "Model?";
074: private static String mainTreeTabName = "Projects";
075: //common test properties
076: private static String prName = "ActivityDiagramProjectNE";
077: private static String project = prName + "|Model";
078: private static String sourceProject = "source";
079: private static boolean codeSync = false;
080: private static String defaultNewElementName = org.netbeans.test.uml.activitydiagram.utils.Utils.defaultNewElementName;
081: private static String defaultReturnType = org.netbeans.test.uml.activitydiagram.utils.Utils.defaultReturnType;
082: private static String defaultAttributeType = org.netbeans.test.uml.activitydiagram.utils.Utils.defaultAttributeType;
083: private static String defaultAttributeVisibility = org.netbeans.test.uml.activitydiagram.utils.Utils.defaultAttributeVisibility;
084: private static String defaultOperationVisibility = org.netbeans.test.uml.activitydiagram.utils.Utils.defaultOperationVisibility;
085: private ProjectsTabOperator pto = null;
086: private Node lastDiagramNode = null;
087: private String lastTestCase = null;
088: private static String workdir = System.getProperty("xtest.workdir");
089: //--
090: private static String activityDiagramName1 = "acD1";
091: private static String workPkg1 = "pkg1";
092: private static String element1 = "Invocation";
093: private static String elementName1 = "";
094: private static ElementTypes elementType1 = ElementTypes.INVOCATION;
095: //--
096: private static String activityDiagramName2 = "acD2";
097: private static String workPkg2 = "pkg2";
098: private static String element2 = "Activity Group";
099: private static String elementName2 = defaultNewElementName;
100: private static ElementTypes elementType2 = ElementTypes.ACTIVITY_GROUP;
101: //--
102: private static String activityDiagramName3 = "acD3";
103: private static String workPkg3 = "pkg3";
104: private static String element3 = "Initial Node";
105: private static String elementName3 = "";
106: private static ElementTypes elementType3 = ElementTypes.INITIAL_NODE;
107: //--
108: private static String activityDiagramName4 = "acD4";
109: private static String workPkg4 = "pkg4";
110: private static String element4 = "Activity Final Node";
111: private static String elementName4 = "";
112: private static ElementTypes elementType4 = ElementTypes.ACTIVITY_FINAL_NODE;
113: //--
114: private static String activityDiagramName5 = "acD5";
115: private static String workPkg5 = "pkg5";
116: private static String element5 = "Flow Final";
117: private static String elementName5 = "";
118: private static ElementTypes elementType5 = ElementTypes.FLOW_FINAL;
119: //--
120: private static String activityDiagramName6 = "acD6";
121: private static String workPkg6 = "pkg6";
122: private static String element6 = "Decision";
123: private static String elementName6 = "";
124: private static ElementTypes elementType6 = ElementTypes.DECISION;
125: //--
126: private static String activityDiagramName7 = "acD7";
127: private static String workPkg7 = "pkg7";
128: private static String element7 = "Vertical Fork";
129: private static String elementName7 = "";
130: private static ElementTypes elementType7 = ElementTypes.VERTICAL_FORK;
131: //--
132: private static String activityDiagramName8 = "acD8";
133: private static String workPkg8 = "pkg8";
134: private static String element8 = "Horizontal Fork";
135: private static String elementName8 = "";
136: private static ElementTypes elementType8 = ElementTypes.HORIZONTAL_FORK;
137: //--
138: private static String activityDiagramName9 = "acD9";
139: private static String workPkg9 = "pkg9";
140: private static String element9 = "Parameter Usage";
141: private static String elementName9 = "";
142: private static ElementTypes elementType9 = ElementTypes.PARAMETER_USAGE;
143: //--
144: private static String activityDiagramName10 = "acD10";
145: private static String workPkg10 = "pkg10";
146: private static String element10 = "Data Store";
147: private static String elementName10 = "";
148: private static ElementTypes elementType10 = ElementTypes.DATA_STORE;
149: //--
150: private static String activityDiagramName11 = "acD11";
151: private static String workPkg11 = "pkg11";
152: private static String element11 = "Signal";
153: private static String elementName11 = "";
154: private static ElementTypes elementType11 = ElementTypes.SIGNAL;
155: //--
156: private static String activityDiagramName12 = "acD12";
157: private static String workPkg12 = "pkg12";
158: private static String element12 = "Partition";
159: private static String elementName12 = defaultNewElementName;
160: private static ElementTypes elementType12 = ElementTypes.PARTITION;
161: //--
162: private static String activityDiagramName13 = "acD13";
163: private static String workPkg13 = "pkg13";
164: private static String element13 = "Comment";
165: private static String elementName13 = "";
166: private static ElementTypes elementType13 = ElementTypes.COMMENT;
167: //--
168: private static String activityDiagramName14 = "acD14";
169: private static String workPkg14 = "pkg14";
170: private static String element14 = "Link Comment";
171: private static String elementName14 = "";
172: private static ElementTypes elementType14 = ElementTypes.LINK_COMMENT;
173:
174: /** Need to be defined because of JUnit */
175: public ActivityDiagramNameElements(String name) {
176: super (name);
177: }
178:
179: public static NbTestSuite suite() {
180: NbTestSuite suite = new NbTestSuite(
181: org.netbeans.test.uml.activitydiagram.ActivityDiagramNameElements.class);
182: return suite;
183: }
184:
185: private DiagramOperator createDiagram(String project,
186: String workPkg, String diagram) {
187: org.netbeans.test.umllib.Utils.RetAll rt = org.netbeans.test.umllib.Utils
188: .createDiagram(project, workPkg, diagram,
189: NewDiagramWizardOperator.ACTIVITY_DIAGRAM);
190: pto = rt.pto;
191: lastDiagramNode = rt.lastDiagramNode;
192: return rt.dOp;
193: }
194:
195: public void testCreate1() {
196: testElementPlace(workPkg1, activityDiagramName1, element1,
197: elementName1, elementType1);
198: }
199:
200: public void testCreate2() {
201: testElementPlace(workPkg2, activityDiagramName2, element2,
202: elementName2, elementType2);
203: }
204:
205: public void testCreate3() {
206: testElementPlace(workPkg3, activityDiagramName3, element3,
207: elementName3, elementType3);
208: }
209:
210: public void testCreate4() {
211: testElementPlace(workPkg4, activityDiagramName4, element4,
212: elementName4, elementType4);
213: }
214:
215: public void testCreate5() {
216: testElementPlace(workPkg5, activityDiagramName5, element5,
217: elementName5, elementType5);
218: }
219:
220: public void testCreate6() {
221: testElementPlace(workPkg6, activityDiagramName6, element6,
222: elementName6, elementType6);
223: }
224:
225: public void testCreate7() {
226: testElementPlace(workPkg7, activityDiagramName7, element7,
227: elementName7, elementType7);
228: }
229:
230: public void testCreate8() {
231: testElementPlace(workPkg8, activityDiagramName8, element8,
232: elementName8, elementType8);
233: }
234:
235: public void testCreate9() {
236: testElementPlace(workPkg9, activityDiagramName9, element9,
237: elementName9, elementType9);
238: }
239:
240: public void testCreate10() {
241: testElementPlace(workPkg10, activityDiagramName10, element10,
242: elementName10, elementType10);
243: }
244:
245: public void testCreate11() {
246: testElementPlace(workPkg11, activityDiagramName11, element11,
247: elementName11, elementType11);
248: }
249:
250: public void testCreate12() {
251: testElementPlace(workPkg12, activityDiagramName12, element12,
252: elementName12, elementType12);
253: }
254:
255: public void testCreate13() {
256: testElementPlace(workPkg13, activityDiagramName13, element13,
257: elementName13, elementType13);
258: }
259:
260: public void testCreate14() {
261: testElementPlace(workPkg14, activityDiagramName14, element14,
262: elementName14, elementType14);
263: }
264:
265: public void setUp() {
266: System.out.println("######## " + getName() + " #######");
267: pto = ProjectsTabOperator.invoke();
268: if (!codeSync) {
269: org.netbeans.test.uml.activitydiagram.utils.Utils
270: .commonActivityDiagramSetup(workdir, prName);
271: //
272: codeSync = true;
273: }
274:
275: }
276:
277: public void tearDown() {
278: org.netbeans.test.umllib.util.Utils
279: .makeScreenShot(lastTestCase);
280: //popup protection
281: MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
282: new EventTool().waitNoEvent(1000);
283: //
284: closeAllModal();
285: org.netbeans.test.umllib.util.Utils.saveAll();
286: if (lastDiagramNode != null) {
287: lastDiagramNode.collapse();
288: new Node(lastDiagramNode.tree(), lastDiagramNode
289: .getParentPath()).collapse();
290: }
291: try {
292: DiagramOperator d = new DiagramOperator("acD");
293: d.closeAllDocuments();
294: d.waitClosed();
295: new EventTool().waitNoEvent(1000);
296: } catch (Exception ex) {
297: }
298: ;
299: closeAllModal();
300: //save
301: org.netbeans.test.umllib.util.Utils.tearDown();
302: }
303:
304: private void testElementPlace(String workPkg, String diagramName,
305: String element, String elementName, ElementTypes elementType) {
306: lastTestCase = getCurrentTestNamesWithCheck()[1];
307: DiagramOperator d = createDiagram(project, workPkg, diagramName);
308: //
309: int numChild = lastDiagramNode.getChildren().length;
310: //
311: UMLPaletteOperator pl = new UMLPaletteOperator();
312: //
313: try {
314: pl.selectTool(element);
315: } catch (NotFoundException ex) {
316: fail("BLOCKING: Can't find '" + element + "' in paletter");
317: }
318: //
319: DrawingAreaOperator drAr = d.getDrawingArea();
320: java.awt.Point a = drAr.getFreePoint();
321: drAr.clickMouse(a.x, a.y, 1);
322: new EventTool().waitNoEvent(500);
323: //
324: try {
325: DiagramElementOperator dEl = new DiagramElementOperator(d,
326: elementName, elementType, 0);
327: } catch (Exception ex) {
328: try {
329: fail(element
330: + " wasn't added to diagram, but object with type:"
331: + new DiagramElementOperator(d, elementName)
332: .getType()
333: + ": and element type :"
334: + new DiagramElementOperator(d, elementName)
335: .getElementType()
336: + ": was added whyle type should be :"
337: + elementType + ": was added");
338: } catch (Exception ex2) {
339:
340: }
341: fail(element + " wasn't added to iagram.");
342: }
343: //
344: new EventTool().waitNoEvent(500);
345: PropertySheetOperator ps = new PropertySheetOperator();
346: if (elementName.equals("")) {
347: assertTrue("Property sheet isn't for " + elementType
348: + ", but for " + ps.getName(),
349: (elementType + " - Properties")
350: .equals(ps.getName()));
351: } else {
352: assertTrue("Property sheet isn't for " + elementName
353: + ", but for " + ps.getName(),
354: (elementName + " - Properties")
355: .equals(ps.getName()));
356: }
357: //
358: int numChild2 = lastDiagramNode.getChildren().length;
359:
360: org.netbeans.test.uml.activitydiagram.utils.Utils
361: .setTextProperty("Name", "ELName");
362: //
363: new EventTool().waitNoEvent(500);
364: //
365: try {
366: DiagramElementOperator dEl = new DiagramElementOperator(d,
367: "ELName", elementType, 0);
368: } catch (Exception ex) {
369: fail("Can't find " + element
370: + " with name \"ELName\" on diagram");
371: }
372: //
373: assertTrue("No name propagated to node within diagram",
374: lastDiagramNode.isChildPresent("ELName"));
375: }
376:
377: }
|