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);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeManagerExpensiveTests method testCreateTypeSubstitution.
private void testCreateTypeSubstitution(final INaviModule module) throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException {
final TypeManager manager = module.getTypeManager();
final BaseType baseType = manager.createAtomicType(TypeName, 32, true);
final INaviOperandTreeNode treeNode = new MockOperandTreeNode();
final int offset = 0;
final CAddress address = new CAddress(0x1000);
final TypeSubstitution substitution = manager.createTypeSubstitution(treeNode, baseType, 0, offset, address);
Assert.assertEquals(substitution.getAddress(), address);
Assert.assertTrue(substitution.getBaseType() == baseType);
Assert.assertTrue(substitution.getOffset() == offset);
Assert.assertTrue(substitution.getOperandTreeNode() == treeNode);
Assert.assertTrue(substitution.getExpressionId() == treeNode.getId());
final List<RawTypeSubstitution> substitutions = getProvider().loadTypeSubstitutions(module);
final List<RawTypeSubstitution> foundSubstitutions = findRawTypeSubstitutions(substitutions, treeNode.getId());
Assert.assertTrue(foundSubstitutions.size() == 1);
final RawTypeSubstitution foundSubstitution = foundSubstitutions.get(0);
matchTypeSubstitution(substitution, foundSubstitution);
manager.deleteType(baseType);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeManagerTest method testNotifySubstitutionCreated.
@Test
public void testNotifySubstitutionCreated() throws CouldntSaveDataException {
final TypeSubstitutionChangedEventCollector events = new TypeSubstitutionChangedEventCollector();
typeManager.addListener(events);
final IAddress address = new CAddress(0x1000);
final TypeSubstitution substitution = typeManager.createTypeSubstitution(new MockOperandTreeNode(), typeSystem.intType, 0, 0, address);
final TypeSubstitutionChangedEventCollector expectedEvents = new TypeSubstitutionChangedEventCollector();
expectedEvents.substitutionsAdded(Sets.newHashSet(substitution));
Assert.assertEquals(expectedEvents, events);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeManagerTest method testNotifySubstitutionUpdated.
@Test
public void testNotifySubstitutionUpdated() throws CouldntSaveDataException {
final IAddress address = new CAddress(0x1000);
final INaviOperandTreeNode node = new MockOperandTreeNode();
final TypeSubstitution substitution = typeManager.createTypeSubstitution(node, typeSystem.intType, 0, 0, address);
final TypeSubstitutionChangedEventCollector events = new TypeSubstitutionChangedEventCollector();
typeManager.addListener(events);
typeManager.updateTypeSubstitution(node, substitution, typeSystem.uintType, new ArrayList<TypeMember>(), 0);
typeManager.updateTypeSubstitution(node, typeSystem.uintType.getId(), new Integer[0], 0);
final TypeSubstitutionChangedEventCollector expectedEvents = new TypeSubstitutionChangedEventCollector();
expectedEvents.substitutionsChanged(Sets.newHashSet(substitution));
expectedEvents.substitutionsChanged(Sets.newHashSet(substitution));
Assert.assertEquals(expectedEvents, events);
}
use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.
the class TypeManagerTest method testNotifySubstitutionDeleted.
@Test
public void testNotifySubstitutionDeleted() throws CouldntDeleteException, CouldntSaveDataException {
final CAddress address = new CAddress(0x1000);
final INaviOperandTreeNode node = new MockOperandTreeNode();
final TypeSubstitution substitution = typeManager.createTypeSubstitution(node, typeSystem.intType, 0, 0, address);
final TypeSubstitutionChangedEventCollector events = new TypeSubstitutionChangedEventCollector();
typeManager.addListener(events);
typeManager.deleteTypeSubstitution(node);
final TypeSubstitutionChangedEventCollector expectedEvents = new TypeSubstitutionChangedEventCollector();
expectedEvents.substitutionsDeleted(Sets.newHashSet(substitution));
Assert.assertEquals(expectedEvents, events);
}
Aggregations