Search in sources :

Example 26 with CProject

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

the class CProjectContainerTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    m_provider = new MockSqlProvider();
    m_module = new MockModule(m_provider);
    m_database = new MockDatabase(m_provider);
    m_function = new MockFunction(m_provider);
    m_project = new CProject(123, "Name", "Comment", new Date(), new Date(), 55, new FilledList<DebuggerTemplate>(), m_provider);
    m_project.load();
    m_space = m_project.getContent().createAddressSpace("space");
    m_space.load();
    m_space.getContent().addModule(m_module);
    m_debugger = new DebuggerTemplate(2, "gdb", "local", 2222, m_provider);
    m_space.getConfiguration().setDebuggerTemplate(m_debugger);
    m_listener = new MockAddressSpaceListener();
    m_space.addListener(m_listener);
    m_module.load();
    CFunctionContainerHelper.addFunction(m_module.getContent().getFunctionContainer(), m_function);
    final CView view = m_module.getContent().getViewContainer().createView("foo", "bar");
    @SuppressWarnings("unused") final MockViewContainer mockViewContainer = new MockViewContainer();
    final MockViewListener listener = new MockViewListener();
    view.addListener(listener);
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) MockAddressSpaceListener(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.MockAddressSpaceListener) 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) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Before(org.junit.Before)

Example 27 with CProject

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

the class CProjectContainerNodeTest method testUnloaded.

@Test
public void testUnloaded() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final CProject project1 = new CProject(123, "Project 1", "Comment", new Date(), new Date(), 55, new ArrayList<DebuggerTemplate>(), m_provider);
    final CProject project2 = new CProject(123, "Project 2", "Comment", new Date(), new Date(), 55, new ArrayList<DebuggerTemplate>(), m_provider);
    final CProjectContainerNode node = new CProjectContainerNode(m_tree, m_database);
    assertEquals("Projects (0)", node.toString());
    assertEquals(0, node.getChildCount());
    m_database.addProject(project1);
    m_database.addProject(project2);
    assertEquals("Projects (2)", node.toString());
    assertEquals(2, node.getChildCount());
    assertEquals("Project 1 (55)", node.getChildAt(0).toString());
    assertEquals("Project 2 (55)", node.getChildAt(1).toString());
    m_database.getContent().delete(project1);
    assertEquals("Projects (1)", node.toString());
    assertEquals(1, node.getChildCount());
    assertEquals("Project 2 (55)", node.getChildAt(0).toString());
    node.dispose();
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")).isEmpty());
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database.getContent().getDebuggerTemplateManager(), "listeners"), "m_listeners")) == null);
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) Date(java.util.Date) Test(org.junit.Test)

Example 28 with CProject

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

the class CDatabaseNodeTest method setUp.

@Before
public void setUp() throws IllegalArgumentException, SecurityException, FileReadException, CouldntLoadDataException, CouldntSaveDataException, LoadCancelledException {
    ConfigManager.instance().read();
    m_database = new MockDatabase(m_provider);
    m_project = new CProject(1, "Mock Project", "Mock Project Description", new Date(), new Date(), 0, new ArrayList<DebuggerTemplate>(), m_provider);
    m_project.load();
    m_addressSpace = m_project.getContent().createAddressSpace("Address Space");
    final CProjectTreeModel model = new CProjectTreeModel(m_tree);
    model.setRoot(new DefaultMutableTreeNode());
    m_tree.setModel(model);
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CProjectTreeModel(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.CProjectTreeModel) ArrayList(java.util.ArrayList) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Date(java.util.Date) Before(org.junit.Before)

Aggregations

CProject (com.google.security.zynamics.binnavi.disassembly.CProject)28 Test (org.junit.Test)15 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)12 Date (java.util.Date)10 ArrayList (java.util.ArrayList)9 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)8 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)8 Before (org.junit.Before)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)5 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)3 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)3 CProjectTreeModel (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.CProjectTreeModel)3 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)2