Search in sources :

Example 81 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class CProjectContainerTest method testCreateView.

@Test
public void testCreateView() {
    final CProjectContainer container = new CProjectContainer(m_database, m_project);
    try {
        container.createView(null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        container.createView("seppel", null);
        fail();
    } catch (final NullPointerException e) {
    }
    final INaviView view = container.createView("foo", "berT");
    assertNotNull(view);
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) Test(org.junit.Test)

Example 82 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class CProjectContainerTest method testGetFunction.

@Test
public void testGetFunction() {
    final CProjectContainer container = new CProjectContainer(m_database, m_project);
    final INaviView view = container.createView("foo", "berT");
    try {
        container.getFunction(null);
        fail();
    } catch (final NullPointerException e) {
    }
    assertNull(container.getFunction(view));
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) Test(org.junit.Test)

Example 83 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class CProjectContentTest method testClose.

@Test
public void testClose() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final CProjectContent projectContent = new CProjectContent(m_project, m_listeners, m_provider, m_addressSpaces, m_views, m_traces);
    assertNotNull(projectContent);
    final CAddressSpace spaceOne = projectContent.createAddressSpace("Address Space 1");
    spaceOne.load();
    final CAddressSpace spaceTwo = projectContent.createAddressSpace("Address Space 2");
    spaceTwo.load();
    final CAddressSpace spaceThree = projectContent.createAddressSpace("Address Space 3");
    spaceThree.load();
    final CAddressSpace spaceFour = projectContent.createAddressSpace("Address Space 4");
    spaceFour.load();
    @SuppressWarnings("unused") final INaviView viewOne = projectContent.createView(new MockView(m_provider), "View 1 Name", "View 1 description");
    projectContent.close();
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Test(org.junit.Test)

Example 84 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class CProjectContentTest method testRemoveAddressSpace.

@Test
public void testRemoveAddressSpace() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CouldntDeleteException {
    final CProjectContent projectContent = new CProjectContent(m_project, m_listeners, m_provider, m_addressSpaces, m_views, m_traces);
    @SuppressWarnings("unused") final INaviView view = new MockView(m_provider);
    @SuppressWarnings("unused") final INaviView view2 = projectContent.createView("Name", "description");
    assertNotNull(CViewFilter.getTaggedViews(projectContent.getViews(), new CTag(4, "foo", "bar", TagType.VIEW_TAG, m_provider)));
    final CAddressSpace spaceOne = projectContent.createAddressSpace("Address Space 1");
    spaceOne.load();
    final CAddressSpace spaceTwo = projectContent.createAddressSpace("Address Space 2");
    spaceTwo.load();
    final CAddressSpace spaceThree = projectContent.createAddressSpace("Address Space 3");
    spaceThree.load();
    final CAddressSpace spaceFour = projectContent.createAddressSpace("Address Space 4");
    spaceFour.load();
    m_project.load();
    try {
        assertFalse(projectContent.removeAddressSpace(spaceThree));
        fail();
    } catch (final IllegalStateException e) {
    }
    spaceThree.close();
    assertTrue(projectContent.removeAddressSpace(spaceThree));
    try {
        assertFalse(projectContent.removeAddressSpace(spaceThree));
        fail();
    } catch (final IllegalArgumentException e) {
    }
    try {
        assertFalse(projectContent.removeAddressSpace(null));
        fail();
    } catch (final NullPointerException e) {
    }
    m_project.close();
    try {
        assertFalse(projectContent.removeAddressSpace(spaceFour));
        fail();
    } catch (final IllegalStateException e) {
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Test(org.junit.Test)

Example 85 with INaviView

use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.

the class PostgreSQLNotificationProviderTest method testEditGroupNodeComment.

@Test
public void testEditGroupNodeComment() throws CouldntSaveDataException, CouldntLoadDataException, CPartialLoadException, LoadCancelledException, InterruptedException {
    final CView databaseOneGroupNodeView = databaseOneModuleTwo.getContent().getViewContainer().createView(" GROUP NODE TESTING VIEW ", "");
    CViewInserter.insertView(databaseOneView, databaseOneGroupNodeView);
    final INaviGroupNode databaseOneGroupNode = databaseOneGroupNodeView.getContent().createGroupNode(databaseOneGroupNodeView.getGraph().getNodes());
    databaseOneGroupNodeView.save();
    databaseTwoModuleTwo.close();
    databaseTwoModuleTwo.load();
    databaseTwoView.load();
    final INaviView databaseTwoGroupNodeView = Iterables.getLast(databaseTwoModuleTwo.getContent().getViewContainer().getUserViews());
    INaviGroupNode databaseTwoGroupNode = null;
    assertEquals(databaseOneGroupNodeView.getName(), databaseTwoGroupNodeView.getName());
    databaseTwoGroupNodeView.load();
    for (final INaviViewNode node : databaseTwoGroupNodeView.getContent().getGraph().getNodes()) {
        if (node instanceof INaviGroupNode) {
            databaseTwoGroupNode = (INaviGroupNode) node;
        }
    }
    assertNotNull(databaseTwoGroupNode);
    assertEquals(databaseTwoGroupNode.getId(), databaseOneGroupNode.getId());
    final List<IComment> comments = databaseOneGroupNode.appendComment(" TEST NOTIFICATION PROVIDER TESTS (GROUP NODE COMMENT) BEFORE ");
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOneGroupNode.getComments();
    final List<IComment> twoAfter = databaseTwoGroupNode.getComments();
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(1, oneAfter.size());
    assertEquals(1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
    final int oneTwoSize = oneAfter.size();
    final int twoTwoSize = twoAfter.size();
    databaseOneGroupNode.editComment(Iterables.getLast(comments), " TEST NOTIFICATION PROVIDER TESTS (GROUP NODE COMMENT) AFTER ");
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneThree = databaseOneGroupNode.getComments();
    final List<IComment> twoThree = databaseTwoGroupNode.getComments();
    assertEquals(oneTwoSize, oneThree.size());
    assertEquals(twoTwoSize, twoThree.size());
    assertEquals(oneThree, twoThree);
    assertEquals(" TEST NOTIFICATION PROVIDER TESTS (GROUP NODE COMMENT) AFTER ", Iterables.getLast(oneThree).getComment());
    assertEquals(" TEST NOTIFICATION PROVIDER TESTS (GROUP NODE COMMENT) AFTER ", Iterables.getLast(twoThree).getComment());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) Test(org.junit.Test)

Aggregations

INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)121 Test (org.junit.Test)54 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)29 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)26 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)18 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)13 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)11 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)10 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)10 ArrayList (java.util.ArrayList)10 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)9 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 HashMap (java.util.HashMap)8 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)7 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)7 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)7 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)7 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)6