Search in sources :

Example 21 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph 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)

Example 22 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.

the class PostgreSQLGroupNodeCommentTests method appendInstructionCommentInGroupNode.

@Test
public void appendInstructionCommentInGroupNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    assertEquals(42, view.getNodeCount());
    final INaviViewNode node1 = view.getContent().getBasicBlocks().get(1);
    final INaviViewNode node2 = view.getContent().getBasicBlocks().get(2);
    view.getContent().createGroupNode(Lists.newArrayList(node1, node2));
    final ZyGraph graph = CGraphBuilder.buildGraph(view);
    final INaviView nonNativeView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST INSTRUCTION COMMENTS IN GROUP NODE ", " TESTING GROUP NODE COMMENTS ");
    final INaviInstruction instruction = view.getContent().getBasicBlocks().get(0).getLastInstruction();
    final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    final String firstCommentString = "TEST INSTRUCTION COMMENT PROPAGATION";
    final int firstCommentId = getProvider().appendGlobalInstructionComment(instruction, firstCommentString, user.getUserId());
    final IComment firstComment = new CComment(firstCommentId, user, null, firstCommentString);
    final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(firstCommentId);
    assertNotNull(commentsFromDatabase);
    assertEquals(1, commentsFromDatabase.size());
    assertTrue(commentsFromDatabase.contains(firstComment));
    final INaviInstruction instruction2 = nonNativeView.getBasicBlocks().get(0).getLastInstruction();
    assertEquals(1, instruction2.getGlobalComment().size());
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) UniqueTestUserGenerator(com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 23 with ZyGraph

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.

the class CPostgreSQLZyGraphTest2 method testLayouting.

@Test
public void testLayouting() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final ICallgraphView cg = m_module.getContent().getViewContainer().getNativeCallgraphView();
    final ZyGraphViewSettings settings = ConfigManager.instance().getDefaultFlowGraphSettings();
    settings.getProximitySettings().setProximityBrowsingActivationThreshold(50);
    cg.load();
    final ZyGraph g = CGraphBuilder.buildGraph(cg);
    g.getSettings().getLayoutSettings().setDefaultGraphLayout(LayoutStyle.HIERARCHIC);
    g.doLayout();
    g.getSettings().getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
    g.doLayout();
}
Also used : ICallgraphView(com.google.security.zynamics.binnavi.disassembly.ICallgraphView) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) Test(org.junit.Test)

Aggregations

ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)23 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)9 Test (org.junit.Test)9 CModuleContainer (com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer)5 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)4 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 ZyGraph2DView (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 MockDebuggerProvider (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider)2 CGraphWindow (com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow)2 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2 CCodeNodeUpdater (com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater)2