Search in sources :

Example 1 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class TraceLoggerTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, InvalidDatabaseVersionException {
    final SQLProvider mockProvider = new MockSqlProvider();
    // CDatabase("", "", "", "", "", false,
    final IDatabase internalDatabase = new MockDatabase();
    // false);
    final Database database = new Database(internalDatabase);
    database.load();
    final MockProject mockProject = new MockProject();
    final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
    final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
    final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
    final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
    final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
    final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final Project project = new Project(database, mockProject, nodeTagManager, viewTagManager);
    m_mockModule = new Module(database, mockModule, viewTagManager, nodeTagManager);
    m_debugSettings = new ModuleTargetSettings(m_mockModule.getNative());
    m_mockDebugger = new MockDebugger(m_debugSettings);
    m_mockDebugger.setAddressTranslator(mockModule, new CAddress(0), new CAddress(0x1000));
    final Debugger debugger = new Debugger(m_mockDebugger);
    m_logger = new TraceLogger(debugger, module);
    m_projectLogger = new TraceLogger(debugger, project);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) Project(com.google.security.zynamics.binnavi.API.disassembly.Project) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) Before(org.junit.Before)

Example 2 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class DatabaseTest method testCreateProject.

@Test
public void testCreateProject() throws CouldntSaveDataException, CouldntDeleteException {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    final Project newProject = database.createProject("Hannes");
    mockDatabase.getContent().addProject("Fork");
    assertEquals("addedProject;addedProject;", listener.events);
    assertEquals(2, database.getProjects().size());
    database.deleteProject(newProject);
    assertEquals("addedProject;addedProject;deletedProject;", listener.events);
    assertEquals(1, database.getProjects().size());
    database.removeListener(listener);
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Example 3 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class DatabaseTest method testGetDebuggerTemplateManager.

@Test
public void testGetDebuggerTemplateManager() {
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    final DebuggerTemplateManager manager1 = database.getDebuggerTemplateManager();
    final DebuggerTemplateManager manager2 = database.getDebuggerTemplateManager();
    assertNotNull(manager1);
    assertEquals(manager1, manager2);
}
Also used : MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) DebuggerTemplateManager(com.google.security.zynamics.binnavi.API.disassembly.DebuggerTemplateManager) Test(org.junit.Test)

Example 4 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class DatabaseTest method testSetDriver.

@Test
public void testSetDriver() {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    database.setDriver("Fark 1");
    assertEquals("changedDriver;", listener.events);
    assertEquals("Fark 1", database.getDriver());
    assertEquals("Fark 1", mockDatabase.getConfiguration().getDriver());
    mockDatabase.getConfiguration().setDriver("Fark 2");
    assertEquals("changedDriver;changedDriver;", listener.events);
    assertEquals("Fark 2", database.getDriver());
    assertEquals("Fark 2", mockDatabase.getConfiguration().getDriver());
    database.removeListener(listener);
}
Also used : MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Example 5 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class DatabaseTest method testDeleteModule.

@Test
public void testDeleteModule() throws CouldntLoadDriverException, CouldntConnectException, InvalidDatabaseException, CouldntInitializeDatabaseException, InvalidDatabaseFormatException, CouldntLoadDataException, InvalidDatabaseVersionException, CouldntDeleteException {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    mockDatabase.getContent().m_modules.add(CModuleFactory.get());
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    database.connect();
    database.load();
    database.deleteModule(database.getModules().get(0));
    assertEquals("openedDatabase;loadedDatabase;deletedModule;", listener.events);
    assertTrue(database.getModules().isEmpty());
}
Also used : MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Aggregations

MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)59 Test (org.junit.Test)31 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)29 Date (java.util.Date)29 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)28 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)24 Before (org.junit.Before)23 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)20 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)19 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)19 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)14 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)13 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)12 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)11 Tree (com.google.security.zynamics.zylib.types.trees.Tree)10 ArrayList (java.util.ArrayList)10 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)9 CProjectTreeModel (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.CProjectTreeModel)8 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)8 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)8