use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class PostgreSQLProviderTest method testSetDescription1.
@Test
public void testSetDescription1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviProject project = getProvider().loadProjects().get(0);
final CAddressSpace addressSpace = getProvider().createAddressSpace(project, "SOME_OTHER_ADDRESS_SPACE");
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final CFunction function = (CFunction) module.getContent().getFunctionContainer().getFunctions().get(0);
final CView view = (CView) module.getContent().getViewContainer().getViews().get(0);
final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
final ITreeNode<CTag> tag = tagManager.getRootTag().getChildren().get(0);
getProvider().setDescription(addressSpace, "New Description");
getProvider().setDescription(function, "New Description");
getProvider().setDescription(module, "New Description");
getProvider().setDescription(project, "New Description");
getProvider().setDescription(tag.getObject(), "New Description");
getProvider().setDescription(module.getContent().getTraceContainer().getTraces().get(0), "New Description");
getProvider().setDescription(view, "New Description");
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class PostgreSQLProviderTestSetup method testCreateViewModule4.
@Test
public void testCreateViewModule4() throws CouldntLoadDataException, CouldntSaveDataException, CPartialLoadException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final INaviView view = module.getContent().getViewContainer().getViews().get(223);
view.load();
final CView newView = getProvider().createView(module, view, "Module View Name", "Module View Description");
assertEquals("Module View Name", newView.getName());
assertEquals("Module View Description", newView.getConfiguration().getDescription());
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class CPostgreSQLModuleContentTest method testDeleteTrace.
@Test
public void testDeleteTrace() throws LoadCancelledException, CouldntLoadDataException, CouldntSaveDataException, CouldntDeleteException {
final CModule module = (CModule) getDatabase().getContent().getModules().get(0);
module.load();
final CModuleContent moduleContent1 = module.getContent();
assertNotNull(moduleContent1);
final CView view = moduleContent1.getViewContainer().createView("name", "desc");
assertNotNull(view);
final TraceList trace = moduleContent1.getTraceContainer().createTrace("name2", "desc2");
assertNotNull(trace);
moduleContent1.getTraceContainer().deleteTrace(trace);
try {
moduleContent1.getTraceContainer().deleteTrace(null);
} catch (final NullPointerException e) {
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class CViewInserterTest method test.
@Test
public void test() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, FileReadException, CouldntSaveDataException {
ConfigManager.instance().read();
final INaviModule mockModule = new MockModule();
final MockSqlProvider mockProvider = new MockSqlProvider();
final CUserManager userManager = CUserManager.get(mockProvider);
final IUser user = userManager.addUser(" VIEW INSERTER USER ");
userManager.setCurrentActiveUser(user);
final CModuleViewGenerator generator = new CModuleViewGenerator(mockProvider, mockModule);
final CView view = generator.generate(1, "", "", ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
view.load();
final MockFunction mockFunction = new MockFunction(mockProvider);
final CFunctionNode fnode1 = view.getContent().createFunctionNode(mockFunction);
final CFunctionNode fnode2 = view.getContent().createFunctionNode(mockFunction);
@SuppressWarnings("unused") final CNaviViewEdge edge1 = view.getContent().createEdge(fnode1, fnode2, EdgeType.JUMP_UNCONDITIONAL);
final MockInstruction instruction1 = new MockInstruction();
final CCodeNode cnode1 = view.getContent().createCodeNode(mockFunction, Lists.newArrayList(instruction1));
final CCodeNode cnode2 = view.getContent().createCodeNode(mockFunction, Lists.newArrayList(instruction1));
@SuppressWarnings("unused") final CNaviViewEdge edge2 = view.getContent().createEdge(cnode1, cnode2, EdgeType.JUMP_UNCONDITIONAL);
final ArrayList<IComment> comments = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Foo"));
final CTextNode tnode1 = view.getContent().createTextNode(comments);
@SuppressWarnings("unused") final CNaviViewEdge edge3 = view.getContent().createEdge(cnode1, tnode1, EdgeType.JUMP_UNCONDITIONAL);
final CGroupNode gnode1 = view.getContent().createGroupNode(Lists.newArrayList((INaviViewNode) fnode1, (INaviViewNode) fnode2));
gnode1.appendComment("TEST GROUP NODE COMMENT 1");
final CView view2 = generator.generate(2, "", "", ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
view2.load();
CViewInserter.insertView(view, view2);
final List<INaviViewNode> nodes = view2.getGraph().getNodes();
assertEquals(view2.getNodeCount(), 6);
assertEquals(mockFunction, ((INaviFunctionNode) nodes.get(0)).getFunction());
assertEquals(nodes.get(5), ((INaviFunctionNode) nodes.get(0)).getParentGroup());
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class CModuleTest method testViews.
@Test
public void testViews() throws CouldntLoadDataException, CouldntDeleteException, LoadCancelledException {
try {
m_module.getContent().getViewContainer().createView(null, "New Trace Description");
fail();
} catch (final NullPointerException exception) {
}
try {
m_module.getContent().getViewContainer().createView("New Trace", null);
fail();
} catch (final NullPointerException exception) {
}
try {
m_module.getContent().getViewContainer().createView("New View", "New Trace Description");
fail();
} catch (final NullPointerException exception) {
}
m_module.load();
final CView newView = m_module.getContent().getViewContainer().createView("New View", "New View Description");
// Check listener events
assertEquals("addedView/", m_listener.eventList);
assertEquals(newView, m_listener.addedViews.get(0));
// Check module
assertEquals(1, m_module.getCustomViewCount());
assertEquals(1, m_module.getFunctionCount());
assertEquals(3, m_module.getViewCount());
// Check view
assertTrue(newView.isLoaded());
assertEquals("New View", newView.getName());
assertEquals("New View Description", newView.getConfiguration().getDescription());
assertEquals(0, newView.getNodeCount());
assertEquals(0, newView.getEdgeCount());
assertEquals(ViewType.NonNative, newView.getType());
assertEquals(GraphType.MIXED_GRAPH, newView.getGraphType());
try {
m_module.getContent().getViewContainer().deleteView(null);
fail();
} catch (final NullPointerException exception) {
}
// Check module
assertEquals(1, m_module.getCustomViewCount());
assertEquals(1, m_module.getFunctionCount());
assertEquals(3, m_module.getViewCount());
m_module.getContent().getViewContainer().deleteView(newView);
// Check listener events
assertEquals("addedView/deletedView/", m_listener.eventList);
assertEquals(newView, m_listener.deletedViews.get(0));
// Check module
assertEquals(0, m_module.getCustomViewCount());
assertEquals(1, m_module.getFunctionCount());
assertEquals(2, m_module.getViewCount());
}
Aggregations