Search in sources :

Example 21 with Database

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

the class DatabaseTest method testViewTagManager.

@Test
public void testViewTagManager() {
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    final TagManager manager1 = database.getViewTagManager();
    final TagManager manager2 = database.getViewTagManager();
    assertNotNull(manager1);
    assertEquals(manager1, manager2);
}
Also used : TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) 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 22 with Database

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

the class DatabaseTest method testSetDescription.

@Test
public void testSetDescription() {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    database.setDescription("Fark 1");
    assertEquals("changedDescription;", listener.events);
    assertEquals("Fark 1", database.getDescription());
    assertEquals("Fark 1", mockDatabase.getConfiguration().getDescription());
    mockDatabase.getConfiguration().setDescription("Fark 2");
    assertEquals("changedDescription;changedDescription;", listener.events);
    assertEquals("Fark 2", database.getDescription());
    assertEquals("Fark 2", mockDatabase.getConfiguration().getDescription());
    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 23 with Database

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

the class DatabaseTest method testSetUser.

@Test
public void testSetUser() {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    database.setUser("Fark 1");
    assertEquals("changedUser;", listener.events);
    assertEquals("Fark 1", database.getUser());
    assertEquals("Fark 1", mockDatabase.getConfiguration().getUser());
    mockDatabase.getConfiguration().setUser("Fark 2");
    assertEquals("changedUser;changedUser;", listener.events);
    assertEquals("Fark 2", database.getUser());
    assertEquals("Fark 2", mockDatabase.getConfiguration().getUser());
    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 24 with Database

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

the class CModuleNodeMenuBuilder method getPluginModules.

/**
   * Returns the API module objects for the modules for which the menu was built.
   *
   * @return The API module objects.
   */
private List<Module> getPluginModules() {
    final DatabaseManager manager = PluginInterface.instance().getDatabaseManager();
    for (final Database database : manager) {
        if (database.getNative() == m_database) {
            final List<Module> allModules = database.getModules();
            final List<Module> menuModules = new ArrayList<Module>();
            for (final INaviModule module : m_modules) {
                menuModules.add(ObjectFinders.getObject(module, allModules));
            }
            return menuModules;
        }
    }
    throw new IllegalStateException("IE01165: Unknown database");
}
Also used : DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) ArrayList(java.util.ArrayList) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module)

Example 25 with Database

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

the class CProjectNodeMenuBuilder method getPluginProjects.

/**
   * Returns the API project objects for the projects for which the menu was built.
   * 
   * @return The API project objects.
   */
private List<Project> getPluginProjects() {
    final DatabaseManager manager = PluginInterface.instance().getDatabaseManager();
    for (final Database database : manager) {
        if (database.getNative() == m_database) {
            final List<Project> allProjects = database.getProjects();
            final List<Project> menuProjects = new ArrayList<Project>();
            for (final INaviProject project : m_projects) {
                menuProjects.add(ObjectFinders.getObject(project, allProjects));
            }
            return menuProjects;
        }
    }
    throw new IllegalStateException("IE01168: Unknown database");
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) CProject(com.google.security.zynamics.binnavi.disassembly.CProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) ArrayList(java.util.ArrayList)

Aggregations

Database (com.google.security.zynamics.binnavi.API.disassembly.Database)26 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)19 Test (org.junit.Test)15 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)9 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)8 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)7 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)7 Tree (com.google.security.zynamics.zylib.types.trees.Tree)7 Project (com.google.security.zynamics.binnavi.API.disassembly.Project)6 IDatabase (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)6 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)6 DatabaseManager (com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)3 Date (java.util.Date)3 Before (org.junit.Before)3 View (com.google.security.zynamics.binnavi.API.disassembly.View)2 CDatabase (com.google.security.zynamics.binnavi.Database.CDatabase)2 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)2