1 21 22 package gui.debuggercore; 23 24 import java.io.File ; 25 import junit.textui.TestRunner; 26 import org.netbeans.jellytools.*; 27 import org.netbeans.jellytools.actions.Action; 28 import org.netbeans.jellytools.actions.DebugProjectAction; 29 import org.netbeans.jellytools.actions.OpenAction; 30 import org.netbeans.jellytools.nodes.Node; 31 import org.netbeans.jellytools.nodes.SourcePackagesNode; 32 import org.netbeans.jemmy.JemmyProperties; 33 import org.netbeans.jemmy.util.PNGEncoder; 34 import org.netbeans.junit.NbTestSuite; 35 36 public class StartDebugger extends JellyTestCase { 37 38 public StartDebugger(String name) { 39 super(name); 40 } 41 42 public static void main(String [] args) { 43 TestRunner.run(suite()); 44 } 45 46 public static NbTestSuite suite() { 47 NbTestSuite suite = new NbTestSuite(); 48 suite.addTest(new StartDebugger("testDebugMainProject")); 49 suite.addTest(new StartDebugger("testDebugProject")); 50 suite.addTest(new StartDebugger("testDebugFile")); 51 suite.addTest(new StartDebugger("testRunDebuggerStepInto")); 52 suite.addTest(new StartDebugger("testRunDebuggerRunToCursor")); 53 return suite; 54 } 55 56 public void setUp() { 57 System.out.println("######## " + getName() + " #######"); 58 } 59 60 public void tearDown() { 61 JemmyProperties.getCurrentOutput().printTrace("\nteardown\n"); 62 Utilities.endAllSessions(); 63 } 64 65 public void testDebugMainProject() throws Throwable { 66 try { 67 new Action(Utilities.runMenu+"|"+Utilities.debugMainProjectItem, null).perform(); 68 Utilities.getDebugToolbar().waitComponentVisible(true); 69 Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, 0); 70 } catch (Throwable th) { 71 try { 72 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 74 } catch (Exception e1) { 75 } 77 throw th; 78 } 79 } 80 81 public void testDebugProject() throws Throwable { 82 try { 83 Node projectNode = ProjectsTabOperator.invoke().getProjectRootNode(Utilities.testProjectName); 84 new DebugProjectAction().perform(projectNode); 85 Utilities.getDebugToolbar().waitComponentVisible(true); 86 Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, 0); 87 } catch (Throwable th) { 88 try { 89 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 91 } catch (Exception e1) { 92 } 94 throw th; 95 } 96 } 97 98 public void testDebugFile() throws Throwable { 99 try { 100 Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); new OpenAction().performAPI(beanNode); EditorOperator eo = new EditorOperator("MemoryView.java"); 104 new Action(null, null, Utilities.debugFileShortcut).performShortcut(); 105 Utilities.getDebugToolbar().waitComponentVisible(true); 106 Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, 0); 107 } catch (Throwable th) { 108 try { 109 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 111 } catch (Exception e1) { 112 } 114 throw th; 115 } 116 } 117 118 public void testRunDebuggerStepInto() throws Throwable { 119 try { 120 EditorOperator eo = new EditorOperator("MemoryView.java"); 121 new Action(null, null, Utilities.stepIntoShortcut).performShortcut(); 122 Utilities.getDebugToolbar().waitComponentVisible(true); 123 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:", 0); 124 } catch (Throwable th) { 125 try { 126 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 128 } catch (Exception e1) { 129 } 131 throw th; 132 } 133 } 134 135 public void testRunDebuggerRunToCursor() throws Throwable { 136 try { 137 EditorOperator eo = new EditorOperator("MemoryView.java"); 138 Utilities.setCaret(eo, 75); 139 new Action(null, null, Utilities.runToCursorShortcut).performShortcut(); 140 Utilities.getDebugToolbar().waitComponentVisible(true); 141 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:75", 0); 142 } catch (Throwable th) { 143 try { 144 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 146 } catch (Exception e1) { 147 } 149 throw th; 150 } 151 } 152 } 153 | Popular Tags |