Search in sources :

Example 91 with MockSqlProvider

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

the class AddressSpaceTest method setUp.

@Before
public void setUp() {
    final MockSqlProvider provider = new MockSqlProvider();
    creationDate = new Date();
    modificationDate = new Date();
    final MockDatabase mockDb = new MockDatabase();
    database = new Database(mockDb);
    internalAddressSpace = new CAddressSpace(1, "Mock Space", "Mock Space Description", creationDate, modificationDate, new LinkedHashMap<INaviModule, IAddress>(), null, provider, new MockProject());
    addressSpace = new AddressSpace(database, null, internalAddressSpace);
    final Date creationDate = new Date();
    final Date modificationDate = new Date();
    final CModule internalModule = new CModule(123, "Name", "Comment", creationDate, modificationDate, "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    mockDb.getContent().addModule(internalModule);
    final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    module = new Module(database, internalModule, nodeTagManager, viewTagManager);
}
Also used : CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Before(org.junit.Before)

Example 92 with MockSqlProvider

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

the class AddressSpaceTest method testConstructorAlternative.

@Test
public void testConstructorAlternative() throws com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException, com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException, LoadCancelledException {
    final MockSqlProvider provider = new MockSqlProvider();
    final MockDatabase mockDb = new MockDatabase(provider);
    final Database database = new Database(mockDb);
    final com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate template = new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "", "", 0, provider);
    mockDb.getContent().getDebuggerTemplateManager().addDebugger(template);
    final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    mockDb.getContent().addModule(internalModule);
    final CAddressSpace internalAddressSpace = new CAddressSpace(1, "Mock Space", "Mock Space Description", new Date(), new Date(), new LinkedHashMap<INaviModule, IAddress>(), null, provider, new MockProject());
    internalAddressSpace.load();
    internalAddressSpace.getConfiguration().setDebuggerTemplate(template);
    internalAddressSpace.getContent().addModule(internalModule);
    final Project project = ProjectFactory.get();
    final AddressSpace addressSpace = new AddressSpace(database, project, internalAddressSpace);
    assertEquals(1, addressSpace.getModules().size());
    assertNotNull(addressSpace.getDebuggerTemplate());
    assertNotNull(addressSpace.getDebugger());
}
Also used : Date(java.util.Date) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Test(org.junit.Test)

Example 93 with MockSqlProvider

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

the class CodeNodeTest method setUp.

@Before
public void setUp() {
    final Database database = new Database(new MockDatabase());
    final MockModule mockModule = new MockModule();
    final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final MockView mockView = new MockView();
    final View view = new View(module, mockView, nodeTagManager, viewTagManager);
    final MockSqlProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    final CFunction internalFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
    final CComment m_globalComment = new CComment(null, CommonTestObjects.TEST_USER_1, null, "Global Comment");
    final INaviCodeNode codeNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, false, Lists.<IComment>newArrayList(m_globalComment), internalFunction, new HashSet<CTag>(), new MockSqlProvider());
    codeNode.addInstruction(new CInstruction(true, internalModule, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider), null);
    m_node = new CodeNode(view, codeNode, nodeTagManager);
}
Also used : MockView(com.google.security.zynamics.binnavi.disassembly.MockView) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) ArrayList(java.util.ArrayList) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Before(org.junit.Before)

Example 94 with MockSqlProvider

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

the class OperandTest method testCreate.

@Test
public void testCreate() {
    final Database database = new Database(new MockDatabase());
    final MockModule mockModule = new MockModule();
    final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final COperandTreeNode rootNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_SIZE_PREFIX_ID, "b4", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
    final COperandTreeNode childNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
    COperandTreeNode.link(rootNode, childNode);
    final OperandExpression root = new OperandExpression(rootNode);
    final Operand operand = Operand.create(module, root);
    assertEquals("dword", operand.getRootNode().getValue());
    assertEquals(1, operand.getRootNode().getChildren().size());
    assertEquals("eax", operand.getRootNode().getChildren().get(0).getValue());
    assertEquals("eax", operand.toString());
}
Also used : MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) IReference(com.google.security.zynamics.zylib.disassembly.IReference) Test(org.junit.Test)

Example 95 with MockSqlProvider

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

the class DebuggerTemplateManagerTest method testDispose.

@Test
public void testDispose() throws CouldntSaveDataException, CouldntDeleteException {
    final MockDebuggerTemplateManagerListener listener = new MockDebuggerTemplateManagerListener();
    final com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplateManager internalManager = new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplateManager(new MockSqlProvider());
    final DebuggerTemplateManager manager = new DebuggerTemplateManager(internalManager);
    manager.addListener(listener);
    final DebuggerTemplate template1 = manager.createDebuggerTemplate("Hannes", "Host", 123);
    @SuppressWarnings("unused") final DebuggerTemplate template2 = manager.createDebuggerTemplate("Hannes", "Host", 123);
    manager.deleteDebugger(template1);
    manager.dispose();
}
Also used : MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Test(org.junit.Test)

Aggregations

MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)111 Test (org.junit.Test)82 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)55 Date (java.util.Date)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)44 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)42 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)32 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)25 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)24 Before (org.junit.Before)23 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)17 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)17 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)14 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)13 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)13 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)12 Tree (com.google.security.zynamics.zylib.types.trees.Tree)12 ArrayList (java.util.ArrayList)12