1 19 20 package org.netbeans.api.debugger; 21 22 import org.netbeans.api.debugger.test.TestDICookie; 23 import org.netbeans.api.debugger.test.TestActionsManagerListener; 24 import org.netbeans.api.debugger.test.TestLazyActionsManagerListener; 25 26 import java.util.*; 27 28 33 public class DebuggerActionsTest extends DebuggerApiTestBase { 34 35 public DebuggerActionsTest(String s) { 36 super(s); 37 } 38 39 public void testLookup() throws Exception { 40 41 DebuggerManager dm = DebuggerManager.getDebuggerManager(); 42 Map args = new HashMap(); 43 TestDICookie tdi = TestDICookie.create(args); 44 45 Object [] services = new Object [] { tdi, this }; 46 DebuggerInfo di = DebuggerInfo.create(TestDICookie.ID, services); 47 48 DebuggerEngine engines [] = dm.startDebugging(di); 49 assertEquals("Wrong number of engines started", 1, engines.length); 50 DebuggerEngine debugger = engines[0]; 51 52 ActionsManager am = debugger.getActionsManager(); 53 TestActionsManagerListener tam = new TestActionsManagerListener(); 54 am.addActionsManagerListener(tam); 55 56 TestLazyActionsManagerListener laml = (TestLazyActionsManagerListener) debugger.lookupFirst(null, LazyActionsManagerListener.class); 57 assertNotNull("Lazy actions manager listener not loaded", laml); 58 59 am.doAction(ActionsManager.ACTION_CONTINUE); 60 am.doAction(ActionsManager.ACTION_FIX); 61 am.doAction(ActionsManager.ACTION_MAKE_CALLEE_CURRENT); 62 am.doAction(ActionsManager.ACTION_MAKE_CALLER_CURRENT); 63 am.doAction(ActionsManager.ACTION_PAUSE); 64 am.doAction(ActionsManager.ACTION_POP_TOPMOST_CALL); 65 am.doAction(ActionsManager.ACTION_RESTART); 66 am.doAction(ActionsManager.ACTION_RUN_INTO_METHOD); 67 am.doAction(ActionsManager.ACTION_RUN_TO_CURSOR); 68 am.doAction(ActionsManager.ACTION_STEP_INTO); 69 am.doAction(ActionsManager.ACTION_STEP_OUT); 70 am.doAction(ActionsManager.ACTION_STEP_OVER); 71 am.doAction(ActionsManager.ACTION_TOGGLE_BREAKPOINT); 72 dm.getCurrentSession().kill(); 73 74 am.removeActionsManagerListener(tam); 75 76 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_START)); 77 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_CONTINUE)); 78 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_FIX)); 79 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_MAKE_CALLEE_CURRENT)); 80 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_MAKE_CALLER_CURRENT)); 81 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_PAUSE)); 82 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_POP_TOPMOST_CALL)); 83 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_RESTART)); 84 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_RUN_INTO_METHOD)); 85 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_RUN_TO_CURSOR)); 86 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_STEP_INTO)); 87 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_STEP_OUT)); 88 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_STEP_OVER)); 89 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_TOGGLE_BREAKPOINT)); 90 assertTrue("Action was not performed", tdi.hasInfo(ActionsManager.ACTION_KILL)); 91 92 testReceivedEvents(tam.getPerformedActions(), false); 93 testReceivedEvents(laml.getPerformedActions(), true); 94 } 95 96 private void testReceivedEvents(List eventActions, boolean expectStartAction) { 97 if (expectStartAction) assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_START)); 98 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_CONTINUE)); 99 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_FIX)); 100 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_MAKE_CALLEE_CURRENT)); 101 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_MAKE_CALLER_CURRENT)); 102 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_PAUSE)); 103 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_POP_TOPMOST_CALL)); 104 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_RESTART)); 105 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_RUN_INTO_METHOD)); 106 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_RUN_TO_CURSOR)); 107 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_STEP_INTO)); 108 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_STEP_OUT)); 109 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_STEP_OVER)); 110 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_TOGGLE_BREAKPOINT)); 111 assertTrue("ActionListener was not notified", eventActions.remove(ActionsManager.ACTION_KILL)); 112 assertEquals("ActionListener notification failed", eventActions.size(), 0); 113 } 114 } 115 | Popular Tags |