Search in sources :

Example 46 with NaviNode

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

the class ZyGraphNodeBuilder method convertNode.

/**
   * Creates a graph node from a raw node.
   * 
   * @param node The raw node that provides the underlying data.
   * @param graph2D The graph object where the node is created.
   * @param graphSettings Graph settings used to build the graph.
   * 
   * @return The created YNode/NaviNode pair.
   */
public static Pair<Node, NaviNode> convertNode(final INaviViewNode node, final Graph2D graph2D, final ZyGraphViewSettings graphSettings) {
    Preconditions.checkNotNull(node, "IE00909: Node argument can not be null");
    Preconditions.checkNotNull(graph2D, "IE00910: Graph2D argument can not be null");
    // Create the node in the Graph2D
    final Node yNode = createNode(graph2D, node);
    final ZyLabelContent content = ZyGraphNodeBuilder.buildContent(node, graphSettings, null);
    final IZyNodeRealizer realizer = createRealizer(node, content);
    // Associate the user data with the Graph2D node
    final NaviNode zyNode = new NaviNode(yNode, realizer, node);
    realizer.setUserData(new ZyNodeData<NaviNode>(zyNode));
    realizer.updateContentSelectionColor();
    graph2D.setRealizer(yNode, realizer.getRealizer());
    return new Pair<Node, NaviNode>(yNode, zyNode);
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) Node(y.base.Node) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 47 with NaviNode

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

the class CIndegreeEvaluatorTest method testComplete.

@Test
public void testComplete() {
    final NaviNode node = CNaviNodeFactory.get();
    assertTrue(CIndegreeEvaluator.matches(node, "=", 0));
    assertFalse(CIndegreeEvaluator.matches(node, "=", 1));
    assertFalse(CIndegreeEvaluator.matches(node, "<", 0));
    assertFalse(CIndegreeEvaluator.matches(node, ">", 0));
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Test(org.junit.Test)

Example 48 with NaviNode

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

the class CColorEvaluatorTest method testComplete.

@Test
public void testComplete() {
    final NaviNode node = CNaviNodeFactory.get();
    assertTrue(CColorEvaluator.evaluate(node, Color.red));
    assertFalse(CColorEvaluator.evaluate(node, Color.green));
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Test(org.junit.Test)

Example 49 with NaviNode

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

the class CCriteriumExecuterTest method testSingleTagCriterion.

@Test
public void testSingleTagCriterion() {
    final Set<CTag> tags = new HashSet<CTag>();
    for (final NaviNode node : m_graph.getNodes()) {
        if (node.getRawNode().isTagged()) {
            tags.addAll(node.getRawNode().getTags());
        }
    }
    assertEquals(1, tags.size());
    final CCachedTagCriterium criterium = new CCachedTagCriterium(false, Iterables.getOnlyElement(tags));
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    assertEquals(0, m_graph.getSelectedNodes().size());
    CCriteriumExecuter.execute(m_tree, m_graph);
    assertEquals(1, m_graph.getSelectedNodes().size());
}
Also used : CCachedTagCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CCachedTagCriterium) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 50 with NaviNode

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

the class ZyGraphTest method testAddedCodeNode.

@Test
public void testAddedCodeNode() {
    assertEquals(7, m_graph.visibleNodeCount());
    assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
    assertEquals(96, m_graph.getRawView().getNodeCount());
    final MockFunction function = new MockFunction(m_provider);
    final List<INaviInstruction> instructions = Lists.newArrayList((INaviInstruction) new MockInstruction(new CAddress(0x123456), "mov", new ArrayList<COperandTree>(), null, m_module));
    final CCodeNode codeNode = m_graph.getRawView().getContent().createCodeNode(function, instructions);
    assertEquals(8, m_graph.visibleNodeCount());
    assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
    assertEquals(97, m_graph.getRawView().getNodeCount());
    final List<NaviNode> nodes = GraphHelpers.getNodes(m_graph);
    final NaviNode cnn = searchNode(nodes, codeNode);
    assertEquals(codeNode, cnn.getRawNode());
    assertTrue(codeNode.isVisible());
    assertEquals(codeNode.isVisible(), cnn.isVisible());
    codeNode.setVisible(false);
    assertFalse(codeNode.isVisible());
    assertEquals(codeNode.isVisible(), cnn.isVisible());
    codeNode.setVisible(true);
    assertTrue(codeNode.isVisible());
    assertEquals(codeNode.isVisible(), cnn.isVisible());
    assertFalse(codeNode.isSelected());
    assertEquals(codeNode.isSelected(), cnn.isSelected());
    codeNode.setSelected(false);
    assertFalse(codeNode.isSelected());
    assertEquals(codeNode.isSelected(), cnn.isSelected());
    codeNode.setSelected(true);
    assertTrue(codeNode.isSelected());
    assertEquals(codeNode.isSelected(), cnn.isSelected());
    assertEquals(codeNode.getColor(), cnn.getRealizer().getFillColor());
    codeNode.setColor(Color.GREEN);
    assertEquals(Color.GREEN, codeNode.getColor());
    assertEquals(codeNode.getColor(), cnn.getRealizer().getFillColor());
    codeNode.setX(100);
    assertEquals(100, codeNode.getX(), 0.1);
    assertEquals(codeNode.getX(), cnn.getX(), 0.1);
    codeNode.setY(200);
    assertEquals(200, codeNode.getY(), 0.1);
    assertEquals(codeNode.getY(), cnn.getY(), 0.1);
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockInstruction(com.google.security.zynamics.binnavi.disassembly.MockInstruction) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Aggregations

NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)60 Test (org.junit.Test)29 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)19 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)11 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)9 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)9 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)8 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)7 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)6 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)6 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)6 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)5 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)5 ArrayList (java.util.ArrayList)5 Node (y.base.Node)5 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)4 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)4 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 Edge (y.base.Edge)4