Search in sources :

Example 71 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class CProjectContentTest method testGetTaggedViews2.

@Test
public void testGetTaggedViews2() {
    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)));
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) Test(org.junit.Test)

Example 72 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class CViewTest method testTagging.

@Test
public void testTagging() throws CouldntSaveDataException {
    final CTag newTag = MockCreator.createViewTag(m_sql);
    // ------------------------------------ TAG VIEW --------------------------------
    m_view.getConfiguration().tagView(newTag);
    // Check listener events
    assertEquals("taggedView/", m_listener.eventList);
    // Check view
    assertTrue(m_view.getConfiguration().isTagged());
    assertTrue(m_view.getConfiguration().isTagged(newTag));
    m_view.getConfiguration().tagView(newTag);
    // Check listener events
    assertEquals("taggedView/", m_listener.eventList);
    // Check view
    assertTrue(m_view.getConfiguration().isTagged());
    assertTrue(m_view.getConfiguration().isTagged(newTag));
    // --------------------------------------- UNTAG VIEW -----------------------------------
    m_view.getConfiguration().untagView(newTag);
    // Check listener events
    assertEquals("taggedView/untaggedView/", m_listener.eventList);
    // Check view
    assertFalse(m_view.getConfiguration().isTagged());
    assertFalse(m_view.getConfiguration().isTagged(newTag));
}
Also used : CTag(com.google.security.zynamics.binnavi.Tagging.CTag) Test(org.junit.Test)

Example 73 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class CViewTest method testConstructor15.

@Test
public void testConstructor15() {
    final MockSqlProvider sql = new MockSqlProvider();
    final CModule module = MockCreator.createModule(sql);
    final Date creationDate = new Date();
    Date modificationDate = new Date();
    final int viewId = new BigInteger(31, random).intValue();
    final Calendar cal = Calendar.getInstance();
    cal.setTime(modificationDate);
    cal.add(Calendar.DATE, 1);
    modificationDate = cal.getTime();
    final CView view = new CView(viewId, module, "New View", "New View Description", ViewType.Native, GraphType.FLOWGRAPH, creationDate, modificationDate, 33, 44, new HashSet<CTag>(), new HashSet<CTag>(), false, sql);
    assertEquals(viewId, view.getConfiguration().getId());
    assertEquals("New View", view.getName());
    assertEquals("New View Description", view.getConfiguration().getDescription());
    assertEquals(ViewType.Native, view.getType());
    assertEquals(GraphType.FLOWGRAPH, view.getGraphType());
    assertEquals(33, view.getNodeCount());
    assertEquals(44, view.getEdgeCount());
    assertEquals(creationDate, view.getConfiguration().getCreationDate());
    assertEquals(modificationDate, view.getConfiguration().getModificationDate());
    final Set<CTag> tags = new HashSet<CTag>();
    final CTag tag1 = new CTag(1, "Tag1", "Tag1 Tag1", TagType.VIEW_TAG, sql);
    final CTag tag2 = new CTag(2, "Tag2", "Tag2 Tag2", TagType.VIEW_TAG, sql);
    final CTag tag3 = new CTag(3, "Tag3", "Tag3 Tag3", TagType.VIEW_TAG, sql);
    final CTag tag4 = new CTag(4, "Tag4", "Tag4 Tag4", TagType.VIEW_TAG, sql);
    tags.add(tag1);
    tags.add(tag2);
    tags.add(tag3);
    tags.add(tag4);
    new CView(1, module, "New View", "New View Description", ViewType.Native, GraphType.FLOWGRAPH, creationDate, modificationDate, 33, 44, new HashSet<CTag>(), tags, false, sql);
    tags.add(null);
    try {
        new CView(1, module, "New View", "New View Description", ViewType.Native, GraphType.FLOWGRAPH, creationDate, modificationDate, 33, 44, tags, new HashSet<CTag>(), false, sql);
        fail();
    } catch (final NullPointerException e) {
    }
    tags.clear();
    tags.add(tag1);
    tags.add(tag2);
    tags.add(tag3);
    tags.add(tag4);
    final CTag tag5 = new CTag(5, "Tag1", "Tag1 Tag1", TagType.NODE_TAG, sql);
    tags.add(tag5);
    try {
        new CView(1, module, "New View", "New View Description", ViewType.Native, GraphType.FLOWGRAPH, creationDate, modificationDate, 33, 44, tags, new HashSet<CTag>(), false, sql);
        fail();
    } catch (final IllegalArgumentException e) {
    }
    tags.clear();
    final CTag tagWrongDB = new CTag(4, "Tag4", "Tag4 Tag4", TagType.VIEW_TAG, new MockSqlProvider());
    tags.add(tagWrongDB);
    try {
        new CView(1, module, "New View", "New View Description", ViewType.Native, GraphType.FLOWGRAPH, creationDate, modificationDate, 33, 44, tags, new HashSet<CTag>(), false, sql);
        fail();
    } catch (final IllegalArgumentException e) {
    }
}
Also used : Calendar(java.util.Calendar) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) Date(java.util.Date) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) BigInteger(java.math.BigInteger) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 74 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class CViewTest method testConstructor16.

