|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ /* * TestTemplates.java * NetBeans JUnit based test * * Created on February 14, 2002, 5:44 PM */ package org.netbeans.test.gui.ant; import java.io.File; import java.util.HashSet; import junit.framework.*; import junit.extensions.TestSetup; import org.netbeans.junit.*; import org.netbeans.jemmy.EventTool; import org.netbeans.jellytools.Bundle; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.EditorOperator; import org.netbeans.jellytools.actions.SaveAllAction; import org.netbeans.jellytools.actions.CopyAction; import org.netbeans.jellytools.actions.PasteAction; import org.netbeans.jellytools.actions.CutAction; import org.netbeans.jellytools.actions.DeleteAction; import org.netbeans.jellytools.nodes.Node; import org.netbeans.jellytools.modules.ant.nodes.AntScriptNode; import org.netbeans.jellytools.modules.ant.nodes.AntTargetNode; import org.netbeans.jellytools.MainWindowOperator; import org.netbeans.jellytools.OutputOperator; import org.netbeans.jellytools.modules.ant.SelectATaskDialog; // ??? /** * * @author mk97936 */ public class TestVisualEdit extends JellyTestCase { String scriptsMountPath; public TestVisualEdit(java.lang.String testName) { super(testName); } public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { TestSuite suite = new NbTestSuite(TestVisualEdit.class); // TestSuite suite = new NbTestSuite(); // suite.addTest(new TestVisualEdit("testCopyCutPaste")); // TestSetup setup = new TestSetup(suite) { // protected void setUp() { // if (MainWindowOperator.getDefault().isMDI()) { // String welcomeTitle = Bundle.getStringTrimmed("org.netbeans.modules.welcome.Bundle", // "LBL_Tab_Title"); // EditorOperator ewo = new EditorOperator(welcomeTitle); // ewo.close(); // } // } // protected void tearDown() { // } // }; // return setup; return suite; } public void setUp() { scriptsMountPath = TestUtilities.getMountPointForPkg("org.netbeans.test.gui.ant"); // NOI18N } public void tearDown() { } // ------------------------------------------------------------------------- /** TEST METHOD * Copy/Cut/Paste/Delete actions on ant script nodes in Explorer */ public void testCopyCutPaste() { TestUtilities.newFromTemplate("Project.xml", "BlankCopyPaste", scriptsMountPath + "|" + "Output"); // NOI18N TestUtilities.newFromTemplate("SampleProject.xml", "SampleCopyPaste", scriptsMountPath + "|" + "Output"); // NOI18N //// ExplorerOperator expl = new ExplorerOperator(); //// expl.selectPageFilesystems(); AntTargetNode sampleScriptNode = new AntTargetNode(scriptsMountPath + "|" + "Output" + "|" + "SampleCopyPaste"); // NOI18N AntTargetNode blankScriptNode = new AntTargetNode(scriptsMountPath + "|" + "Output" + "|" + "BlankCopyPaste"); // NOI18N // Copy init target from Sample to Blank new CopyAction().perform(new Node(sampleScriptNode, "init")); new PasteAction().perform(blankScriptNode); // Cut clean target from Sample to Blank new CutAction().perform(new Node(sampleScriptNode, "clean")); new PasteAction().perform(blankScriptNode); // Copy javadoc target from Sample to Blank new CopyAction().perform(new Node(sampleScriptNode, "javadoc")); new PasteAction().perform(blankScriptNode); // Copy clean target from from Blank to Sample new CopyAction().perform(new Node(blankScriptNode, "clean")); new PasteAction().perform(sampleScriptNode); // Cut javadoc target from Blank to Sample new CutAction().perform(new Node(blankScriptNode, "javadoc")); new PasteAction().perform(sampleScriptNode); // Delete test target from Sample // new DeleteAction().perform(new Node(sampleScriptNode, "test")); // NbDialogOperator confirmDialog = new NbDialogOperator("Confirm Object Deletion"); // confirmDialog.yes(); new SaveAllAction().perform(); try { assertFile(new File(scriptsMountPath + File.separator + "Output" + File.separator + "SampleCopyPaste.xml"), new File(getGoldenFile().getParentFile(), "SampleCopyPaste.pass"), new File(getWorkDir(), "SampleCopyPaste.diff")); assertFile(new File(scriptsMountPath + File.separator + "Output" + File.separator + "BlankCopyPaste.xml"), new File(getGoldenFile().getParentFile(), "BlankCopyPaste.pass"), new File(getWorkDir(), "BlankCopyPaste.diff")); } catch (java.io.IOException ioe) { ioe.printStackTrace(); } } /** TEST METHOD * Adds to target all possible subelements and couple of tasks */ public void testAddToTarget() { TestUtilities.newFromTemplate("Project.xml", "AddToTarget", scriptsMountPath + "|" + "Output"); AntTargetNode atn = new AntTargetNode(scriptsMountPath + "|" + "Output"+ "|" + "AddToTarget" + "|" + "all"); atn.addFilelist(); atn.addFilterset(); atn.addMapper(); atn.addPath(); atn.addPatternset(); atn.addTask(SelectATaskDialog.ITEM_COPY); atn.addTask(SelectATaskDialog.ITEM_JAVAC); atn.addTask(SelectATaskDialog.ITEM_DELETE); new SaveAllAction().perform(); try { assertFile(new File(scriptsMountPath + File.separator + "Output" + File.separator + "AddToTarget.xml"), getGoldenFile(), new File(getWorkDir(), "AddToTarget.diff")); } catch (java.io.IOException ioe) { ioe.printStackTrace(); } } /** TEST METHOD * Adds to project all possible project's subelements */ public void testAddToProject() { TestUtilities.newFromTemplate("Project.xml", "AddToProject", scriptsMountPath + "|" + "Output"); // NOI18N AntScriptNode asn = new AntScriptNode(scriptsMountPath + "|" + "Output"+ "|" + "AddToProject"); // NOI18N asn.addTarget(); asn.addProperty(); asn.addTaskdef(); asn.addDescription(); asn.addFilelist(); //asn.addFileset(); asn.addFilterset(); asn.addMapper(); asn.addPath(); asn.addPatternset(); new SaveAllAction().perform(); try { assertFile(new File(scriptsMountPath + File.separator + "Output" + File.separator + "AddToProject.xml"), getGoldenFile(), new File(getWorkDir(), "AddToProject.diff")); } catch (java.io.IOException ioe) { ioe.printStackTrace(); } } /** TEST METHOD * */ public void testEditor() { TestUtilities.newFromTemplate("Project.xml", "TestEdit", scriptsMountPath + "|" + "Output"); // NOI18N EditorOperator eo = new EditorOperator("TestEdit"); // NOI18N eo.delete(4, 9, 77); eo.insert(" |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.