use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeInstanceContainerBackendTest method deleteInstanceReferenceTest2.
@Test
public void deleteInstanceReferenceTest2() throws CouldntSaveDataException, CouldntDeleteException {
final MockOperandTreeNode treeNode = new MockOperandTreeNode();
final CAddress address = new CAddress(0x1234);
final int position = 1;
final TypeInstanceReference typeInstanceReference = typeInstancContainerBackend.createTypeInstanceReference(address, position, treeNode, typeInstance, view);
typeInstancContainerBackend.deleteInstanceReference(typeInstanceReference);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeInstanceContainerTests method deleteReferenceTest2.
@Test
public void deleteReferenceTest2() throws CouldntLoadDataException, CouldntSaveDataException, CouldntDeleteException {
final int numberOfTypeInstances = typeInstanceContainer.getTypeInstances().size();
final TypeInstance typeInstance = typeInstanceContainer.createInstance("TYPEINSTANCE", null, baseType, section, 0);
Assert.assertEquals(numberOfTypeInstances + 1, typeInstanceContainer.getTypeInstances().size());
Assert.assertTrue(typeInstanceContainer.getTypeInstances().contains(typeInstance));
Assert.assertEquals(typeInstance, typeInstanceContainer.getTypeInstance(typeInstance.getAddress()));
Assert.assertEquals(0, typeInstanceContainer.getReferences(typeInstance).size());
final TypeInstanceReference typeInstanceReference = typeInstanceContainer.createReference(new CAddress("41000", 16), 0, new MockOperandTreeNode(), typeInstance, view);
Assert.assertEquals(1, typeInstanceContainer.getReferences(typeInstance).size());
Assert.assertTrue(typeInstanceContainer.getReferences(typeInstance).contains(typeInstanceReference));
typeInstanceContainer.deleteReference(typeInstanceReference);
Assert.assertEquals(Lists.newArrayList(), typeInstanceContainer.getReferences(typeInstance));
expectedEvents.addedTypeInstance(typeInstance);
expectedEvents.addedTypeInstanceReference(typeInstanceReference);
expectedEvents.removedTypeInstanceReference(typeInstanceReference);
Assert.assertEquals(expectedEvents, listener);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeInstanceContainerTests method updateTypeReferenceTest.
@Test
public void updateTypeReferenceTest() throws CouldntSaveDataException, CouldntLoadDataException {
final TypeInstance typeInstance = typeInstanceContainer.createInstance("TYPEINSTANCE", null, baseType, section, 0);
expectedEvents.addedTypeInstance(typeInstance);
final TypeInstanceReference typeInstanceReference = typeInstanceContainer.createReference(new CAddress("41000", 16), 0, new MockOperandTreeNode(), typeInstance, view);
expectedEvents.addedTypeInstanceReference(typeInstanceReference);
typeInstanceContainer.deactivateTypeInstanceReference(typeInstanceReference);
expectedEvents.changedTypeInstanceReference(typeInstanceReference);
Assert.assertEquals(expectedEvents, listener);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeManagerDatabaseBackendTests method testDeleteTypeSubstitution.
@Test
public void testDeleteTypeSubstitution() throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException {
final MockOperandTreeNode node = new MockOperandTreeNode();
final BaseType baseType = backend.createType("test_type", 32, true, null, BaseTypeCategory.ATOMIC);
final CAddress address = new CAddress(0x1000);
final int position = 0;
final TypeSubstitution substitution = backend.createTypeSubstitution(node, baseType, new ArrayList<Integer>(), position, 32, address);
RawTypeSubstitution rawSubstitution = mockProvider.loadTypeSubstitution(mockModule, address.toBigInteger(), position, node.getId());
Assert.assertNotNull(rawSubstitution);
backend.deleteTypeSubstitution(substitution);
rawSubstitution = mockProvider.loadTypeSubstitution(mockModule, address.toBigInteger(), position, node.getId());
Assert.assertNull(rawSubstitution);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class OperandExpressionTest method testReferences.
@Test
public void testReferences() throws CouldntSaveDataException, CouldntDeleteException {
final MockOperandExpressionListener listener = new MockOperandExpressionListener();
final MockOperandTreeNode node = new MockOperandTreeNode();
final OperandExpression expression = new OperandExpression(node);
expression.addListener(listener);
final Reference reference1 = expression.addReference(new Address(0x123), ReferenceType.CALL_VIRTUAL);
final Reference reference2 = expression.addReference(new Address(0x124), ReferenceType.DATA);
final List<Reference> references = expression.getReferences();
assertEquals(2, references.size());
assertEquals(reference1, references.get(0));
assertEquals(reference2, references.get(1));
assertEquals("addedReference;addedReference;", listener.events);
expression.deleteReference(reference1);
assertEquals(1, expression.getReferences().size());
assertEquals("addedReference;addedReference;removedReference;", listener.events);
expression.removeListener(listener);
}
Aggregations