Search in sources :

Example 1 with MockGraphModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel in project binnavi by google.

the class CModulesPanelTest method testLifeCycleNoDebugger.

@Test
public void testLifeCycleNoDebugger() throws IllegalArgumentException, SecurityException {
    final CDebugPerspectiveModel model = new CDebugPerspectiveModel(new MockGraphModel());
    final CModulesPanel panel = new CModulesPanel(model);
    panel.dispose();
}
Also used : CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) Test(org.junit.Test)

Example 2 with MockGraphModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel in project binnavi by google.

the class CThreadInformationPanelTest method test3.

/**
   * This test makes sure that going from no debugger to a debugger to more threads works fine.
   */
@Test
public void test3() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // CGraphModelFactory.get(database,
    final IGraphModel graphModel = new MockGraphModel();
    // viewContainer);
    final CDebugPerspectiveModel model = CDebugPerspectiveModelFactory.get(graphModel);
    final CThreadInformationPanel panel = new CThreadInformationPanel(model);
    final IDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final LinkedHashSet<?> perspectiveListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(model, "m_listeners"), "m_listeners");
    final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
    assertEquals(1, perspectiveListeners.size());
    assertEquals(1, debuggerListeners.size());
    model.setActiveDebugger(debugger);
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    final LinkedHashSet<?> threadListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(thread, "listeners"), "m_listeners");
    assertEquals(2, threadListeners.size());
    assertEquals(2, threadListeners.size());
    assertEquals(2, debuggerListeners.size());
    debugger.getProcessManager().removeThread(thread);
    assertEquals(0, threadListeners.size());
    panel.dispose();
    assertEquals(0, threadListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(0, perspectiveListeners.size());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) AbstractDebugger(com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Test(org.junit.Test)

Example 3 with MockGraphModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel in project binnavi by google.

the class CThreadInformationPanelTest method test.

/**
   * This test makes sure that going from no debugger to a debugger works fine.
   */
@Test
public void test() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // CGraphModelFactory.get(database,
    final IGraphModel graphModel = new MockGraphModel();
    // viewContainer);
    final CDebugPerspectiveModel model = CDebugPerspectiveModelFactory.get(graphModel);
    final CThreadInformationPanel panel = new CThreadInformationPanel(model);
    final IDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    final LinkedHashSet<?> perspectiveListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(model, "m_listeners"), "m_listeners");
    final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
    final LinkedHashSet<?> threadListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(thread, "listeners"), "m_listeners");
    assertEquals(1, perspectiveListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(1, threadListeners.size());
    model.setActiveDebugger(debugger);
    assertEquals(2, threadListeners.size());
    assertEquals(2, debuggerListeners.size());
    panel.dispose();
    assertEquals(1, threadListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(0, perspectiveListeners.size());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) AbstractDebugger(com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Test(org.junit.Test)

Example 4 with MockGraphModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel in project binnavi by google.

the class CMemoryViewerSynchronizerTest method testNewThread.

/**
   * This test makes sure that the synchronizer can handle new threads.
   *
   * Fix for Case 2036: Listener issue in the memory viewer
   */
@Test
public void testNewThread() {
    final IGraphModel graphModel = new MockGraphModel();
    final CDebugPerspectiveModel model = new CDebugPerspectiveModel(graphModel);
    final JHexView hexView = new JHexView();
    final CMemoryProvider provider = new CMemoryProvider();
    model.setActiveDebugger(m_debugger);
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    m_debugger.getProcessManager().addThread(thread);
    m_debugger.getProcessManager().setActiveThread(thread);
    final CMemoryViewerSynchronizer synchronizer = new CMemoryViewerSynchronizer(hexView, provider, model);
    synchronizer.dispose();
}
Also used : CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) JHexView(com.google.security.zynamics.zylib.gui.JHexPanel.JHexView) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) Test(org.junit.Test)

Example 5 with MockGraphModel

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel in project binnavi by google.

the class CMemoryViewerSynchronizerTest method testActiveDebugger.

@Test
public void testActiveDebugger() {
    final IGraphModel graphModel = new MockGraphModel();
    final CDebugPerspectiveModel model = new CDebugPerspectiveModel(graphModel);
    final JHexView hexView = new JHexView();
    final CMemoryProvider provider = new CMemoryProvider();
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    model.setActiveDebugger(debugger);
    final CMemoryViewerSynchronizer synchronizer = new CMemoryViewerSynchronizer(hexView, provider, model);
    debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
    assertEquals(AddressMode.BIT32, hexView.getAddressMode());
    debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(64, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
    assertEquals(AddressMode.BIT64, hexView.getAddressMode());
    synchronizer.dispose();
}
Also used : CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) JHexView(com.google.security.zynamics.zylib.gui.JHexPanel.JHexView) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) TargetInformationReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) Test(org.junit.Test)

Aggregations

MockGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel)8 CDebugPerspectiveModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel)8 Test (org.junit.Test)7 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)6 IGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel)6 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)6 AbstractDebugger (com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger)4 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)4 LinkedHashSet (java.util.LinkedHashSet)4 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)3 JHexView (com.google.security.zynamics.zylib.gui.JHexPanel.JHexView)2 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)1 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)1 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)1 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1