use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory in project binnavi by google.
the class JCriteriumTreeModelTest method testRemoveNode.
@Test
public void testRemoveNode() {
final JTree tree = new JTree();
final CCriteriumTree cCriteriumTree = new CCriteriumTree();
final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
final JCriteriumTreeModel jCriterumTreeModel = new JCriteriumTreeModel(tree, cCriteriumTree, cCriteriaFactory.getConditions());
final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
final CCriteriumTreeNode child2 = new CCriteriumTreeNode(new CAndCriterium());
cCriteriumTree.insertNode(cCriteriumTree.getRoot(), child2);
final CCriteriumTreeNode child3 = new CCriteriumTreeNode(new CColorCriterium(m_graph));
cCriteriumTree.appendNode(child2, child3);
cCriteriumTree.remove(child);
assertEquals(1, ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildCount());
assertEquals(1, ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getChildCount());
assertEquals(child2.getCriterium(), ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getCriterium());
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory in project binnavi by google.
the class JCriteriumTreeModelTest method testAppendNode.
@Test
public void testAppendNode() {
final JTree tree = new JTree();
final CCriteriumTree cCriteriumTree = new CCriteriumTree();
final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
final JCriteriumTreeModel jCriterumTreeModel = new JCriteriumTreeModel(tree, cCriteriumTree, cCriteriaFactory.getConditions());
final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
assertEquals(1, ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildCount());
assertEquals(child.getCriterium(), ((JCriteriumTreeNode) ((JCriteriumTreeNode) jCriterumTreeModel.getRoot()).getChildAt(0)).getCriterium());
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory in project binnavi by google.
the class CCriteriumFunctionsTest method findNode.
@Test
public void findNode() {
final CCriteriumTree cCriteriumTree = new CCriteriumTree();
final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
final List<ICriteriumCreator> criteria = cCriteriaFactory.getConditions();
final CConditionBox box = new CConditionBox(criteria);
final JCriteriumTree jtree = new JCriteriumTree(cCriteriumTree, criteria);
final CColorCriterium colorado = new CColorCriterium(m_graph);
final CCriteriumTreeNode child = new CCriteriumTreeNode(colorado);
cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
final TreePath path = new TreePath(((JCriteriumTreeNode) jtree.getModel().getRoot()).getFirstChild());
jtree.setSelectionPath(path);
box.setSelectedIndex(6);
CCriteriumFunctions.appendCriterium(jtree, cCriteriumTree, box);
assertEquals(null, CCriteriumFunctions.findNode(cCriteriumTree.getRoot(), new CTextCriterium()));
assertEquals(child, CCriteriumFunctions.findNode(cCriteriumTree.getRoot(), colorado));
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory in project binnavi by google.
the class CCriteriumFunctionsTest method testAppendTwoNoPath.
@Test
public void testAppendTwoNoPath() {
final CCriteriumTree cCriteriumTree = new CCriteriumTree();
final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
final List<ICriteriumCreator> criteria = cCriteriaFactory.getConditions();
final CConditionBox box = new CConditionBox(criteria);
final JCriteriumTree jtree = new JCriteriumTree(cCriteriumTree, criteria);
final CCriteriumTreeNode child = new CCriteriumTreeNode(new CColorCriterium(m_graph));
cCriteriumTree.appendNode(cCriteriumTree.getRoot(), child);
final TreePath path = new TreePath(((JCriteriumTreeNode) jtree.getModel().getRoot()).getFirstChild());
jtree.setSelectionPath(path);
box.setSelectedIndex(6);
CCriteriumFunctions.appendCriterium(jtree, cCriteriumTree, box);
assertTrue(cCriteriumTree.getRoot().getChildren().get(0).getChildren().get(0).getCriterium() instanceof CSelectionCriterium);
assertFalse(cCriteriumTree.getRoot().getChildren().get(0).getChildren().get(0).getCriterium() instanceof CTagCriterium);
}
use of com.google.security.zynamics.binnavi.Gui.CriteriaDialog.CCriteriaFactory in project binnavi by google.
the class JCriteriumTreeModelTest method testEmpty.
@Test
public void testEmpty() {
final JTree tree = new JTree();
final CCriteriumTree cCriteriumTree = new CCriteriumTree();
final CCriteriaFactory cCriteriaFactory = new CCriteriaFactory(m_graph, null, null);
@SuppressWarnings("unused") final JCriteriumTreeModel jCriterumTreeModel = new JCriteriumTreeModel(tree, cCriteriumTree, cCriteriaFactory.getConditions());
}
Aggregations