Search in sources :

Example 51 with CTag

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

the class CTagTest method test_C_Constructor.

@Test
public void test_C_Constructor() {
    try {
        new CTag(-1, "Tag Name", "Tag Description", TagType.NODE_TAG, new MockSqlProvider());
        fail();
    } catch (final IllegalArgumentException exception) {
    }
    try {
        new CTag(0, null, "Tag Description", TagType.NODE_TAG, new MockSqlProvider());
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        new CTag(0, "Tag Name", null, TagType.NODE_TAG, new MockSqlProvider());
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        new CTag(0, "Tag Name", "Tag Description", null, new MockSqlProvider());
        fail();
    } catch (final NullPointerException exception) {
    }
    try {
        new CTag(0, "Tag Name", "Tag Description", TagType.NODE_TAG, null);
        fail();
    } catch (final NullPointerException exception) {
    }
    assertEquals(1, m_tag.getId());
    assertEquals("Tag Name", m_tag.getName());
    assertEquals("Tag Description", m_tag.getDescription());
    assertEquals(TagType.NODE_TAG, m_tag.getType());
}
Also used : MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) Test(org.junit.Test)

Example 52 with CTag

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

the class CProjectContentTest method testRemoveTrace.

@Test
public void testRemoveTrace() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, 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();
    final TraceList trace = new TraceList(3, "name", "desc", m_provider);
    projectContent.removeTrace(trace);
    try {
        projectContent.removeTrace(null);
        fail();
    } catch (final NullPointerException e) {
    }
    final TraceList trace2 = new TraceList(3, "name", "desc", new MockSqlProvider());
    try {
        projectContent.removeTrace(trace2);
        fail();
    } catch (final Exception e) {
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) Test(org.junit.Test)

Example 53 with CTag

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

the class CViewTest method testConstructor2.

@Test
public void testConstructor2() {
    try {
        new CView(new BigInteger(31, random).intValue(), (INaviProject) null, "Foo", "Bar", ViewType.Native, new Date(1234), new Date(12345), new MutableDirectedGraph<INaviViewNode, INaviEdge>(new ArrayList<INaviViewNode>(), new ArrayList<INaviEdge>()), 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(), "Foo", "Bar", ViewType.Native, new Date(1234), new Date(12345), new MutableDirectedGraph<INaviViewNode, INaviEdge>(new ArrayList<INaviViewNode>(), new ArrayList<INaviEdge>()), new HashSet<CTag>(), false, new MockSqlProvider());
    assertEquals(viewId, view.getConfiguration().getId());
}
Also used : ArrayList(java.util.ArrayList) 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) Test(org.junit.Test)

Example 54 with CTag

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

the class CViewTest method testLifeCycle.

@Test
public void testLifeCycle() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
    final MockSqlProvider sql = new MockSqlProvider();
    final Set<CTag> tags = new HashSet<CTag>();
    tags.add(new CTag(1, "", "", TagType.VIEW_TAG, sql));
    final CModuleViewGenerator generator = new CModuleViewGenerator(sql, m_module);
    final CView view = generator.generate(1, "New View", "New View Description", ViewType.Native, GraphType.FLOWGRAPH, new Date(), new Date(), 33, 44, tags, new HashSet<CTag>(), false);
    final MockViewListener listener = new MockViewListener();
    view.addListener(listener);
    view.load();
    listener.m_closing = false;
    view.close();
    assertTrue(view.isLoaded());
    listener.m_closing = true;
    view.close();
    assertFalse(view.isLoaded());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) Date(java.util.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 55 with CTag

use of com.google.security.zynamics.binnavi.Tagging.CTag 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)

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