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: * The Original Software is NetBeans.
026: * The Initial Developer of the Original Software is Sun Microsystems, Inc.
027: * Portions created by Sun Microsystems, Inc. are Copyright (C) 2003
028: * 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: * Contributor(s): Sun Microsystems, Inc.
042: */
043:
044: package gui.debuggercore;
045:
046: import java.io.File;
047: import junit.textui.TestRunner;
048: import org.netbeans.jellytools.*;
049: import org.netbeans.jellytools.actions.Action;
050: import org.netbeans.jellytools.actions.DebugProjectAction;
051: import org.netbeans.jellytools.actions.OpenAction;
052: import org.netbeans.jellytools.nodes.Node;
053: import org.netbeans.jellytools.nodes.SourcePackagesNode;
054: import org.netbeans.jemmy.JemmyProperties;
055: import org.netbeans.jemmy.util.PNGEncoder;
056: import org.netbeans.junit.NbTestSuite;
057:
058: public class StartDebugger extends JellyTestCase {
059:
060: public StartDebugger(String name) {
061: super (name);
062: }
063:
064: public static void main(String[] args) {
065: TestRunner.run(suite());
066: }
067:
068: public static NbTestSuite suite() {
069: NbTestSuite suite = new NbTestSuite();
070: suite.addTest(new StartDebugger("testDebugMainProject"));
071: suite.addTest(new StartDebugger("testDebugProject"));
072: suite.addTest(new StartDebugger("testDebugFile"));
073: suite.addTest(new StartDebugger("testRunDebuggerStepInto"));
074: suite.addTest(new StartDebugger("testRunDebuggerRunToCursor"));
075: return suite;
076: }
077:
078: public void setUp() {
079: System.out.println("######## " + getName() + " #######");
080: }
081:
082: public void tearDown() {
083: JemmyProperties.getCurrentOutput().printTrace("\nteardown\n");
084: Utilities.endAllSessions();
085: }
086:
087: public void testDebugMainProject() throws Throwable {
088: try {
089: new Action(Utilities.runMenu + "|"
090: + Utilities.debugMainProjectItem, null).perform();
091: Utilities.getDebugToolbar().waitComponentVisible(true);
092: Utilities.waitDebuggerConsole(
093: Utilities.runningStatusBarText, 0);
094: } catch (Throwable th) {
095: Utilities.captureScreen(this );
096: throw th;
097: }
098: }
099:
100: public void testDebugProject() throws Throwable {
101: try {
102: Node projectNode = ProjectsTabOperator.invoke()
103: .getProjectRootNode(Utilities.testProjectName);
104: new DebugProjectAction().perform(projectNode);
105: Utilities.getDebugToolbar().waitComponentVisible(true);
106: Utilities.waitDebuggerConsole(
107: Utilities.runningStatusBarText, 0);
108: } catch (Throwable th) {
109: Utilities.captureScreen(this );
110: throw th;
111: }
112: }
113:
114: public void testDebugFile() throws Throwable {
115: try {
116: //open source
117: Node beanNode = new Node(new SourcePackagesNode(
118: Utilities.testProjectName),
119: "examples.advanced|MemoryView.java"); //NOI18N
120: new OpenAction().performAPI(beanNode); // NOI18N
121: EditorOperator eo = new EditorOperator("MemoryView.java");
122: new Action(null, null, Utilities.debugFileShortcut)
123: .performShortcut();
124: Utilities.getDebugToolbar().waitComponentVisible(true);
125: Utilities.waitDebuggerConsole(
126: Utilities.runningStatusBarText, 0);
127: } catch (Throwable th) {
128: Utilities.captureScreen(this );
129: throw th;
130: }
131: }
132:
133: public void testRunDebuggerStepInto() throws Throwable {
134: try {
135: EditorOperator eo = new EditorOperator("MemoryView.java");
136: new Action(null, null, Utilities.stepIntoShortcut)
137: .performShortcut();
138: Utilities.getDebugToolbar().waitComponentVisible(true);
139: Utilities.waitDebuggerConsole(
140: "Thread main stopped at MemoryView.java:", 0);
141: } catch (Throwable th) {
142: Utilities.captureScreen(this );
143: throw th;
144: }
145: }
146:
147: public void testRunDebuggerRunToCursor() throws Throwable {
148: try {
149: EditorOperator eo = new EditorOperator("MemoryView.java");
150: Utilities.setCaret(eo, 75);
151: new Action(null, null, Utilities.runToCursorShortcut)
152: .performShortcut();
153: Utilities.getDebugToolbar().waitComponentVisible(true);
154: Utilities.waitDebuggerConsole(
155: "Thread main stopped at MemoryView.java:75", 0);
156: } catch (Throwable th) {
157: Utilities.captureScreen(this);
158: throw th;
159: }
160: }
161: }
|