Search in sources :

Example 46 with DebuggerTemplate

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.

the class CDebuggerContainerNodeTest method testUnloaded.

@Test
public void testUnloaded() throws CouldntDeleteException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final DebuggerTemplate debugger1 = new DebuggerTemplate(1, "Debugger 1", "", 0, m_provider);
    final DebuggerTemplate debugger2 = new DebuggerTemplate(2, "Debugger 2", "", 0, m_provider);
    final CDebuggerContainerNode node = new CDebuggerContainerNode(m_tree, m_database);
    assertEquals("Debuggers (0)", node.toString());
    assertEquals(0, node.getChildCount());
    m_database.getContent().getDebuggerTemplateManager().addDebugger(debugger1);
    m_database.getContent().getDebuggerTemplateManager().addDebugger(debugger2);
    assertEquals("Debuggers (2)", node.toString());
    assertEquals(2, node.getChildCount());
    assertEquals("Debugger 1", node.getChildAt(0).toString());
    assertEquals("Debugger 2", node.getChildAt(1).toString());
    m_database.getContent().getDebuggerTemplateManager().removeDebugger(debugger1);
    assertEquals("Debuggers (1)", node.toString());
    assertEquals(1, node.getChildCount());
    assertEquals("Debugger 2", node.getChildAt(0).toString());
    node.dispose();
    assertTrue(((Collection<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")) == null);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database.getContent().getDebuggerTemplateManager(), "listeners"), "m_listeners")).isEmpty());
}
Also used : DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) Test(org.junit.Test)

Example 47 with DebuggerTemplate

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.

the class CModuleOverviewPanelTest method testChangingDebugger.

@Test
public void testChangingDebugger() throws CouldntSaveDataException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    final DebuggerTemplate template1 = new DebuggerTemplate(1, "A", "", 0, m_provider);
    final DebuggerTemplate template2 = new DebuggerTemplate(1, "B", "", 0, m_provider);
    m_database.getContent().getDebuggerTemplateManager().addDebugger(template1);
    m_database.getContent().getDebuggerTemplateManager().addDebugger(template2);
    m_project.getConfiguration().addDebugger(template1);
    m_project.getConfiguration().addDebugger(template2);
    sleep();
    assertFalse(m_saveButton.isEnabled());
    m_debuggerCombo.setSelectedIndex(3);
    sleep();
    assertTrue(m_saveButton.isEnabled());
    m_module.getConfiguration().setDebuggerTemplate(template2);
    sleep();
    assertFalse(m_saveButton.isEnabled());
    m_module.getConfiguration().setDebuggerTemplate(template1);
    sleep();
    assertFalse(m_saveButton.isEnabled());
    testListenersRemoved();
}
Also used : DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) Test(org.junit.Test)

Example 48 with DebuggerTemplate

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.

the class CModuleContainerNodeTest method testLoaded.

@Test
public void testLoaded() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final CRawModule rawModule = new CRawModule(1, "", 0, false, m_provider);
    final CModule module1 = new CModule(123, "Module 1", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, m_provider), rawModule, Integer.MAX_VALUE, false, m_provider);
    final CModule module2 = new CModule(123, "Module 2", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, m_provider), rawModule, Integer.MAX_VALUE, false, m_provider);
    m_database.getContent().addModule(module1);
    m_database.getContent().addModule(module2);
    final CModuleContainerNode node = new CModuleContainerNode(m_tree, m_database);
    assertEquals("Modules (2)", node.toString());
    assertEquals(2, node.getChildCount());
    assertEquals("Module 1 (55/66)", node.getChildAt(0).toString());
    assertEquals("Module 2 (55/66)", node.getChildAt(1).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 : DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) CRawModule(com.google.security.zynamics.binnavi.disassembly.CRawModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 49 with DebuggerTemplate

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate 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 50 with DebuggerTemplate

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate in project binnavi by google.

the class CDebuggerNodeTest method setUp.

@Before
public void setUp() throws IllegalArgumentException, SecurityException, FileReadException {
    ConfigManager.instance().read();
    m_database = new MockDatabase(m_provider);
    m_template = new DebuggerTemplate(1, "My Debugger", "Bar", 123, m_provider);
    final CProjectTreeModel model = new CProjectTreeModel(m_tree);
    model.setRoot(new DefaultMutableTreeNode());
    m_tree.setModel(model);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) CProjectTreeModel(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.CProjectTreeModel) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Before(org.junit.Before)

Aggregations

DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)55 Test (org.junit.Test)29 Date (java.util.Date)20 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)16 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)16 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)12 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)11 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)11 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)8 ArrayList (java.util.ArrayList)8 Before (org.junit.Before)8 ResultSet (java.sql.ResultSet)7 SQLException (java.sql.SQLException)6 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)5 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)5 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)5 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)4 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)4 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)4