Search in sources :

Example 21 with CView

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

the class CViewTest method testSave.

@Test
public void testSave() throws CouldntSaveDataException, CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    try {
        m_view.save();
        fail();
    } catch (final IllegalStateException exception) {
    }
    m_view.load();
    m_view.save();
    // Check listener events
    assertEquals("loadedView/savedView/changedModificationDate/", m_listener.eventList);
    // --------------------------------------- SAVE A NATIVE VIEW
    // -------------------------------------------------
    final CView view = MockCreator.createNativeView(m_sql, m_module);
    try {
        view.save();
        fail();
    } catch (final IllegalArgumentException exception) {
    }
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) Test(org.junit.Test)

Example 22 with CView

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

the class CViewTest method testSomeOverwrittenMethods.

@Test
public void testSomeOverwrittenMethods() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, CouldntSaveDataException {
    final CProjectViewGenerator generator = new CProjectViewGenerator(m_sql, new MockProject());
    final CView view = generator.generate(6, "Blub", "Bla", ViewType.Native, GraphType.FLOWGRAPH, new Date(1234), new Date(12345), 123, 700, new HashSet<CTag>(), new HashSet<CTag>(), false);
    assertEquals(6, view.getConfiguration().getId());
    view.load();
    assertNotNull(view.getBasicBlockEdges());
    assertNotNull(view.getBasicBlocks());
    assertNotNull(view.getClass());
    assertNotNull(view.getConfiguration());
    assertNotNull(view.getContent());
    assertNotNull(view.getDerivedViews());
    assertEquals(0, view.getEdgeCount());
    assertNotNull(view.getGraph());
    assertEquals(GraphType.MIXED_GRAPH, view.getGraphType());
    assertEquals(-1, view.getLoadState());
    assertEquals("Blub", view.getName());
    assertEquals(0, view.getNodeCount());
    assertNotNull(view.getNodeTags());
    assertEquals(ViewType.Native, view.getType());
    assertTrue(view.isLoaded());
    assertFalse(view.isStared());
    try {
        view.save();
        fail();
    } catch (final IllegalArgumentException e) {
    }
    assertFalse(view.wasModified());
    view.close();
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CProjectViewGenerator(com.google.security.zynamics.binnavi.Database.CProjectViewGenerator) Date(java.util.Date) Test(org.junit.Test)

Example 23 with CView

use of com.google.security.zynamics.binnavi.disassembly.views.CView 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)

Example 24 with CView

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

the class PostgreSQLNotificationProviderTest method testDeleteTextNodeCommentSync.

@Test
public void testDeleteTextNodeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, InterruptedException, CouldntDeleteException {
    final CView databaseOneTextNodeView = databaseOneModuleTwo.getContent().getViewContainer().createView(" TEXT NODE TESTING VIEW ", "");
    CViewInserter.insertView(databaseOneView, databaseOneTextNodeView);
    final INaviTextNode databaseOneTextNode = databaseOneTextNodeView.getContent().createTextNode(new ArrayList<IComment>());
    databaseOneTextNodeView.save();
    databaseTwoModuleTwo.close();
    databaseTwoModuleTwo.load();
    databaseTwoView.load();
    final INaviView databaseTwoTextNodeView = Iterables.getLast(databaseTwoModuleTwo.getContent().getViewContainer().getUserViews());
    INaviTextNode databaseTwoTextNode = null;
    assertEquals(databaseOneTextNodeView.getName(), databaseTwoTextNodeView.getName());
    databaseTwoTextNodeView.load();
    for (final INaviViewNode node : databaseTwoTextNodeView.getContent().getGraph().getNodes()) {
        if (node instanceof INaviTextNode) {
            databaseTwoTextNode = (INaviTextNode) node;
        }
    }
    assertNotNull(databaseTwoTextNode);
    assertEquals(databaseTwoTextNode.getId(), databaseOneTextNode.getId());
    final List<IComment> comments = databaseOneTextNode.appendComment(" TEST NOTIFICATION PROVIDER TESTS (TEXT NODE COMMENT) ");
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOneTextNode.getComments();
    final List<IComment> twoAfter = databaseTwoTextNode.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();
    databaseOneTextNode.deleteComment(Iterables.getLast(comments));
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneThree = databaseOneTextNode.getComments();
    final List<IComment> twoThree = databaseTwoTextNode.getComments();
    assertEquals(oneTwoSize - 1, oneThree.size());
    assertEquals(twoTwoSize - 1, twoThree.size());
    assertEquals(oneThree, twoThree);
}
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) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) Test(org.junit.Test)

Example 25 with CView

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

the class PostgreSQLNotificationProviderTest method testAppendTextNodeCommentSync.

@Test
public void testAppendTextNodeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, CPartialLoadException, LoadCancelledException, InterruptedException {
    final CView databaseOneTextNodeView = databaseOneModuleTwo.getContent().getViewContainer().createView(" TEXT NODE TESTING VIEW ", "");
    CViewInserter.insertView(databaseOneView, databaseOneTextNodeView);
    final INaviTextNode databaseOneTextNode = databaseOneTextNodeView.getContent().createTextNode(new ArrayList<IComment>());
    databaseOneTextNodeView.save();
    databaseTwoModuleTwo.close();
    databaseTwoModuleTwo.load();
    databaseTwoView.load();
    final INaviView databaseTwoTextNodeView = Iterables.getLast(databaseTwoModuleTwo.getContent().getViewContainer().getUserViews());
    INaviTextNode databaseTwoTextNode = null;
    assertEquals(databaseOneTextNodeView.getName(), databaseTwoTextNodeView.getName());
    databaseTwoTextNodeView.load();
    for (final INaviViewNode node : databaseTwoTextNodeView.getContent().getGraph().getNodes()) {
        if (node instanceof INaviTextNode) {
            databaseTwoTextNode = (INaviTextNode) node;
        }
    }
    assertNotNull(databaseTwoTextNode);
    assertEquals(databaseTwoTextNode.getId(), databaseOneTextNode.getId());
    databaseOneTextNode.appendComment(" TEST NOTIFICATION PROVIDER TESTS (TEXT NODE COMMENT) ");
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOneTextNode.getComments();
    final List<IComment> twoAfter = databaseTwoTextNode.getComments();
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(1, oneAfter.size());
    assertEquals(1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
}
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) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) 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