use of com.google.security.zynamics.binnavi.disassembly.Modules.CModule in project binnavi by google.
the class GroupNodeTest method testElements.
@Test
public void testElements() throws CouldntLoadDataException, PartialLoadException {
final Database database = new Database(new MockDatabase());
final SQLProvider mockProvider = new MockSqlProvider();
final CModule mockModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, mockProvider);
final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
final CModuleViewGenerator generator = new CModuleViewGenerator(mockProvider, mockModule);
final INaviView mockView = generator.generate(1, "", "", ViewType.NonNative, GraphType.FLOWGRAPH, new Date(), new Date(), 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
final View view = new View(module, mockView, nodeTagManager, viewTagManager);
view.load();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, mockProvider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, mockProvider);
final CodeNode codeNode = view.createCodeNode(new Function(module, parentFunction), Lists.newArrayList(new Instruction(new MockInstruction())));
final CodeNode codeNode2 = view.createCodeNode(new Function(module, parentFunction), Lists.newArrayList(new Instruction(new MockInstruction())));
final GroupNode node = view.createGroupNode("", Lists.newArrayList((ViewNode) codeNode2));
final MockGroupNodeListener listener = new MockGroupNodeListener();
final MockViewNodeListener listener2 = new MockViewNodeListener();
node.addListener(listener);
codeNode.addListener(listener2);
node.addNode(codeNode);
assertEquals(2, node.getElements().size());
assertEquals(codeNode, node.getElements().get(1));
assertEquals(node, codeNode.getParentGroup());
assertEquals("addedElement;", listener.events);
assertEquals("changedParentGroup;", listener2.events);
node.removeNode(codeNode);
assertEquals(1, node.getElements().size());
assertEquals(null, codeNode.getParentGroup());
assertEquals("addedElement;removedElement;", listener.events);
assertEquals("changedParentGroup;changedParentGroup;", listener2.events);
node.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.CModule in project binnavi by google.
the class FunctionBlockTest method testConstructor.
@Test
public void testConstructor() {
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final Function function = new Function(ModuleFactory.get(), parentFunction);
final FunctionBlock block = new FunctionBlock(function);
assertEquals(function, block.getFunction());
assertEquals("Function Block ['123 Mock Function']", block.toString());
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.CModule in project binnavi by google.
the class FunctionEdgeTest method testConstructor.
@Test
public void testConstructor() {
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final Function function = new Function(ModuleFactory.get(), parentFunction);
final FunctionBlock block = new FunctionBlock(function);
final FunctionBlock childBlock = new FunctionBlock(function);
final FunctionEdge edge = new FunctionEdge(block, childBlock);
assertEquals("Function Edge [Mock Function -> Mock Function]", edge.toString());
assertEquals(block, edge.getSource());
assertEquals(childBlock, edge.getTarget());
assertEquals(0, block.getParents().size());
assertEquals(1, block.getChildren().size());
assertEquals(childBlock, block.getChildren().get(0));
assertEquals(0, childBlock.getChildren().size());
assertEquals(1, childBlock.getParents().size());
assertEquals(block, childBlock.getParents().get(0));
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.CModule in project binnavi by google.
the class PostgreSQLProvider method createModule.
@Override
public CModule createModule(final INaviRawModule rawModule) throws CouldntLoadDataException, CouldntSaveDataException {
final CModule newModule = getModuleConverter().createModule(this, rawModule);
getModules().add(newModule);
return newModule;
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.CModule in project binnavi by google.
the class CDatabaseContent method createModule.
/**
* Creates a new module for a raw module.
*
* @param rawModule The raw module that backs the module.
*
* @return The created module.
*
* @throws CouldntLoadDataException Thrown if the module data could not be loaded.
* @throws CouldntSaveDataException Thrown if the module could not be created.
*/
private CModule createModule(final INaviRawModule rawModule) throws CouldntLoadDataException, CouldntSaveDataException {
final CModule newModule = m_provider.createModule(rawModule);
m_modules.add(newModule);
return newModule;
}
Aggregations