Search in sources :

Example 16 with CCachedExpressionTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode in project binnavi by google.

the class CCriteriumExecuterTest method testMatchingOrCriterion.

/**
   * This test makes sure that OR criteria are correctly evaluated (TRUE case).
   */
@Test
public void testMatchingOrCriterion() {
    final CCachedOrCriterium criterium = new CCachedOrCriterium();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    final CCachedColorCriterium criterium3 = new CCachedColorCriterium(Color.RED);
    final CCachedExpressionTreeNode node3 = new CCachedExpressionTreeNode(criterium3);
    CCachedExpressionTreeNode.append(node, node3);
    final CCachedTextCriterium criterium2 = new CCachedTextCriterium("mov", false, false);
    final CCachedExpressionTreeNode node2 = new CCachedExpressionTreeNode(criterium2);
    CCachedExpressionTreeNode.append(node, node2);
    assertEquals(0, m_graph.getSelectedNodes().size());
    CCriteriumExecuter.execute(m_tree, m_graph);
    assertEquals(2, m_graph.getSelectedNodes().size());
}
Also used : CCachedTextCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium) CCachedOrCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Or.CCachedOrCriterium) CCachedColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CCachedColorCriterium) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) Test(org.junit.Test)

Example 17 with CCachedExpressionTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode in project binnavi by google.

the class CCriteriumExecuterTest method testValidOrCriterion.

/**
   * This test makes sure that OR criteria are correctly evaluated (FALSE case).
   */
@Test
public void testValidOrCriterion() {
    final CCachedOrCriterium criterium = new CCachedOrCriterium();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    final CCachedColorCriterium criterium3 = new CCachedColorCriterium(Color.GREEN);
    final CCachedExpressionTreeNode node3 = new CCachedExpressionTreeNode(criterium3);
    CCachedExpressionTreeNode.append(node, node3);
    final CCachedColorCriterium criterium2 = new CCachedColorCriterium(Color.BLUE);
    final CCachedExpressionTreeNode node2 = new CCachedExpressionTreeNode(criterium2);
    CCachedExpressionTreeNode.append(node, node2);
    assertEquals(0, m_graph.getSelectedNodes().size());
    CCriteriumExecuter.execute(m_tree, m_graph);
    assertEquals(0, m_graph.getSelectedNodes().size());
}
Also used : CCachedOrCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Or.CCachedOrCriterium) CCachedColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CCachedColorCriterium) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) Test(org.junit.Test)

Example 18 with CCachedExpressionTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode in project binnavi by google.

the class CCriteriumExecuterTest method testSingleSelectionCriterionUnselected.

@Test
public void testSingleSelectionCriterionUnselected() {
    assertEquals(0, m_graph.getSelectedNodes().size());
    m_graph.getRawView().getGraph().getNodes().get(1).setSelected(true);
    assertEquals(1, m_graph.getSelectedNodes().size());
    final CCachedSelectionCriterium criterium = new CCachedSelectionCriterium(SelectionState.UNSELECTED);
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    assertEquals(1, m_graph.getSelectedNodes().size());
    CCriteriumExecuter.execute(m_tree, m_graph);
    assertEquals(m_graph.getNodes().size() - 1, m_graph.getSelectedNodes().size());
    assertFalse(m_graph.getRawView().getGraph().getNodes().get(1).isSelected());
}
Also used : CCachedSelectionCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CCachedSelectionCriterium) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) Test(org.junit.Test)

Example 19 with CCachedExpressionTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode in project binnavi by google.

the class CCriteriumExecuterTest method testSingleSelectionCriterionSelected.

/**
   * This test checks if a node that is selected also is selected after criterium executer has been
   * run.
   */
@Test
public void testSingleSelectionCriterionSelected() {
    assertEquals(0, m_graph.getSelectedNodes().size());
    m_graph.getRawView().getGraph().getNodes().get(1).setSelected(true);
    assertEquals(1, m_graph.getSelectedNodes().size());
    final CCachedSelectionCriterium criterium = new CCachedSelectionCriterium(SelectionState.SELECTED);
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    assertEquals(1, m_graph.getSelectedNodes().size());
    CCriteriumExecuter.execute(m_tree, m_graph);
    assertEquals(1, m_graph.getSelectedNodes().size());
    assertTrue(m_graph.getRawView().getGraph().getNodes().get(1).isSelected());
}
Also used : CCachedSelectionCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CCachedSelectionCriterium) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) Test(org.junit.Test)

Example 20 with CCachedExpressionTreeNode

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode in project binnavi by google.

the class CCriteriumExecuterTest method testSingleOutDegreeCriterion.

@Test
public void testSingleOutDegreeCriterion() {
    final CCachedOutdegreeCriterium criterium = new CCachedOutdegreeCriterium("=", 1);
    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(2, m_graph.getSelectedNodes().size());
}
Also used : CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) CCachedOutdegreeCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.OutDegree.CCachedOutdegreeCriterium) Test(org.junit.Test)

Aggregations

CCachedExpressionTreeNode (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode)25 Test (org.junit.Test)25 CCachedColorCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CCachedColorCriterium)11 CCachedTextCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium)9 CCachedAndCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium)5 CCriteriumCache (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Cache.CCriteriumCache)4 CCachedOrCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Or.CCachedOrCriterium)4 CCachedExpressionTree (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTree)4 CCachedNotCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Not.CCachedNotCriterium)3 CCachedSelectionCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Selection.CCachedSelectionCriterium)2 CCachedVisibilityCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Visibillity.CCachedVisibilityCriterium)2 CCachedIndegreeCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.InDegrees.CCachedIndegreeCriterium)1 CCachedOutdegreeCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.OutDegree.CCachedOutdegreeCriterium)1 CCachedTagCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Tag.CCachedTagCriterium)1 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)1 HashSet (java.util.HashSet)1