use of com.google.security.zynamics.binnavi.disassembly.MockTextNode in project binnavi by google.
the class ViewGraphHelpersTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException, PartialLoadException {
final MockSqlProvider provider = new MockSqlProvider();
final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
final Database database = new Database(new MockDatabase());
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);
internalModule.load();
final Module module = new Module(database, internalModule, tagManager, viewTagManager);
final CModuleViewGenerator generator = new CModuleViewGenerator(provider, internalModule);
final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 1, 2, new HashSet<CTag>(), new HashSet<CTag>(), false);
m_view = new View(module, internalView, tagManager, viewTagManager);
m_view.load();
final List<INaviInstruction> instructions = new ArrayList<INaviInstruction>();
instructions.add(new CInstruction(false, internalModule, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
instructions.add(new CInstruction(false, internalModule, new CAddress(0x124), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
instructions.add(new CInstruction(false, internalModule, new CAddress(0x125), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
final INaviCodeNode codeNode = internalView.getContent().createCodeNode(null, instructions);
final List<INaviViewNode> nodes1 = new ArrayList<INaviViewNode>();
nodes1.add(codeNode);
final List<INaviEdge> edges1 = new ArrayList<INaviEdge>();
final CFunction internalFunction = new CFunction(internalModule, new MockView(nodes1, edges1, provider), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
internalFunction.load();
final Function function = new Function(module, internalFunction);
final CFunctionNode functionNode = new CFunctionNode(0, internalFunction, 0, 0, 0, 0, Color.RED, false, false, null, new HashSet<CTag>(), provider);
m_codeNode = new CodeNode(m_view, codeNode, tagManager);
m_functionNode = new FunctionNode(m_view, functionNode, function, tagManager);
m_textNode = new TextNode(m_view, new MockTextNode(), tagManager);
final List<ViewNode> nodes = Lists.newArrayList(m_codeNode, m_functionNode, m_textNode);
final List<ViewEdge> edges = Lists.newArrayList(new ViewEdge(new MockEdge(1, provider), nodes.get(0), nodes.get(0)));
m_graph = new ViewGraph(nodes, edges);
}
use of com.google.security.zynamics.binnavi.disassembly.MockTextNode in project binnavi by google.
the class ViewGraphTest method testConstructor.
@Test
public void testConstructor() throws CouldntLoadDataException, LoadCancelledException {
final MockSqlProvider provider = new MockSqlProvider();
final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
final Database database = new Database(new MockDatabase());
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);
internalModule.load();
final Module module = new Module(database, internalModule, tagManager, viewTagManager);
final CModuleViewGenerator generator = new CModuleViewGenerator(provider, internalModule);
final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 1, 2, new HashSet<CTag>(), new HashSet<CTag>(), false);
final View view = new View(module, internalView, tagManager, viewTagManager);
final List<ViewNode> nodes = Lists.newArrayList((ViewNode) new TextNode(view, new MockTextNode(), tagManager));
final List<ViewEdge> edges = Lists.newArrayList(new ViewEdge(new MockEdge(1, provider), nodes.get(0), nodes.get(0)));
final ViewGraph graph = new ViewGraph(nodes, edges);
assertEquals(1, graph.getNodes().size());
assertEquals(nodes.get(0), graph.getNodes().get(0));
assertEquals(1, graph.getEdges().size());
assertEquals(edges.get(0), graph.getEdges().get(0));
assertEquals("View Graph [1 nodes, 1 edges]", graph.toString());
}
Aggregations