Search in sources :

Example 11 with CView

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");
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 12 with CView

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());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 13 with CView

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) {
    }
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 14 with CView

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());
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) CFunctionNode(com.google.security.zynamics.binnavi.disassembly.CFunctionNode) CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CUserManager(com.google.security.zynamics.binnavi.Gui.Users.CUserManager) Date(java.util.Date) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) CNaviViewEdge(com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge) MockInstruction(com.google.security.zynamics.binnavi.disassembly.MockInstruction) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode) Test(org.junit.Test)

Example 15 with CView

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());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) Test(org.junit.Test)

Aggregations

CView (com.google.security.zynamics.binnavi.disassembly.views.CView)45 Test (org.junit.Test)36 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)16 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)15 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)13 Date (java.util.Date)13 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)9 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)8 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)7 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)7 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)6 ArrayList (java.util.ArrayList)6 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)5 CFunctionNode (com.google.security.zynamics.binnavi.disassembly.CFunctionNode)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)4 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)4 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)4 BigInteger (java.math.BigInteger)4 CModuleViewGenerator (com.google.security.zynamics.binnavi.Database.CModuleViewGenerator)3