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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations