use of com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel in project binnavi by google.
the class CModulesPanelTest method testLifeCycle.
@Test
public void testLifeCycle() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
final CDebugPerspectiveModel model = new CDebugPerspectiveModel(new MockGraphModel());
model.setActiveDebugger(debugger);
final CModulesPanel panel = new CModulesPanel(model);
panel.dispose();
final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "synchronizer"), "listeners"), "m_listeners");
final LinkedHashSet<?> processListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
// The debugger only has one internal memory synchronizer
assertEquals(1, debuggerListeners.size());
// The process manager only has one thread state synchronizer
assertEquals(1, processListeners.size());
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel in project binnavi by google.
the class CThreadInformationPanelTest method test2.
/**
* This test makes sure that going from no debugger to a debugger to no debugger works fine.
*/
@Test
public void test2() 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());
model.setActiveDebugger(null);
assertEquals(1, threadListeners.size());
assertEquals(1, debuggerListeners.size());
assertEquals(1, perspectiveListeners.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 setUp.
@Before
public void setUp() {
final IGraphModel graphModel = new MockGraphModel();
m_model = new CDebugPerspectiveModel(graphModel);
final CMemoryProvider provider = new CMemoryProvider();
m_hexView.setData(provider);
m_synchronizer = new CMemoryViewerSynchronizer(m_hexView, provider, m_model);
m_debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
m_model.setActiveDebugger(m_debugger);
}
Aggregations