Search in sources :

Example 6 with MockOperandTreeNode

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);
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 7 with MockOperandTreeNode

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);
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 8 with MockOperandTreeNode

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);
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 9 with MockOperandTreeNode

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);
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 10 with MockOperandTreeNode

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);
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) Reference(com.google.security.zynamics.binnavi.API.disassembly.Reference) OperandExpression(com.google.security.zynamics.binnavi.API.disassembly.OperandExpression) Test(org.junit.Test)

Aggregations

MockOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode)14 Test (org.junit.Test)13 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)12 INaviOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode)3 OperandExpression (com.google.security.zynamics.binnavi.API.disassembly.OperandExpression)2 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)2 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)1 Reference (com.google.security.zynamics.binnavi.API.disassembly.Reference)1