Search in sources :

Example 11 with MockOperandTreeNode

use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.

the class TypeInstanceContainerTests method createReferenceTest5.

@Test
public void createReferenceTest5() throws CouldntLoadDataException, CouldntSaveDataException {
    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()));
    expectedEvents.addedTypeInstance(typeInstance);
    Assert.assertEquals(expectedEvents, listener);
    Assert.assertEquals(0, typeInstanceContainer.getReferences(typeInstance).size());
    final TypeInstanceReference typeInstanceReference = typeInstanceContainer.createReference(new CAddress("41000", 16), 0, new MockOperandTreeNode(), typeInstance, view);
    Assert.assertNotNull(typeInstanceReference);
    Assert.assertEquals(1, typeInstanceContainer.getReferences(typeInstance).size());
    Assert.assertTrue(typeInstanceContainer.getReferences(typeInstance).contains(typeInstanceReference));
    expectedEvents.addedTypeInstanceReference(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 12 with MockOperandTreeNode

use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.

the class TypeManagerDatabaseBackendTests method testUpdateTypeSubstitution.

@Test
public void testUpdateTypeSubstitution() throws CouldntSaveDataException, CouldntLoadDataException {
    final MockOperandTreeNode node = new MockOperandTreeNode();
    final BaseType baseType = backend.createType("test_type", 32, true, null, BaseTypeCategory.ATOMIC);
    final BaseType newType = backend.createType("new_test_type", 32, true, null, BaseTypeCategory.ATOMIC);
    final Integer newOffset = 64;
    final TypeSubstitution substitution = backend.createTypeSubstitution(node, baseType, new ArrayList<Integer>(), 0, 32, new CAddress(0x1000));
    backend.updateSubstitution(substitution, newType, new ArrayList<Integer>(), newOffset);
    final RawTypeSubstitution updatedSubstitution = mockProvider.loadTypeSubstitution(mockModule, substitution.getAddress().toBigInteger(), substitution.getPosition(), substitution.getExpressionId());
    Assert.assertEquals(newOffset, updatedSubstitution.getOffset());
    Assert.assertEquals(newType.getId(), updatedSubstitution.getBaseTypeId());
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 13 with MockOperandTreeNode

use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.

the class TypeManagerDatabaseBackendTests method testCreateTypeSubstitution.

@Test
public void testCreateTypeSubstitution() throws CouldntSaveDataException {
    final CAddress address = new CAddress(0x1000);
    final int position = 0;
    final int offset = 32;
    final MockOperandTreeNode node = new MockOperandTreeNode();
    final BaseType baseType = backend.createType("test_type", 32, true, null, BaseTypeCategory.ATOMIC);
    final TypeSubstitution substitution = backend.createTypeSubstitution(node, baseType, new ArrayList<Integer>(), position, offset, address);
    Assert.assertEquals(node, substitution.getOperandTreeNode());
    Assert.assertEquals(baseType, substitution.getBaseType());
    Assert.assertEquals(position, substitution.getPosition());
    Assert.assertEquals(offset, substitution.getOffset());
    Assert.assertEquals(address, substitution.getAddress());
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 14 with MockOperandTreeNode

use of com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode in project binnavi by google.

the class OperandExpressionTest method testConstructor.

@Test
public void testConstructor() {
    final MockOperandTreeNode node = new MockOperandTreeNode();
    final OperandExpression expression = new OperandExpression(node);
    assertEquals(ExpressionType.Register, expression.getType());
    assertEquals("Mock Replacement", expression.getReplacement());
    assertEquals("Mock Value", expression.toString());
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) 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