Search in sources :

Example 1 with MockDebuggerProvider

use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider in project binnavi by google.

the class CVariableHighlighterTest method test1Simple.

@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final List<INaviInstruction> mockInstructions = new ArrayList<INaviInstruction>();
    final CCodeNode node = graph.getRawView().getBasicBlocks().get(0);
    final NaviNode naviNode = graph.getNode(node);
    mockInstructions.add(Iterables.get(node.getInstructions(), 0));
    final BackEndDebuggerProvider provider = new MockDebuggerProvider();
    @SuppressWarnings("unused") final CCodeNodeUpdater updater = new CCodeNodeUpdater(graph, naviNode, node, provider);
    assertFalse(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.VARIABLE_LAYER));
    CVariableHighlighter.highlightInstructions(graph, mockInstructions);
    assertTrue(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.VARIABLE_LAYER));
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CCodeNodeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater) ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BackEndDebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider) MockDebuggerProvider(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Example 2 with MockDebuggerProvider

use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider in project binnavi by google.

the class CGraphSynchonizerTest method test1Simple.

// TODO this test is very artificial as it does not test a real work flow.
@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final CSpecialInstructionsModel model = new CSpecialInstructionsModel();
    final List<CSpecialInstruction> instructions = new ArrayList<CSpecialInstruction>();
    final ITypeDescription callsDescription = model.getDescriptions().get(0);
    callsDescription.setEnabled(true);
    final CSpecialInstruction instruction = new CSpecialInstruction(callsDescription, Iterables.getFirst(graph.getRawView().getBasicBlocks().get(2).getInstructions(), null));
    final CCodeNode node = graph.getRawView().getBasicBlocks().get(2);
    final NaviNode naviNode = graph.getNode(node);
    final BackEndDebuggerProvider provider = new MockDebuggerProvider();
    new CCodeNodeUpdater(graph, naviNode, node, provider);
    instructions.add(instruction);
    model.setInstructions(instructions);
    assertFalse(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
    final CGraphSynchronizer synchronizer = new CGraphSynchronizer(graph, model);
    CTypeResultsHighlighter.updateHighlighting(graph, Lists.newArrayList(instruction));
    assertTrue(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
    synchronizer.dispose();
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CCodeNodeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater) ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BackEndDebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider) MockDebuggerProvider(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider) Test(org.junit.Test)

Aggregations

MockDebuggerProvider (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider)2 CCodeNodeUpdater (com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater)2 BackEndDebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider)2 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)2 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)2 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)1