use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CSelectionHistoryTest method testUndo.
@Test
public void testUndo() throws FileReadException, LoadCancelledException {
ConfigManager.instance().read();
final ZyGraph graph = CGraphBuilder.buildGraph(new MockView());
final CSelectionHistory history = new CSelectionHistory(graph, 4);
final CSelectionSnapshot snapshot1 = new CSelectionSnapshot(new ArrayList<NaviNode>());
final CSelectionSnapshot snapshot2 = new CSelectionSnapshot(new ArrayList<NaviNode>());
final CSelectionSnapshot snapshot3 = new CSelectionSnapshot(new ArrayList<NaviNode>());
final CSelectionSnapshot snapshot4 = new CSelectionSnapshot(new ArrayList<NaviNode>());
history.addSnapshot(snapshot1);
history.addSnapshot(snapshot2);
history.addSnapshot(snapshot3);
history.addSnapshot(snapshot4);
// First Undo
assertTrue(history.canUndo());
assertTrue(history.canRedo());
assertEquals(snapshot3, history.getUndoSnapshot(true));
// Second Undo
assertTrue(history.canUndo());
assertTrue(history.canRedo());
assertEquals(snapshot2, history.getUndoSnapshot(true));
// Third Undo
assertTrue(history.canUndo());
assertTrue(history.canRedo());
assertEquals(snapshot1, history.getUndoSnapshot(true));
// Fourth Undo (Fail) + First Redo
assertTrue(history.canUndo());
assertTrue(history.canRedo());
assertEquals(snapshot1, history.getUndoSnapshot(true));
assertEquals(snapshot2, history.getUndoSnapshot(false));
assertTrue(history.canUndo());
assertTrue(history.canRedo());
// Second Redo
assertTrue(history.canUndo());
assertTrue(history.canRedo());
assertEquals(snapshot3, history.getUndoSnapshot(false));
// Third Redo
assertTrue(history.canUndo());
assertTrue(history.canRedo());
assertEquals(snapshot4, history.getUndoSnapshot(false));
// Fourth Redo (Fail) + Last Undo
assertTrue(history.canUndo());
assertTrue(history.canRedo());
assertEquals(snapshot4, history.getUndoSnapshot(false));
assertEquals(snapshot3, history.getUndoSnapshot(true));
assertTrue(history.canUndo());
assertTrue(history.canRedo());
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CNaviNodeFactory method get.
public static NaviNode get() {
final Graph2D graph = new Graph2D();
final CTextNode node = CTextNodeFactory.get();
final ZyLabelContent content = ZyTextNodeBuilder.buildContent(node);
final IZyNodeRealizer realizer = new ZyNormalNodeRealizer<NaviNode>(content);
return new NaviNode(graph.createNode(), realizer, node);
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode 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));
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CTaggedGraphNodeNodeTest method test1Simple.
@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final ZyGraph graph = ZyGraphFactory.generateTestGraph();
final CCodeNode node = graph.getRawView().getBasicBlocks().get(0);
final NaviNode naviNode = graph.getNode(node);
@SuppressWarnings("unused") final CTaggedGraphNodeNode taggedNode = new CTaggedGraphNodeNode(graph, naviNode);
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.
the class CStepEndHelper method getEndAddresses.
/**
* Returns the addresses of all final instructions of a graph.
*
* @param graph The graph whose final addresses are returned.
*
* @return The final addresses of the graph.
*/
public static Set<BreakpointAddress> getEndAddresses(final ZyGraph graph) {
final Set<BreakpointAddress> instructions = new HashSet<BreakpointAddress>();
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
if ((node.getRawNode() instanceof INaviCodeNode) && node.getChildren().isEmpty()) {
final INaviCodeNode cnode = (INaviCodeNode) node.getRawNode();
final INaviInstruction lastInstruction = Iterables.getLast(cnode.getInstructions());
instructions.add(new BreakpointAddress(lastInstruction.getModule(), new UnrelocatedAddress(lastInstruction.getAddress())));
}
return IterationMode.CONTINUE;
}
});
return instructions;
}
Aggregations