Search in sources :

Example 1 with CCachedTextCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium in project binnavi by google.

the class CCriteriumCacheTest method testSameTree.

@Test
public void testSameTree() {
    final CCachedExpressionTree cachedTree = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree2 = new CCachedExpressionTree();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(new CCachedTextCriterium("foo", false, false));
    CCachedExpressionTreeNode.append(cachedTree.getRoot(), node);
    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(1, criteriumCache.getTrees().size());
}
Also used : CCachedExpressionTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTree) CCachedTextCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium) 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 2 with CCachedTextCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium in project binnavi by google.

the class CCriteriumCacheTest method testMoreThenEnoughTrees.

@Test
public void testMoreThenEnoughTrees() {
    final CCachedExpressionTree cachedTree = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree2 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree3 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree4 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree5 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree6 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree7 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree8 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree9 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree10 = new CCachedExpressionTree();
    final CCachedExpressionTree cachedTree11 = new CCachedExpressionTree();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(new CCachedTextCriterium("1", false, false));
    CCachedExpressionTreeNode.append(cachedTree.getRoot(), node);
    final CCachedExpressionTreeNode node2 = new CCachedExpressionTreeNode(new CCachedTextCriterium("2", false, false));
    CCachedExpressionTreeNode.append(cachedTree2.getRoot(), node2);
    final CCachedExpressionTreeNode node3 = new CCachedExpressionTreeNode(new CCachedTextCriterium("3", false, false));
    CCachedExpressionTreeNode.append(cachedTree3.getRoot(), node3);
    final CCachedExpressionTreeNode node4 = new CCachedExpressionTreeNode(new CCachedTextCriterium("4", false, false));
    CCachedExpressionTreeNode.append(cachedTree4.getRoot(), node4);
    final CCachedExpressionTreeNode node5 = new CCachedExpressionTreeNode(new CCachedTextCriterium("5", false, false));
    CCachedExpressionTreeNode.append(cachedTree5.getRoot(), node5);
    final CCachedExpressionTreeNode node6 = new CCachedExpressionTreeNode(new CCachedTextCriterium("6", false, false));
    CCachedExpressionTreeNode.append(cachedTree6.getRoot(), node6);
    final CCachedExpressionTreeNode node7 = new CCachedExpressionTreeNode(new CCachedTextCriterium("7", false, false));
    CCachedExpressionTreeNode.append(cachedTree7.getRoot(), node7);
    final CCachedExpressionTreeNode node8 = new CCachedExpressionTreeNode(new CCachedTextCriterium("8", false, false));
    CCachedExpressionTreeNode.append(cachedTree8.getRoot(), node8);
    final CCachedExpressionTreeNode node9 = new CCachedExpressionTreeNode(new CCachedTextCriterium("9", false, false));
    CCachedExpressionTreeNode.append(cachedTree9.getRoot(), node9);
    final CCachedExpressionTreeNode node10 = new CCachedExpressionTreeNode(new CCachedTextCriterium("10", false, false));
    CCachedExpressionTreeNode.append(cachedTree10.getRoot(), node10);
    final CCachedExpressionTreeNode node11 = new CCachedExpressionTreeNode(new CCachedTextCriterium("11", false, false));
    CCachedExpressionTreeNode.append(cachedTree11.getRoot(), node11);
    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());
    criteriumCache.add(cachedTree3);
    assertEquals(3, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree4);
    assertEquals(4, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree5);
    assertEquals(5, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree6);
    assertEquals(6, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree7);
    assertEquals(7, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree8);
    assertEquals(8, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree9);
    assertEquals(9, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree10);
    assertEquals(10, criteriumCache.getTrees().size());
    criteriumCache.add(cachedTree11);
    assertEquals(10, criteriumCache.getTrees().size());
}
Also used : CCachedExpressionTree(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTree) CCachedTextCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium) 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 3 with CCachedTextCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium 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 4 with CCachedTextCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium in project binnavi by google.

the class CCriteriumExecuterTest method testInvalidNotCriterion.

@Test(expected = IllegalStateException.class)
public void testInvalidNotCriterion() {
    final CCachedNotCriterium criterium = new CCachedNotCriterium();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    final CCachedTextCriterium criterium2 = new CCachedTextCriterium("nop", false, false);
    final CCachedExpressionTreeNode node2 = new CCachedExpressionTreeNode(criterium2);
    CCachedExpressionTreeNode.append(node, node2);
    final CCachedColorCriterium criterium3 = new CCachedColorCriterium(Color.BLUE);
    final CCachedExpressionTreeNode node3 = new CCachedExpressionTreeNode(criterium3);
    CCachedExpressionTreeNode.append(node, node3);
    CCriteriumExecuter.execute(m_tree, m_graph);
}
Also used : 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) CCachedNotCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Not.CCachedNotCriterium) Test(org.junit.Test)

Example 5 with CCachedTextCriterium

use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium in project binnavi by google.

the class CCriteriumExecuterTest method testValidNotCriterion.

/**
   * This test makes sure that NOT criteria are correctly evaluated (FALSE case).
   */
@Test
public void testValidNotCriterion() {
    final CCachedNotCriterium criterium = new CCachedNotCriterium();
    final CCachedExpressionTreeNode node = new CCachedExpressionTreeNode(criterium);
    CCachedExpressionTreeNode.append(m_tree.getRoot(), node);
    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(2, m_graph.getSelectedNodes().size());
}
Also used : CCachedTextCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Text.CCachedTextCriterium) CCachedExpressionTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCachedExpressionTreeNode) CCachedNotCriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.Not.CCachedNotCriterium) Test(org.junit.Test)

Aggregations

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