Search in sources :

Example 31 with MockSqlProvider

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

the class DebuggerTemplateManagerTest method testLifeCycle.

@Test
public void testLifeCycle() 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 template = manager.createDebuggerTemplate("Hannes", "Host", 123);
    assertEquals(1, internalManager.debuggerCount());
    assertEquals(1, manager.getDebuggerTemplateCount());
    assertEquals(1, manager.getDebuggerTemplates().size());
    assertEquals("Hannes", internalManager.getDebugger(0).getName());
    assertEquals("Host", internalManager.getDebugger(0).getHost());
    assertEquals(123, internalManager.getDebugger(0).getPort());
    assertEquals("Hannes", manager.getDebuggerTemplate(0).getName());
    assertEquals("Host", manager.getDebuggerTemplate(0).getHost());
    assertEquals(123, manager.getDebuggerTemplate(0).getPort());
    manager.deleteDebugger(template);
    assertEquals(0, internalManager.debuggerCount());
    assertEquals(0, manager.getDebuggerTemplateCount());
    assertEquals("addedDebuggerTemplate;deletedDebuggerTemplate;", listener.events);
    manager.removeListener(listener);
}
Also used : MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Test(org.junit.Test)

Example 32 with MockSqlProvider

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

the class DebuggerTemplateManagerTest method testConstructor.

@Test
public void testConstructor() {
    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);
    assertEquals("Debugger Template Manager (0 templates)", manager.toString());
}
Also used : MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Test(org.junit.Test)

Example 33 with MockSqlProvider

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

the class DebuggerTemplateTest method testSetPort.

@Test
public void testSetPort() throws CouldntSaveDataException, com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException {
    final MockDebuggerTemplateListener listener = new MockDebuggerTemplateListener();
    final com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate internalTemplate = new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Name", "Host", 123, new MockSqlProvider());
    final DebuggerTemplate template = new DebuggerTemplate(internalTemplate);
    template.addListener(listener);
    template.setPort(222);
    assertEquals(222, template.getPort());
    assertEquals(222, internalTemplate.getPort());
    assertEquals("changedPort;", listener.events);
    internalTemplate.setPort(223);
    assertEquals(223, template.getPort());
    assertEquals(223, internalTemplate.getPort());
    assertEquals("changedPort;changedPort;", listener.events);
    template.removeListener(listener);
}
Also used : MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Test(org.junit.Test)

Example 34 with MockSqlProvider

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

the class FunctionBlockTest method testConstructor.

@Test
public void testConstructor() {
    final MockSqlProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
    final CFunction parentFunction = 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 Function function = new Function(ModuleFactory.get(), parentFunction);
    final FunctionBlock block = new FunctionBlock(function);
    assertEquals(function, block.getFunction());
    assertEquals("Function Block ['123 Mock Function']", block.toString());
}
Also used : CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) 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 35 with MockSqlProvider

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

the class FunctionEdgeTest method testConstructor.

@Test
public void testConstructor() {
    final MockSqlProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
    final CFunction parentFunction = 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 Function function = new Function(ModuleFactory.get(), parentFunction);
    final FunctionBlock block = new FunctionBlock(function);
    final FunctionBlock childBlock = new FunctionBlock(function);
    final FunctionEdge edge = new FunctionEdge(block, childBlock);
    assertEquals("Function Edge [Mock Function -> Mock Function]", edge.toString());
    assertEquals(block, edge.getSource());
    assertEquals(childBlock, edge.getTarget());
    assertEquals(0, block.getParents().size());
    assertEquals(1, block.getChildren().size());
    assertEquals(childBlock, block.getChildren().get(0));
    assertEquals(0, childBlock.getChildren().size());
    assertEquals(1, childBlock.getParents().size());
    assertEquals(block, childBlock.getParents().get(0));
}
Also used : CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) 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)

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