use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class FunctionNodeTest method testConstructor.
@Test
public void testConstructor() {
final Database database = new Database(new MockDatabase());
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 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 Module module = new Module(database, internalModule, nodeTagManager, viewTagManager);
final MockView mockView = new MockView();
final View view = new View(module, mockView, nodeTagManager, viewTagManager);
final CFunction internalFunction = 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 CFunctionNode internalFunctionNode = new CFunctionNode(0, internalFunction, 0, 0, 0, 0, Color.RED, false, false, null, new HashSet<CTag>(), 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(module, parentFunction);
final FunctionNode node = new FunctionNode(view, internalFunctionNode, function, viewTagManager);
assertEquals(function, node.getFunction());
assertEquals("Function Node ['Mock Function']", node.toString());
}
use of com.google.security.zynamics.zylib.disassembly.CAddress 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.zylib.disassembly.CAddress in project binnavi by google.
the class ThreadTest method testGetCurrentAddress.
@Test
public void testGetCurrentAddress() {
final MockThreadListener listener = new MockThreadListener();
m_thread.addListener(listener);
m_internalThread.setCurrentAddress(new RelocatedAddress(new CAddress(0x200)));
assertEquals("changedProgramCounter;", listener.events);
assertEquals(0x200, m_thread.getCurrentAddress().toLong());
m_thread.removeListener(listener);
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class BasicBlockTest method testConstructor.
@Test
public void testConstructor() throws InternalTranslationException {
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 internalFunction = 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 List<INaviInstruction> instructions = new ArrayList<INaviInstruction>();
instructions.add(new MockInstruction(0x123));
final INaviBasicBlock bblock = new CBasicBlock(1, "Hannes", instructions);
final IBlockNode node = new CBlockNode(bblock);
final Function pFunction = new Function(ModuleFactory.get(), internalFunction);
final BasicBlock block = new BasicBlock(node, pFunction);
assertEquals(0x123, block.getAddress().toLong());
assertEquals(pFunction, block.getParentFunction());
assertEquals("Hannes", block.getComment());
assertEquals(0x123, block.getInstructions().get(0).getAddress().toLong());
assertNotNull(block.getReilCode());
assertTrue(block.getChildren().isEmpty());
assertTrue(block.getParents().isEmpty());
assertEquals("123 nop \n", block.toString());
}
use of com.google.security.zynamics.zylib.disassembly.CAddress in project binnavi by google.
the class CallgraphTest method testConstructor.
@Test
public void testConstructor() {
final List<FunctionBlock> nodes = new ArrayList<FunctionBlock>();
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 FunctionBlock b1 = new FunctionBlock(new Function(ModuleFactory.get(), parentFunction));
final FunctionBlock b2 = new FunctionBlock(new Function(ModuleFactory.get(), parentFunction));
nodes.add(b1);
nodes.add(b2);
final List<FunctionEdge> edges = new ArrayList<FunctionEdge>();
final FunctionEdge e1 = new FunctionEdge(b1, b2);
edges.add(e1);
final Callgraph cg = new Callgraph(nodes, edges);
assertEquals(2, cg.getNodes().size());
assertEquals(b1, cg.getNodes().get(0));
assertEquals(b2, cg.getNodes().get(1));
assertEquals(1, cg.getEdges().size());
assertEquals(e1, cg.getEdges().get(0));
assertEquals("Callgraph [2 function nodes, 1 edges]", cg.toString());
}
Aggregations