Search in sources :

Example 51 with NaviNode

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

the class ZyGraphTest method testNode.

@Test
public void testNode() {
    final List<NaviNode> nodes = GraphHelpers.getNodes(m_graph);
    final NaviNode cnn = nodes.get(0);
    final CCodeNode codeNode = (CCodeNode) cnn.getRawNode();
    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 : CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Test(org.junit.Test)

Example 52 with NaviNode

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

the class ZyGraphTest method testVisibility.

@Test
public void testVisibility() {
    assertEquals(7, m_graph.visibleNodeCount());
    assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
    assertEquals(96, m_graph.getRawView().getNodeCount());
    int visibilityCounter = 0;
    int totalCounter = 0;
    for (final NaviNode node : GraphHelpers.getNodes(m_graph)) {
        assertEquals(node.isVisible(), node.getRawNode().isVisible());
        if (node.isVisible()) {
            visibilityCounter++;
        }
        totalCounter++;
    }
    assertEquals(7, visibilityCounter);
    assertEquals(96, totalCounter);
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) Test(org.junit.Test)

Example 53 with NaviNode

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

the class ZyGraphTest method testAddedTextNode.

@Test
public void testAddedTextNode() {
    assertEquals(7, m_graph.visibleNodeCount());
    assertEquals(89, NodeFunctions.getInvisibleNodes(m_graph).size());
    assertEquals(96, m_graph.getRawView().getNodeCount());
    final CTextNode textNode = m_graph.getRawView().getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Hannes")));
    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, textNode);
    assertTrue(textNode.isVisible());
    assertEquals(textNode.isVisible(), cnn.isVisible());
    textNode.setVisible(false);
    assertFalse(textNode.isVisible());
    assertEquals(textNode.isVisible(), cnn.isVisible());
    textNode.setVisible(true);
    assertTrue(textNode.isVisible());
    assertEquals(textNode.isVisible(), cnn.isVisible());
    assertFalse(textNode.isSelected());
    assertEquals(textNode.isSelected(), cnn.isSelected());
    textNode.setSelected(false);
    assertFalse(textNode.isSelected());
    assertEquals(textNode.isSelected(), cnn.isSelected());
    textNode.setSelected(true);
    assertTrue(textNode.isSelected());
    assertEquals(textNode.isSelected(), cnn.isSelected());
    assertEquals(textNode.getColor(), cnn.getRealizer().getFillColor());
    textNode.setColor(Color.GREEN);
    assertEquals(Color.GREEN, textNode.getColor());
    assertEquals(textNode.getColor(), cnn.getRealizer().getFillColor());
    textNode.setX(100);
    assertEquals(100, textNode.getX(), 0.1);
    assertEquals(textNode.getX(), cnn.getX(), 0.1);
    textNode.setY(200);
    assertEquals(200, textNode.getY(), 0.1);
    assertEquals(textNode.getY(), cnn.getY(), 0.1);
}
Also used : CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) Test(org.junit.Test)

Example 54 with NaviNode

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

the class GraphSearcherTest method testSearchSelected.

@Test
public void testSearchSelected() {
    final ZyNodeRealizer<NaviNode> r = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final NaviNode m_node1 = new NaviNode(m_ynode, r, m_codeNode1);
    final GraphSearcher searcher = new GraphSearcher();
    searcher.getSettings().setOnlySelected(true);
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my");
    assertNull(searcher.getCursor().current());
    m_node1.getRawNode().setSelected(true);
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my");
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    // TEST: Do not move beyond the last result
    searcher.getCursor().next();
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
}
Also used : ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) GraphSearcher(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Test(org.junit.Test)

Example 55 with NaviNode

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

the class GraphSearcherTest method testSearchRegex.

@Test
public void testSearchRegex() {
    final ZyNodeRealizer<NaviNode> r = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final NaviNode m_node1 = new NaviNode(m_ynode, r, m_codeNode1);
    final GraphSearcher searcher = new GraphSearcher();
    searcher.getSettings().setRegEx(true);
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my[^s]*");
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(5, searcher.getCursor().current().getLength());
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my.*");
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(7, searcher.getCursor().current().getLength());
    searcher.getSettings().setCaseSensitive(true);
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my[^t]*");
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(6, searcher.getCursor().current().getLength());
}
Also used : ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) GraphSearcher(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) 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