use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testLocalCodeNodeCommentParsingDelete.
@Test
public void testLocalCodeNodeCommentParsingDelete() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_code_nodes UPDATE 1 1111 4608 null");
final CommentNotification result = PostgreSQLCommentNotificationParser.processNodeLocalNodeCommentNotification(notification, provider);
assertNotNull(result);
final CodeNodeCommentNotificationContainer container = (CodeNodeCommentNotificationContainer) result;
final INaviCodeNode node = container.getNode();
assertEquals(1111, node.getId());
assertEquals(new CAddress(4608), node.getAddress());
assertEquals(CommentOperation.DELETE, container.getOperation());
assertNull(container.getCommentId());
assertEquals(CommentScope.LOCAL, container.getScope());
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class TraceTest method testEvent.
@Test
public void testEvent() {
final Trace trace = new Trace(new TraceList(1, "Name", "Description", new MockSqlProvider()));
final MockTraceListener listener = new MockTraceListener();
trace.addListener(listener);
final MockModule module = new MockModule();
final Module m = ModuleFactory.get(module);
trace.addEvent(0, m, new Address(123), TraceEventType.Breakpoint);
trace.addEvent(0, m, new Address(124), TraceEventType.EchoBreakpoint);
assertEquals(2, trace.getEvents().size());
assertEquals(123, trace.getEvents().get(0).getAddress().toLong());
assertEquals(TraceEventType.Breakpoint, trace.getEvents().get(0).getType());
assertEquals(124, trace.getEvents().get(1).getAddress().toLong());
assertEquals(TraceEventType.EchoBreakpoint, trace.getEvents().get(1).getType());
assertEquals("addedEvent;addedEvent;", listener.events);
trace.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class OperandTest method testConstructor.
@Test
public void testConstructor() {
final MockModule mockModule = new MockModule();
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 COperandTree tree = new COperandTree(rootNode, new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
final Operand operand = new Operand(tree);
assertEquals("dword", operand.getRootNode().getValue());
assertEquals(1, operand.getRootNode().getChildren().size());
assertEquals("eax", operand.getRootNode().getChildren().get(0).getValue());
assertEquals("eax", operand.toString());
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class ProjectTest method testCreateAddressSpace.
@Test
public void testCreateAddressSpace() throws CouldntLoadDataException, CouldntSaveDataException {
final MockProjectListener listener = new MockProjectListener();
m_project.load();
m_project.addListener(listener);
final AddressSpace space = m_project.createAddressSpace("Hannes Space");
space.load();
final INaviModule nativeModule = new MockModule(provider);
internalDatabase.getContent().addModule(nativeModule);
final Module module = ModuleFactory.get(nativeModule, provider);
module.load();
space.addModule(module);
assertEquals(space, m_project.getAddressSpaces().get(1));
assertEquals("Hannes Space", m_internalProject.getContent().getAddressSpaces().get(1).getConfiguration().getName());
assertEquals("addedAddressSpace;changedModificationDate;", listener.events);
assertEquals(0, m_project.getFunctions().size());
m_project.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testTypeInstanceCommentParsingDeleteComment.
@Test
public void testTypeInstanceCommentParsingDeleteComment() throws CouldntSaveDataException, CouldntLoadDataException {
final INaviModule module = new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
module.getContent().getSections().createSection("A", new CAddress(0), new CAddress(1234), SectionPermission.READ, null);
final TypeInstance fakeInstance = module.getContent().getTypeInstanceContainer().createInstance("TYPE INSTANCE", null, module.getTypeManager().getTypes().get(0), module.getContent().getSections().getSection(0), 0);
final PGNotification notification = new MockPGNotification("comment_changes", "bn_type_instances UPDATE 1 " + fakeInstance.getId() + " null");
final CommentNotification result = PostgreSQLCommentNotificationParser.processTypeInstanceCommentNotification(notification, provider);
assertNotNull(result);
final TypeInstanceCommentNotificationContainer container = (TypeInstanceCommentNotificationContainer) result;
assertNotNull(container);
final TypeInstance instance = container.getInstance();
assertEquals(fakeInstance.getId(), instance.getId());
assertEquals(CommentOperation.DELETE, container.getOperation());
assertNull(container.getCommentId());
}
Aggregations