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) 2005
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.awt.event.KeyEvent;
047: import junit.textui.TestRunner;
048: import org.netbeans.jellytools.Bundle;
049: import org.netbeans.jellytools.EditorOperator;
050: import org.netbeans.jellytools.JellyTestCase;
051: import org.netbeans.jellytools.MainWindowOperator;
052: import org.netbeans.jellytools.ProjectsTabOperator;
053: import org.netbeans.jellytools.actions.Action;
054: import org.netbeans.jellytools.actions.DebugProjectAction;
055: import org.netbeans.jellytools.actions.OpenAction;
056: import org.netbeans.jellytools.modules.debugger.actions.ContinueAction;
057: import org.netbeans.jellytools.modules.debugger.actions.RunToCursorAction;
058: import org.netbeans.jellytools.modules.debugger.actions.StepIntoAction;
059: import org.netbeans.jellytools.modules.debugger.actions.StepOutAction;
060: import org.netbeans.jellytools.modules.debugger.actions.StepOverAction;
061: import org.netbeans.jellytools.nodes.Node;
062: import org.netbeans.jellytools.nodes.SourcePackagesNode;
063: import org.netbeans.jemmy.EventTool;
064: import org.netbeans.jemmy.JemmyProperties;
065: import org.netbeans.jemmy.operators.ContainerOperator;
066: import org.netbeans.jemmy.operators.JPopupMenuOperator;
067: import org.netbeans.junit.NbTestSuite;
068:
069: /**
070: *
071: * @author cincura, ehucka
072: */
073: public class Actions extends JellyTestCase {
074:
075: public Actions(String name) {
076: super (name);
077: }
078:
079: public static void main(String[] args) {
080: TestRunner.run(suite());
081: }
082:
083: public static NbTestSuite suite() {
084: NbTestSuite suite = new NbTestSuite();
085: suite.addTest(new Actions("testCheckEnabledActions"));
086: suite.addTest(new Actions("testCheckEnabledActionsDebugging"));
087: suite.addTest(new Actions("testToggleBreakpoints"));
088: suite.addTest(new Actions("testStartDebugging"));
089: suite.addTest(new Actions("testRemoveBreakpoint"));
090: suite.addTest(new Actions("testStepInto"));
091: suite.addTest(new Actions("testStepOver"));
092: suite.addTest(new Actions("testRunToCursor"));
093: suite.addTest(new Actions("testStepOut"));
094: suite.addTest(new Actions("testContinue"));
095: suite.addTest(new Actions("testStepOverExpression"));
096: suite.addTest(new Actions("testPause"));
097: return suite;
098: }
099:
100: /** setUp method */
101: public void setUp() {
102: System.out.println("######## " + getName() + " #######");
103: }
104:
105: public void tearDown() {
106: JemmyProperties.getCurrentOutput().printTrace("\nteardown\n");
107: if (getName().equals("testPause")) {
108: Utilities.endAllSessions();
109: Utilities.deleteAllBreakpoints();
110: }
111: }
112:
113: public void testCheckEnabledActions() throws Throwable {
114: try {
115: new Action(null, Utilities.setMainProjectAction)
116: .perform(new ProjectsTabOperator()
117: .getProjectRootNode(Utilities.testProjectName));
118:
119: Node projectNode = ProjectsTabOperator.invoke()
120: .getProjectRootNode(Utilities.testProjectName);
121: Utilities
122: .verifyPopup(
123: projectNode,
124: new String[] {
125: Bundle
126: .getString(
127: "org.netbeans.modules.java.j2seproject.ui.Bundle",
128: "LBL_BuildAction_Name"),
129: Bundle
130: .getString(
131: "org.netbeans.modules.java.j2seproject.ui.Bundle",
132: "LBL_RunAction_Name"),
133: Bundle
134: .getString(
135: "org.netbeans.modules.debugger.ui.actions.Bundle",
136: "LBL_DebugProjectActionOnProject_Name") });
137:
138: //main menu actions
139: //check main menu debug main project action
140: assertTrue(Utilities.runMenu + "|"
141: + Utilities.debugMainProjectItem, Utilities
142: .verifyMainMenu(Utilities.runMenu + "|"
143: + Utilities.debugMainProjectItem, true));
144: //Step into
145: assertTrue(
146: Utilities.runMenu + "|" + Utilities.stepIntoItem,
147: Utilities.verifyMainMenu(Utilities.runMenu + "|"
148: + Utilities.stepIntoItem, true));
149: //new breakpoint
150: assertTrue(Utilities.runMenu + "|"
151: + Utilities.newBreakpointItem, Utilities
152: .verifyMainMenu(Utilities.runMenu + "|"
153: + Utilities.newBreakpointItem, true));
154: //new watch
155: assertTrue(
156: Utilities.runMenu + "|" + Utilities.newWatchItem,
157: Utilities.verifyMainMenu(Utilities.runMenu + "|"
158: + Utilities.newWatchItem, true));
159: //main menu actions disabled
160: //check finish debugger
161: assertFalse(Utilities.runMenu + "|"
162: + Utilities.finishSessionsItem, Utilities
163: .verifyMainMenu(Utilities.runMenu + "|"
164: + Utilities.finishSessionsItem, false));
165: //pause
166: assertFalse(Utilities.runMenu + "|" + Utilities.pauseItem,
167: Utilities.verifyMainMenu(Utilities.runMenu + "|"
168: + Utilities.pauseItem, false));
169: //continue
170: assertFalse(Utilities.runMenu + "|"
171: + Utilities.continueItem, Utilities.verifyMainMenu(
172: Utilities.runMenu + "|" + Utilities.continueItem,
173: false));
174: //step over
175: assertFalse(Utilities.runMenu + "|"
176: + Utilities.stepOverItem, Utilities.verifyMainMenu(
177: Utilities.runMenu + "|" + Utilities.stepOverItem,
178: false));
179: //step over expression
180: assertFalse(Utilities.runMenu + "|"
181: + Utilities.stepOverExpresItem, Utilities
182: .verifyMainMenu(Utilities.runMenu + "|"
183: + Utilities.stepOverExpresItem, false));
184: //step out
185: assertFalse(
186: Utilities.runMenu + "|" + Utilities.stepOutItem,
187: Utilities.verifyMainMenu(Utilities.runMenu + "|"
188: + Utilities.stepOutItem, false));
189: //run to cursor
190: assertFalse(Utilities.runMenu + "|"
191: + Utilities.runToCursorItem, Utilities
192: .verifyMainMenu(Utilities.runMenu + "|"
193: + Utilities.runToCursorItem, false));
194: //run into method
195: assertFalse(Utilities.runMenu + "|"
196: + Utilities.runIntoMethodItem, Utilities
197: .verifyMainMenu(Utilities.runMenu + "|"
198: + Utilities.runIntoMethodItem, false));
199: //apply code changes
200: assertFalse(Utilities.runMenu + "|"
201: + Utilities.applyCodeChangesItem, Utilities
202: .verifyMainMenu(Utilities.runMenu + "|"
203: + Utilities.applyCodeChangesItem, false));
204: //toggle breakpoint
205: assertFalse(Utilities.runMenu + "|"
206: + Utilities.toggleBreakpointItem, Utilities
207: .verifyMainMenu(Utilities.runMenu + "|"
208: + Utilities.toggleBreakpointItem, false));
209: //evaluate expression
210: assertFalse(Utilities.runMenu + "|"
211: + Utilities.evaluateExpressionItem, Utilities
212: .verifyMainMenu(Utilities.runMenu + "|"
213: + Utilities.evaluateExpressionItem, false));
214: MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
215:
216: //open source file
217: Node beanNode = new Node(new SourcePackagesNode(
218: Utilities.testProjectName),
219: "examples.advanced|MemoryView.java"); //NOI18N
220: new OpenAction().performAPI(beanNode); // NOI18N
221: EditorOperator eo = new EditorOperator("MemoryView.java");
222: Utilities.setCaret(eo, 80);
223: new EventTool().waitNoEvent(1000); //because of issue 70731
224: //main menu file actions
225: //check run file action
226: String actionName = Bundle.getStringTrimmed(
227: "org.netbeans.modules.project.ui.actions.Bundle",
228: "LBL_RunSingleAction_Name", new Object[] {
229: new Integer(1), "MemoryView.java" });
230: assertTrue(Utilities.runMenu + "|" + Utilities.runFileMenu
231: + "|" + actionName + " is not enabled", Utilities
232: .verifyMainMenu(Utilities.runMenu + "|"
233: + Utilities.runFileMenu + "|" + actionName,
234: true));
235: //check debug file action
236: actionName = Bundle.getStringTrimmed(
237: "org.netbeans.modules.debugger.ui.actions.Bundle",
238: "LBL_DebugSingleAction_Name", new Object[] {
239: new Integer(1), "MemoryView.java" });
240: assertTrue(Utilities.runMenu + "|" + Utilities.runFileMenu
241: + "|" + actionName + " is not enabled", Utilities
242: .verifyMainMenu(Utilities.runMenu + "|"
243: + Utilities.runFileMenu + "|" + actionName,
244: true));
245: //run to cursor
246: assertTrue(Utilities.runMenu + "|"
247: + Utilities.runToCursorItem + " is not enabled",
248: Utilities.verifyMainMenu(Utilities.runMenu + "|"
249: + Utilities.runToCursorItem, true));
250: //toggle breakpoint
251: assertTrue(Utilities.runMenu + "|"
252: + Utilities.toggleBreakpointItem
253: + " is not enabled", Utilities.verifyMainMenu(
254: Utilities.runMenu + "|"
255: + Utilities.toggleBreakpointItem, true));
256: MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
257: MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
258:
259: //source popup menu actions
260: JPopupMenuOperator operator = new JPopupMenuOperator(
261: JPopupMenuOperator.callPopup(eo, 50, 50));
262: Utilities
263: .verifyPopup(
264: operator,
265: new String[] {
266: Bundle
267: .getStringTrimmed(
268: "org.netbeans.modules.java.project.Bundle",
269: "LBL_DebugFile_Action"),
270: Bundle
271: .getStringTrimmed(
272: "org.netbeans.modules.debugger.ui.actions.Bundle",
273: "CTL_New_Watch"),
274: Bundle
275: .getStringTrimmed(
276: "org.netbeans.modules.debugger.ui.actions.Bundle",
277: "CTL_Toggle_breakpoint") });
278:
279: //tools menu
280: //debug is not visible
281: for (int i = 0; i < MainWindowOperator.getDefault()
282: .getToolbarCount(); i++) {
283: assertFalse("Debug toolbar is visible",
284: MainWindowOperator.getDefault().getToolbarName(
285: i).equals(Utilities.debugToolbarLabel));
286: }
287: //run
288: ContainerOperator tbrop = MainWindowOperator
289: .getDefault()
290: .getToolbar(
291: Bundle
292: .getString(
293: "org.netbeans.modules.project.ui.Bundle",
294: "Toolbars/Build"));
295: assertTrue(
296: "Debug Main Project toolbar action is not enabled",
297: MainWindowOperator
298: .getDefault()
299: .getToolbarButton(
300: tbrop,
301: Bundle
302: .getStringTrimmed(
303: "org.netbeans.modules.debugger.ui.actions.Bundle",
304: "LBL_DebugMainProjectAction_Name"))
305: .isEnabled());
306:
307: eo.close();
308: } catch (Throwable th) {
309: Utilities.captureScreen(this );
310: throw th;
311: }
312: }
313:
314: public void testCheckEnabledActionsDebugging() throws Throwable {
315: try {
316: //open source
317: Node projectNode = ProjectsTabOperator.invoke()
318: .getProjectRootNode(Utilities.testProjectName);
319: Node beanNode = new Node(new SourcePackagesNode(
320: Utilities.testProjectName),
321: "examples.advanced|MemoryView.java"); //NOI18N
322: new OpenAction().performAPI(beanNode); // NOI18N
323: EditorOperator eo = new EditorOperator("MemoryView.java");
324: //place breakpoint
325: Utilities.toggleBreakpoint(eo, 104);
326: //start debugging
327: new DebugProjectAction().perform(projectNode);
328: Utilities.getDebugToolbar().waitComponentVisible(true);
329: //wait for breakpoint
330: Utilities
331: .waitStatusText("Thread main stopped at MemoryView.java:104");
332: //check actions
333: //main menu actions
334: //check main menu debug main project action
335: assertTrue(Utilities.runMenu + "|"
336: + Utilities.debugMainProjectItem, Utilities
337: .verifyMainMenu(Utilities.runMenu + "|"
338: + Utilities.debugMainProjectItem, true));
339: //Step into
340: assertTrue(
341: Utilities.runMenu + "|" + Utilities.stepIntoItem,
342: Utilities.verifyMainMenu(Utilities.runMenu + "|"
343: + Utilities.stepIntoItem, true));
344: //new breakpoint
345: assertTrue(Utilities.runMenu + "|"
346: + Utilities.newBreakpointItem, Utilities
347: .verifyMainMenu(Utilities.runMenu + "|"
348: + Utilities.newBreakpointItem, true));
349: //new watch
350: assertTrue(
351: Utilities.runMenu + "|" + Utilities.newWatchItem,
352: Utilities.verifyMainMenu(Utilities.runMenu + "|"
353: + Utilities.newWatchItem, true));
354: //check finish debugger
355: assertTrue(Utilities.runMenu + "|"
356: + Utilities.finishSessionsItem, Utilities
357: .verifyMainMenu(Utilities.runMenu + "|"
358: + Utilities.finishSessionsItem, true));
359: //pause
360: assertFalse(Utilities.runMenu + "|" + Utilities.pauseItem,
361: Utilities.verifyMainMenu(Utilities.runMenu + "|"
362: + Utilities.pauseItem, false));
363: //continue
364: assertTrue(
365: Utilities.runMenu + "|" + Utilities.continueItem,
366: Utilities.verifyMainMenu(Utilities.runMenu + "|"
367: + Utilities.continueItem, true));
368: //step over
369: assertTrue(
370: Utilities.runMenu + "|" + Utilities.stepOverItem,
371: Utilities.verifyMainMenu(Utilities.runMenu + "|"
372: + Utilities.stepOverItem, true));
373: //step over expression
374: assertTrue(Utilities.runMenu + "|"
375: + Utilities.stepOverExpresItem, Utilities
376: .verifyMainMenu(Utilities.runMenu + "|"
377: + Utilities.stepOverExpresItem, true));
378: //step out
379: assertTrue(Utilities.runMenu + "|" + Utilities.stepOutItem,
380: Utilities.verifyMainMenu(Utilities.runMenu + "|"
381: + Utilities.stepOutItem, true));
382: //run to cursor
383: assertTrue(Utilities.runMenu + "|"
384: + Utilities.runToCursorItem, Utilities
385: .verifyMainMenu(Utilities.runMenu + "|"
386: + Utilities.runToCursorItem, true));
387: //run into method
388: assertTrue(Utilities.runMenu + "|"
389: + Utilities.runIntoMethodItem, Utilities
390: .verifyMainMenu(Utilities.runMenu + "|"
391: + Utilities.runIntoMethodItem, true));
392: //apply code changes
393: assertTrue(Utilities.runMenu + "|"
394: + Utilities.applyCodeChangesItem, Utilities
395: .verifyMainMenu(Utilities.runMenu + "|"
396: + Utilities.applyCodeChangesItem, true));
397: //toggle breakpoint
398: assertTrue(Utilities.runMenu + "|"
399: + Utilities.toggleBreakpointItem, Utilities
400: .verifyMainMenu(Utilities.runMenu + "|"
401: + Utilities.toggleBreakpointItem, true));
402: //evaluate expression
403: assertTrue(Utilities.runMenu + "|"
404: + Utilities.evaluateExpressionItem, Utilities
405: .verifyMainMenu(Utilities.runMenu + "|"
406: + Utilities.evaluateExpressionItem, true));
407: MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
408:
409: //debug toolbar
410: ContainerOperator debugToolbarOper = Utilities
411: .getDebugToolbar();
412: assertTrue(
413: "Toolbar action Finish is not enabled",
414: MainWindowOperator
415: .getDefault()
416: .getToolbarButton(
417: debugToolbarOper,
418: Bundle
419: .getStringTrimmed(
420: "org.netbeans.modules.debugger.ui.actions.Bundle",
421: "CTL_KillAction_name"))
422: .isEnabled());
423: assertFalse(
424: "Toolbar action Pause is not disabled",
425: MainWindowOperator
426: .getDefault()
427: .getToolbarButton(
428: debugToolbarOper,
429: Bundle
430: .getStringTrimmed(
431: "org.netbeans.modules.debugger.ui.actions.Bundle",
432: "CTL_Pause_action_name"))
433: .isEnabled());
434: assertTrue(
435: "Toolbar action Continue is not enabled",
436: MainWindowOperator
437: .getDefault()
438: .getToolbarButton(
439: debugToolbarOper,
440: Bundle
441: .getStringTrimmed(
442: "org.netbeans.modules.debugger.ui.actions.Bundle",
443: "CTL_Continue_action_name"))
444: .isEnabled());
445: //step
446: assertTrue(
447: "Toolbar action Step ovet is not enabled",
448: MainWindowOperator
449: .getDefault()
450: .getToolbarButton(
451: debugToolbarOper,
452: Bundle
453: .getStringTrimmed(
454: "org.netbeans.modules.debugger.ui.actions.Bundle",
455: "CTL_Step_over_action_name"))
456: .isEnabled());
457: assertTrue(
458: "Toolbar action Step over expression is not enabled",
459: MainWindowOperator
460: .getDefault()
461: .getToolbarButton(
462: debugToolbarOper,
463: Bundle
464: .getStringTrimmed(
465: "org.netbeans.modules.debugger.ui.actions.Bundle",
466: "CTL_Step_operation_action_name"))
467: .isEnabled());
468: assertTrue(
469: "Toolbar action Step into is not enabled",
470: MainWindowOperator
471: .getDefault()
472: .getToolbarButton(
473: debugToolbarOper,
474: Bundle
475: .getStringTrimmed(
476: "org.netbeans.modules.debugger.ui.actions.Bundle",
477: "CTL_Step_into_action_name"))
478: .isEnabled());
479: assertTrue(
480: "Toolbar action Step out is not enabled",
481: MainWindowOperator
482: .getDefault()
483: .getToolbarButton(
484: debugToolbarOper,
485: Bundle
486: .getStringTrimmed(
487: "org.netbeans.modules.debugger.ui.actions.Bundle",
488: "CTL_Step_out_action_name"))
489: .isEnabled());
490: //run to cursor
491: assertTrue(
492: "Toolbar action Run to cursor is not enabled",
493: MainWindowOperator
494: .getDefault()
495: .getToolbarButton(
496: debugToolbarOper,
497: Bundle
498: .getStringTrimmed(
499: "org.netbeans.modules.debugger.ui.actions.Bundle",
500: "CTL_Run_to_cursor_action_name"))
501: .isEnabled());
502: assertTrue(
503: "Toolbar action Apply code changes is not enabled",
504: MainWindowOperator
505: .getDefault()
506: .getToolbarButton(
507: debugToolbarOper,
508: Bundle
509: .getStringTrimmed(
510: "org.netbeans.modules.debugger.ui.actions.Bundle",
511: "CTL_Fix_action_name"))
512: .isEnabled());
513:
514: //remove breakpoint
515: Utilities.deleteAllBreakpoints();
516: //finish debugging
517: Utilities.endAllSessions();
518: //close sources
519: eo.close();
520: } catch (Throwable th) {
521: Utilities.captureScreen(this );
522: throw th;
523: }
524: }
525:
526: public void testToggleBreakpoints() throws Throwable {
527: try {
528: //open source
529: Node projectNode = ProjectsTabOperator.invoke()
530: .getProjectRootNode(Utilities.testProjectName);
531: Node beanNode = new Node(new SourcePackagesNode(
532: Utilities.testProjectName),
533: "examples.advanced|MemoryView.java"); //NOI18N
534: new OpenAction().performAPI(beanNode); // NOI18N
535: EditorOperator eo = new EditorOperator("MemoryView.java");
536: //place breakpoint
537: Utilities.toggleBreakpoint(eo, 80);
538: assertTrue("Breakpoint annotation is not displayed",
539: Utilities.checkAnnotation(eo, 80, "Breakpoint"));
540: } catch (Throwable th) {
541: Utilities.captureScreen(this );
542: throw th;
543: }
544: }
545:
546: static int lastLineNumber = 0;
547:
548: public void testStartDebugging() throws Throwable {
549: try {
550: //start debugging
551: Node projectNode = ProjectsTabOperator.invoke()
552: .getProjectRootNode(Utilities.testProjectName);
553: new DebugProjectAction().perform(projectNode);
554: Utilities.getDebugToolbar().waitComponentVisible(true);
555: //wait for breakpoint
556: Utilities
557: .waitStatusText("Thread main stopped at MemoryView.java:80");
558: EditorOperator eo = new EditorOperator("MemoryView.java");
559: assertTrue("Breakpoint annotation is not on line 80",
560: Utilities.checkAnnotation(eo, 80, "Breakpoint"));
561: assertTrue("Current PC annotation is not on line 80",
562: Utilities.checkAnnotation(eo, 80, "CurrentPC"));
563: } catch (Throwable th) {
564: Utilities.captureScreen(this );
565: throw th;
566: }
567: }
568:
569: public void testRemoveBreakpoint() throws Throwable {
570: try {
571: EditorOperator eo = new EditorOperator("MemoryView.java");
572: //remove breakpoint
573: Utilities.toggleBreakpoint(eo, 80, false);
574: assertFalse(
575: "Breakpoint annotation is not removed from line 80",
576: Utilities.checkAnnotation(eo, 80, "Breakpoint"));
577: } catch (Throwable th) {
578: Utilities.captureScreen(this );
579: throw th;
580: }
581: }
582:
583: public void testStepInto() throws Throwable {
584: try {
585: new StepIntoAction().performShortcut();
586: lastLineNumber = Utilities.waitDebuggerConsole(
587: "Thread main stopped at MemoryView.java:92",
588: lastLineNumber + 1);
589: //check 80, 92
590: EditorOperator eo = new EditorOperator("MemoryView.java");
591: assertTrue("CurrentPC annotation is not on line 92",
592: Utilities.checkAnnotation(eo, 92, "CurrentPC"));
593: assertTrue("Call Site annotation is not on line 80",
594: Utilities.checkAnnotation(eo, 80, "CallSite"));
595: } catch (Throwable th) {
596: Utilities.captureScreen(this );
597: throw th;
598: }
599: }
600:
601: public void testStepOver() throws Throwable {
602: try {
603: new StepOverAction().performShortcut();
604: lastLineNumber = Utilities.waitDebuggerConsole(
605: "Thread main stopped at MemoryView.java:93",
606: lastLineNumber + 1);
607: //check 80, 82
608: EditorOperator eo = new EditorOperator("MemoryView.java");
609: assertFalse("CurrentPC annotation remains on line 92",
610: Utilities.checkAnnotation(eo, 92, "CurrentPC"));
611: assertTrue("CurrentPC annotation is not on line 93",
612: Utilities.checkAnnotation(eo, 93, "CurrentPC"));
613: } catch (Throwable th) {
614: Utilities.captureScreen(this );
615: throw th;
616: }
617: }
618:
619: public void testRunToCursor() throws Throwable {
620: try {
621: EditorOperator eo = new EditorOperator("MemoryView.java");
622: Utilities.setCaret(eo, 109);
623: //run to cursor
624: new RunToCursorAction().perform();
625: lastLineNumber = Utilities.waitDebuggerConsole(
626: "Thread main stopped at MemoryView.java:109",
627: lastLineNumber + 1);
628: //check line
629: assertFalse("Current PC annotation remains on line 93",
630: Utilities.checkAnnotation(eo, 93, "CurrentPC"));
631: assertTrue("Current PC annotation is not on line 109",
632: Utilities.checkAnnotation(eo, 109, "CurrentPC"));
633: } catch (Throwable th) {
634: Utilities.captureScreen(this );
635: throw th;
636: }
637: }
638:
639: public void testStepOut() throws Throwable {
640: try {
641: new StepOutAction().performShortcut();
642: lastLineNumber = Utilities.waitDebuggerConsole(
643: "Thread main stopped at MemoryView.java:80",
644: lastLineNumber + 1);
645: //check 82, 92
646: EditorOperator eo = new EditorOperator("MemoryView.java");
647: assertFalse("Current PC annotation remains on line 109",
648: Utilities.checkAnnotation(eo, 109, "CurrentPC"));
649: assertTrue("Current PC annotation is not on line 80",
650: Utilities.checkAnnotation(eo, 80,
651: "CurrentExpressionLine"));
652: } catch (Throwable th) {
653: Utilities.captureScreen(this );
654: throw th;
655: }
656: }
657:
658: public void testContinue() throws Throwable {
659: try {
660: EditorOperator eo = new EditorOperator("MemoryView.java");
661: //remove breakpoint
662: Utilities.toggleBreakpoint(eo, 104, true);
663: new ContinueAction().perform();
664: lastLineNumber = Utilities.waitDebuggerConsole(
665: "Thread main stopped at MemoryView.java:104",
666: lastLineNumber + 1);
667: assertFalse("Current PC annotation remains on line 80",
668: Utilities.checkAnnotation(eo, 80, "CurrentPC"));
669: assertTrue("Current PC annotation is not on line 104",
670: Utilities.checkAnnotation(eo, 104, "CurrentPC"));
671: Utilities.toggleBreakpoint(eo, 104, false);
672: } catch (Throwable th) {
673: Utilities.captureScreen(this );
674: throw th;
675: }
676: }
677:
678: public void testStepOverExpression() throws Throwable {
679: try {
680: EditorOperator eo = new EditorOperator("MemoryView.java");
681:
682: new Action(Utilities.runMenu + "|"
683: + Utilities.stepOverExpresItem, null).perform();
684: lastLineNumber = Utilities.waitDebuggerConsole(
685: "Thread main stopped at MemoryView.java:104",
686: lastLineNumber + 1);
687: assertTrue(
688: "CurrentExpressionLine annotation is not on line 105",
689: Utilities.checkAnnotation(eo, 105,
690: "CurrentExpressionLine"));
691: new Action(Utilities.runMenu + "|"
692: + Utilities.stepOverExpresItem, null).perform();
693: lastLineNumber = Utilities.waitDebuggerConsole(
694: "Thread main stopped at MemoryView.java:104",
695: lastLineNumber + 1);
696: assertTrue(
697: "CurrentExpressionLine annotation is not on line 106",
698: Utilities.checkAnnotation(eo, 106,
699: "CurrentExpressionLine"));
700: new Action(Utilities.runMenu + "|"
701: + Utilities.stepOverExpresItem, null).perform();
702: lastLineNumber = Utilities.waitDebuggerConsole(
703: "Thread main stopped at MemoryView.java:104",
704: lastLineNumber + 1);
705: assertTrue(
706: "CurrentExpressionLine annotation is not on line 107",
707: Utilities.checkAnnotation(eo, 107,
708: "CurrentExpressionLine"));
709: new Action(Utilities.runMenu + "|"
710: + Utilities.stepOverExpresItem, null).perform();
711: lastLineNumber = Utilities.waitDebuggerConsole(
712: "Thread main stopped at MemoryView.java:104",
713: lastLineNumber + 1);
714: assertTrue(
715: "CurrentExpressionLine annotation is not on line 104",
716: Utilities.checkAnnotation(eo, 104,
717: "CurrentExpressionLine"));
718: new Action(Utilities.runMenu + "|"
719: + Utilities.stepOverExpresItem, null).perform();
720: lastLineNumber = Utilities.waitDebuggerConsole(
721: "Thread main stopped at MemoryView.java:104",
722: lastLineNumber + 1);
723: assertTrue(
724: "CurrentExpressionLine annotation is not on line 104",
725: Utilities.checkAnnotation(eo, 104,
726: "CurrentExpressionLine"));
727: new Action(Utilities.runMenu + "|"
728: + Utilities.stepOverExpresItem, null).perform();
729: lastLineNumber = Utilities.waitDebuggerConsole(
730: "Thread main stopped at MemoryView.java:109",
731: lastLineNumber + 1);
732: assertTrue("Current PC annotation is not on line 109",
733: Utilities.checkAnnotation(eo, 109, "CurrentPC"));
734: } catch (Throwable th) {
735: Utilities.captureScreen(this );
736: throw th;
737: }
738: }
739:
740: public void testPause() throws Throwable {
741: try {
742: EditorOperator eo = new EditorOperator("MemoryView.java");
743: //place breakpoint
744: Utilities.toggleBreakpoint(eo, 80);
745: //continue
746: new ContinueAction().perform();
747: lastLineNumber = Utilities.waitDebuggerConsole(
748: "Thread main stopped at MemoryView.java:80",
749: lastLineNumber + 1);
750: //remove breakpoint
751: Utilities.toggleBreakpoint(eo, 80, false);
752: //continue
753: new ContinueAction().perform();
754: String pausePath = Utilities.runMenu + "|"
755: + Utilities.pauseItem;
756: for (int i = 0; i < 10; i++) {
757: if (MainWindowOperator.getDefault().menuBar()
758: .showMenuItem(pausePath).isEnabled()) {
759: new Action(pausePath, null).perform();
760: }
761: MainWindowOperator.getDefault().menuBar()
762: .closeSubmenus();
763: new EventTool().waitNoEvent(500);
764: }
765: Utilities.waitDebuggerConsole("Thread main stopped at ",
766: lastLineNumber + 1);
767: eo = new EditorOperator("MemoryView.java");
768: boolean found = false;
769: for (int i = 79; i < 87; i++) {
770: if (Utilities.checkAnnotation(eo, i, "CallSite")) {
771: found = true;
772: break;
773: }
774: }
775: assertTrue("Call Site annotation is not in for cycle",
776: found);
777: //there should not be any other opened classes - issue 83704
778: eo.closeAllDocuments();
779: } catch (Throwable th) {
780: Utilities.captureScreen(this);
781: throw th;
782: }
783: }
784: }
|