Search in sources :

Example 1 with CCachedAndCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium in project binnavi by google.

the class CCriteriumExecuterTest method testMatchingAndCriterion.

/**
   * This test makes sure that AND criteria are correctly evaluated (TRUE case).
   */
@Test
public void testMatchingAndCriterion() {
    final CCachedAndCriterium criterium = new CCachedAndCriterium();
    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("nop", 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(1, m_graph.getSelectedNodes().size());
}
Also used : CCachedAndCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium) CCachedTextCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium) 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 2 with CCachedAndCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium in project binnavi by google.

the class CCriteriumExecuterTest method testValidAndCriterion.

/**
   * This test makes sure that AND criteria are correctly evaluated (FALSE case).
   */
@Test
public void testValidAndCriterion() {
    final CCachedAndCriterium criterium = new CCachedAndCriterium();
    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 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 : CCachedAndCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium) 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 3 with CCachedAndCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium in project binnavi by google.

the class CCriteriumExecuterTest method testInvalidAndCriterion1.

/**
   * This test makes sure that criteria trees with AND expressions with fewer than two children can
   * not be evaluated..
   */
@Test(expected = IllegalStateException.class)
public void testInvalidAndCriterion1() {
    final CCachedAndCriterium criterium = new CCachedAndCriterium();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    CCriteriumExecuter.execute(m_tree, m_graph);
}
Also used : CCachedAndCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) Test(org.junit.Test)

Example 4 with CCachedAndCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium in project binnavi by google.

the class CCriteriumCacheTest method testAdd.

@Test
public void testAdd() {
    final CCachedExpressionTree cachedTree = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree2 = new CCachedExpressionTree();
    final CCachedAndCriterium criterium = new CCachedAndCriterium();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(cachedTree.getRoot(), node);
    final CCachedExpressionTreeNode node_a = new CCachedExpressionTreeNode(new CCachedColorCriterium(Color.red));
    CCachedExpressionTreeNode.append(node, node_a);
    final CCachedExpressionTreeNode node_b = new CCachedExpressionTreeNode(new CCachedColorCriterium(Color.blue));
    CCachedExpressionTreeNode.append(node, node_b);
    final CCachedExpressionTreeNode node2 = new CCachedExpressionTreeNode(new CCachedTextCriterium("foo", false, false));
    CCachedExpressionTreeNode.append(cachedTree2.getRoot(), node2);
    final CCriteriumCache criteriumCache = new CCriteriumCache();
    criteriumCache.addListener(m_listener);
    assertEquals(0, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree);
    assertEquals(1, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree2);
    assertEquals(2, criteriumCache.getTrees().size());
}
Also used : CCachedAndCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium) CCachedExpressionTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTree) CCachedTextCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium) CCachedColorCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CCachedColorCriterium) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) CCriteriumCache(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Cache.CCriteriumCache) Test(org.junit.Test)

Example 5 with CCachedAndCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium in project binnavi by google.

the class CCriteriumExecuterTest method testInvalidAndCriterion2.

@Test(expected = IllegalStateException.class)
public void testInvalidAndCriterion2() {
    final CCachedAndCriterium criterium = new CCachedAndCriterium();
    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);
    CCriteriumExecuter.execute(m_tree, m_graph);
}
Also used : CCachedAndCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium) 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)

Aggregations

CCachedAndCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.And.CCachedAndCriterium)5 CCachedExpressionTreeNode (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode)5 Test (org.junit.Test)5 CCachedColorCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.NodeColor.CCachedColorCriterium)4 CCachedTextCriterium (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium)2 CCriteriumCache (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Cache.CCriteriumCache)1 CCachedExpressionTree (com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTree)1