use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstance in project binnavi by google.
the class PostgreSQLNotificationParserTest method testTypeInstanceCommentParsingAppendComment.
@Test
public void testTypeInstanceCommentParsingAppendComment() 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);
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_type_instances UPDATE 1 " + fakeInstance.getId() + " 3333");
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.APPEND, container.getOperation());
assertEquals(new Integer(3333), container.getCommentId());
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstance 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());
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstance in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method createTypeInstanceReference5.
@Test
public void createTypeInstanceReference5() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
module.load();
final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
final TypeInstanceAddress address1 = typeInstance.getAddress();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress("1001929", 16));
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
final INaviInstruction instruction = view.getBasicBlocks().get(1).getInstructions().iterator().next();
Assert.assertNotNull(typeInstance);
provider.createTypeInstanceReference(typeInstance.getModule().getConfiguration().getId(), instruction.getAddress().toLong(), instruction.getOperandPosition(instruction.getOperands().get(0)), instruction.getOperands().get(0).getNodes().get(0).getId(), typeInstance.getId());
view.close();
module.close();
module.load();
view.load();
final TypeInstance typeInstance2 = module.getContent().getTypeInstanceContainer().getTypeInstance(typeInstance.getAddress());
Assert.assertEquals(address1, typeInstance2.getAddress());
final List<TypeInstanceReference> references = module.getContent().getTypeInstanceContainer().getReferences(typeInstance2);
Assert.assertTrue(!references.isEmpty());
Assert.assertEquals(instruction.getAddress(), references.get(0).getAddress());
Assert.assertEquals(instruction.getOperandPosition(instruction.getOperands().get(0)), references.get(0).getPosition());
Assert.assertEquals(instruction.getOperands().get(0).getNodes().get(0).getId(), references.get(0).getTreeNode().get().getId());
Assert.assertEquals(typeInstance.getId(), references.get(0).getTypeInstance().getId());
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstance in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method deleteTypeInstanceTest3.
@Test
public void deleteTypeInstanceTest3() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException {
module.load();
final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstances().get(0);
provider.deleteTypeInstance(module.getConfiguration().getId(), typeInstance.getId());
module.close();
module.load();
Assert.assertFalse(module.getContent().getTypeInstanceContainer().getTypeInstances().contains(typeInstance));
}
use of com.google.security.zynamics.binnavi.disassembly.types.TypeInstance in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method createTypeInstance6.
@Test
public void createTypeInstance6() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final String typeInstanceName = " TYPE INSTANCE NAME ";
module.load();
final Section section = module.getContent().getSections().getSections().get(0);
final BaseType type = module.getTypeManager().getTypes().get(0);
final int typeInstanceId = provider.createTypeInstance(module.getConfiguration().getId(), typeInstanceName, null, type.getId(), section.getId(), 0);
module.close();
module.load();
final TypeInstance typeInstance = module.getContent().getTypeInstanceContainer().getTypeInstanceById(typeInstanceId);
Assert.assertEquals(typeInstanceId, typeInstance.getId());
Assert.assertEquals(typeInstanceName, typeInstance.getName());
Assert.assertEquals(module, typeInstance.getModule());
Assert.assertEquals(section.getId(), typeInstance.getSection().getId());
}
Aggregations