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();
}
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());
}
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());
}
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();
}
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();
}
Aggregations