use of com.google.security.zynamics.binnavi.disassembly.COperandTreeNode 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.disassembly.COperandTreeNode in project binnavi by google.
the class OperandTest method testCreate.
@Test
public void testCreate() {
final Database database = new Database(new MockDatabase());
final MockModule mockModule = new MockModule();
final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
final COperandTreeNode rootNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_SIZE_PREFIX_ID, "b4", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
final COperandTreeNode childNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
COperandTreeNode.link(rootNode, childNode);
final OperandExpression root = new OperandExpression(rootNode);
final Operand operand = Operand.create(module, root);
assertEquals("dword", operand.getRootNode().getValue());
assertEquals(1, operand.getRootNode().getChildren().size());
assertEquals("eax", operand.getRootNode().getChildren().get(0).getValue());
assertEquals("eax", operand.toString());
}
Aggregations