@Test
public void testConstructor16() {
    final MutableDirectedGraph<INaviViewNode, INaviEdge> graph = new MutableDirectedGraph<INaviViewNode, INaviEdge>(new ArrayList<INaviViewNode>(), new ArrayList<INaviEdge>());
    final Set<CTag> tags = new HashSet<CTag>();
    final MockSqlProvider provider = new MockSqlProvider();
    final MockModule module = new MockModule();
    final CView view = new CView(2, module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
    assertEquals(2, view.getConfiguration().getId());
    assertEquals("View", view.getName());
    assertEquals("Description", view.getConfiguration().getDescription());
    assertEquals(ViewType.Native, view.getType());
    assertEquals(0, view.getNodeCount());
    assertEquals(0, view.getEdgeCount());
    try {
        new CView(-2, module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final IllegalArgumentException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), (CModule) null, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, null, "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "Description", null, ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", null, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, null, new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), null, graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), new Date(12345), null, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), new Date(12345), graph, null, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), new Date(12345), graph, tags, false, null);
        fail();
    } catch (final NullPointerException e) {
    }
    final CTag tag1 = new CTag(1, "Tag1", "Tag1 Tag1", TagType.VIEW_TAG, provider);
    final CTag tag2 = new CTag(2, "Tag2", "Tag2 Tag2", TagType.VIEW_TAG, provider);
    final CTag tag3 = new CTag(3, "Tag3", "Tag3 Tag3", TagType.VIEW_TAG, provider);
    final CTag tag4 = new CTag(4, "Tag4", "Tag4 Tag4", TagType.VIEW_TAG, provider);
    tags.add(tag1);
    tags.add(tag2);
    tags.add(tag3);
    tags.add(tag4);
    new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
    tags.add(null);
    try {
        new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    tags.clear();
    tags.add(tag1);
    tags.add(tag2);
    tags.add(tag3);
    tags.add(tag4);
    final CTag tag5 = new CTag(5, "Tag1", "Tag1 Tag1", TagType.NODE_TAG, provider);
    tags.add(tag5);
    try {
        new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final IllegalArgumentException e) {
    }
    tags.clear();
    final CTag tagWrongDB = new CTag(new BigInteger(31, random).intValue(), "Tag4", "Tag4 Tag4", TagType.VIEW_TAG, new MockSqlProvider());
    tags.add(tagWrongDB);
    try {
        new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final IllegalArgumentException e) {
    }
}
Also used : CTag(com.google.security.zynamics.binnavi.Tagging.CTag) Date(java.util.Date) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) BigInteger(java.math.BigInteger) MutableDirectedGraph(com.google.security.zynamics.zylib.types.graphs.MutableDirectedGraph) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 75 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.

the class CViewTest method testConstructor3.

@Test
public void testConstructor3() {
    try {
        new CView(new BigInteger(31, random).intValue(), (INaviProject) null, "Blub", "Bla", ViewType.Native, GraphType.FLOWGRAPH, new Date(1234), new Date(12345), 123, 700, new HashSet<CTag>(), new HashSet<CTag>(), false, new MockSqlProvider());
        fail();
    } catch (final NullPointerException e) {
    }
    final int viewId = new BigInteger(31, random).intValue();
    final CView view = new CView(viewId, new MockProject(), "Blub", "Bla", ViewType.Native, GraphType.FLOWGRAPH, new Date(1234), new Date(12345), 123, 700, new HashSet<CTag>(), new HashSet<CTag>(), false, new MockSqlProvider());
    assertEquals(viewId, view.getConfiguration().getId());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) BigInteger(java.math.BigInteger) Date(java.util.Date) Test(org.junit.Test)

Aggregations

CTag (com.google.security.zynamics.binnavi.Tagging.CTag)113 Test (org.junit.Test)55 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)42 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)35 Date (java.util.Date)28 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)24 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)24 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)21 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)20 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)18 ArrayList (java.util.ArrayList)17 Tree (com.google.security.zynamics.zylib.types.trees.Tree)15 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)14 TreeNode (com.google.security.zynamics.zylib.types.trees.TreeNode)14 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)13 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)13 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)13 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)13 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)13 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)12