use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment in project binnavi by google.
the class FunctionTest method testAppendFunctionComment.
@Test
public void testAppendFunctionComment() throws CouldntSaveDataException, com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException, CouldntLoadDataException {
final MockFunctionListener listener = new MockFunctionListener();
final Function function = new Function(ModuleFactory.get(), m_internalFunction2);
function.addListener(listener);
final CUserManager userManager = CUserManager.get(m_provider);
final IUser user = userManager.addUser(" SET FUNCTION COMMENT TEST ");
userManager.setCurrentActiveUser(user);
final List<IComment> appendedComments = function.appendComment("Hannes");
assertEquals(appendedComments, function.getComment());
assertEquals(appendedComments, m_internalFunction2.getGlobalComment());
assertEquals("appendedComment;", listener.events);
final ArrayList<IComment> comments = Lists.newArrayList();
comments.add(new CComment(12345, CommonTestObjects.TEST_USER_1, null, "FOO"));
m_internalFunction2.initializeGlobalComment(comments);
assertEquals(comments.get(0), function.getComment().get(0));
assertEquals(comments.get(0), m_internalFunction2.getGlobalComment().get(0));
assertEquals("appendedComment;initializedComments;", listener.events);
function.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment in project binnavi by google.
the class InstructionTest method testCommentInitialization.
@Test
public void testCommentInitialization() throws CouldntLoadDataException, LoadCancelledException {
final SQLProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
internalModule.load();
final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTree operand1 = new COperandTree(rootNode1, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final COperandTree operand2 = new COperandTree(rootNode2, provider, internalModule.getTypeManager(), internalModule.getContent().getTypeInstanceContainer());
final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
final CInstruction internalInstruction = new CInstruction(false, internalModule, new CAddress(0x123), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", provider);
final Instruction instruction = new Instruction(internalInstruction);
final MockInstructionListener listener = new MockInstructionListener();
instruction.addListener(listener);
final ArrayList<IComment> comment = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Hannes"));
instruction.initializeComment(comment);
assertEquals(comment, internalInstruction.getGlobalComment());
assertEquals(comment, instruction.getComment());
// TODO (timkornau): check if double messages are what we want here of rather not.
// assertEquals("InitializedComment;", listener.events);
instruction.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment in project binnavi by google.
the class ViewTest method testTextNode.
@Test
public void testTextNode() throws PartialLoadException, com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException {
final MockViewListener listener = new MockViewListener();
m_view.addListener(listener);
m_view.load();
final ArrayList<IComment> comment = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " COMMENT VIEW TEST "));
final TextNode textNode = m_view.createTextNode(comment);
assertEquals(textNode, m_view.getGraph().getNodes().get(0));
assertEquals(listener.events, "addedNode;");
assertEquals(com.google.security.zynamics.binnavi.API.disassembly.GraphType.MixedGraph, m_view.getGraphType());
assertEquals(" COMMENT VIEW TEST ", textNode.getComments().get(0).getComment());
m_view.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment in project binnavi by google.
the class ViewTest method testGraph.
@Test
public void testGraph() {
final List<INaviViewNode> nodes = new ArrayList<INaviViewNode>();
final List<INaviEdge> edges = new ArrayList<INaviEdge>();
final MutableDirectedGraph<INaviViewNode, INaviEdge> graph = new MutableDirectedGraph<INaviViewNode, INaviEdge>(nodes, edges);
final int viewId = new BigInteger(31, new SecureRandom()).intValue();
final INaviView internalView = new CView(viewId, internalModule, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, m_creationDate, m_modificationDate, graph, new HashSet<CTag>(), false, m_provider);
final INaviFunction internalFunction = internalModule.getContent().getFunctionContainer().getFunctions().get(0);
final CCodeNode codeNode = internalView.getContent().createCodeNode(internalFunction, Lists.newArrayList(new MockInstruction()));
final CFunctionNode functionNode = internalView.getContent().createFunctionNode(internalFunction);
@SuppressWarnings("unused") final CTextNode textNode = internalView.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Foo")));
@SuppressWarnings("unused") final CGroupNode groupNode = internalView.getContent().createGroupNode(internalView.getGraph().getNodes());
internalView.getContent().createEdge(codeNode, functionNode, com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType.JUMP_UNCONDITIONAL);
final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
final MockViewListener listener = new MockViewListener();
final View view = new View(module, internalView, tagManager, m_viewTagManager);
view.addListener(listener);
assertEquals(4, view.getGraph().getNodes().size());
assertEquals(1, view.getGraph().getEdges().size());
internalView.getContent().deleteNodes(internalView.getContent().getGraph().getNodes());
assertEquals("deletedEdge;deletedNode;deletedNode;deletedNode;", listener.events);
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment in project binnavi by google.
the class ViewTest method testCreateNode.
@Test
public void testCreateNode() throws PartialLoadException, com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException {
final MockViewListener listener = new MockViewListener();
final Function function = module.getFunctions().get(0);
final List<Instruction> instructions = Lists.newArrayList(new Instruction(new MockInstruction()));
m_view.load();
final CodeNode codeNode = m_view.createCodeNode(function, instructions);
final FunctionNode functionNode = m_view.createFunctionNode(function);
final ArrayList<IComment> comment = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " COMMENT VIEW TEST "));
final TextNode textNode = m_view.createTextNode(comment);
assertEquals(3, m_view.getNodeCount());
m_view.addListener(listener);
@SuppressWarnings("unused") final CodeNode clonedCodeNode = (CodeNode) m_view.createNode(codeNode);
@SuppressWarnings("unused") final FunctionNode clonedFunctionNode = (FunctionNode) m_view.createNode(functionNode);
@SuppressWarnings("unused") final TextNode clonedTextNode = (TextNode) m_view.createNode(textNode);
m_view.removeListener(listener);
}
Aggregations