Search in sources :

Example 1 with GraphSearcher

use of com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher in project binnavi by google.

the class GraphSearcherTest method testAfterLast.

@Test
public void testAfterLast() {
    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.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "");
    assertNull(searcher.getCursor().current());
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my");
    assertFalse(searcher.getCursor().isAfterLast());
    searcher.getCursor().next();
    assertTrue(searcher.getCursor().isAfterLast());
    searcher.getCursor().next();
    assertTrue(searcher.getCursor().isAfterLast());
}
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 2 with GraphSearcher

use of com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher in project binnavi by google.

the class GraphSearcherTest method testSimpleNoResult.

@Test
public void testSimpleNoResult() {
    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();
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "mx");
    searcher.getCursor().next();
    assertNull(searcher.getCursor().current());
}
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 3 with GraphSearcher

use of com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher 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 4 with GraphSearcher

use of com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher 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)

Example 5 with GraphSearcher

use of com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher in project binnavi by google.

the class GraphSearcherTest method testSimpleMultiple.

@Test
public void testSimpleMultiple() {
    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();
    m_content.addLineContent(new ZyLineContent("Hello my my Test", null));
    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());
}
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

GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)9 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)9 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)9 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)8 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)8 Test (org.junit.Test)8 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)1 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)1 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)1 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)1 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)1 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)1 ArrayList (java.util.ArrayList)1 Graph2D (y.view.Graph2D)1 HierarchyManager (y.view.hierarchy.HierarchyManager)1