use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.
the class CGraphSynchonizerTest method test1Simple.
// TODO this test is very artificial as it does not test a real work flow.
@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final ZyGraph graph = ZyGraphFactory.generateTestGraph();
final CSpecialInstructionsModel model = new CSpecialInstructionsModel();
final List<CSpecialInstruction> instructions = new ArrayList<CSpecialInstruction>();
final ITypeDescription callsDescription = model.getDescriptions().get(0);
callsDescription.setEnabled(true);
final CSpecialInstruction instruction = new CSpecialInstruction(callsDescription, Iterables.getFirst(graph.getRawView().getBasicBlocks().get(2).getInstructions(), null));
final CCodeNode node = graph.getRawView().getBasicBlocks().get(2);
final NaviNode naviNode = graph.getNode(node);
final BackEndDebuggerProvider provider = new MockDebuggerProvider();
new CCodeNodeUpdater(graph, naviNode, node, provider);
instructions.add(instruction);
model.setInstructions(instructions);
assertFalse(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
final CGraphSynchronizer synchronizer = new CGraphSynchronizer(graph, model);
CTypeResultsHighlighter.updateHighlighting(graph, Lists.newArrayList(instruction));
assertTrue(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
synchronizer.dispose();
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.
the class PostgreSQLGroupNodeCommentTests method appendInstructionCommentInGroupNode.
@Test
public void appendInstructionCommentInGroupNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
assertEquals(42, view.getNodeCount());
final INaviViewNode node1 = view.getContent().getBasicBlocks().get(1);
final INaviViewNode node2 = view.getContent().getBasicBlocks().get(2);
view.getContent().createGroupNode(Lists.newArrayList(node1, node2));
final ZyGraph graph = CGraphBuilder.buildGraph(view);
final INaviView nonNativeView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST INSTRUCTION COMMENTS IN GROUP NODE ", " TESTING GROUP NODE COMMENTS ");
final INaviInstruction instruction = view.getContent().getBasicBlocks().get(0).getLastInstruction();
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final String firstCommentString = "TEST INSTRUCTION COMMENT PROPAGATION";
final int firstCommentId = getProvider().appendGlobalInstructionComment(instruction, firstCommentString, user.getUserId());
final IComment firstComment = new CComment(firstCommentId, user, null, firstCommentString);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(firstCommentId);
assertNotNull(commentsFromDatabase);
assertEquals(1, commentsFromDatabase.size());
assertTrue(commentsFromDatabase.contains(firstComment));
final INaviInstruction instruction2 = nonNativeView.getBasicBlocks().get(0).getLastInstruction();
assertEquals(1, instruction2.getGlobalComment().size());
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph in project binnavi by google.
the class CPostgreSQLZyGraphTest2 method testLayouting.
@Test
public void testLayouting() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
final ICallgraphView cg = m_module.getContent().getViewContainer().getNativeCallgraphView();
final ZyGraphViewSettings settings = ConfigManager.instance().getDefaultFlowGraphSettings();
settings.getProximitySettings().setProximityBrowsingActivationThreshold(50);
cg.load();
final ZyGraph g = CGraphBuilder.buildGraph(cg);
g.getSettings().getLayoutSettings().setDefaultGraphLayout(LayoutStyle.HIERARCHIC);
g.doLayout();
g.getSettings().getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
g.doLayout();
}
Aggregations