Search in sources :

Example 96 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class CAddressSpaceNodeTest method testLoaded.

@Test
public void testLoaded() throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException, LoadCancelledException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    m_addressSpace.load();
    final CAddressSpaceNode node = new CAddressSpaceNode(m_tree, new DefaultMutableTreeNode(), m_database, m_project, m_addressSpace, m_container);
    assertEquals("Address Space (0)", node.toString());
    final MockModule unloadedModule = new MockModule(m_provider, false);
    m_addressSpace.getContent().addModule(new MockModule(m_provider, true));
    m_addressSpace.getContent().addModule(unloadedModule);
    assertEquals("Address Space (2)", node.toString());
    assertEquals(2, node.getChildCount());
    m_addressSpace.getContent().removeModule(unloadedModule);
    assertEquals("Address Space (1)", node.toString());
    assertEquals(1, node.getChildCount());
    node.dispose();
    m_container.dispose();
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")) == null);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_project, "m_listeners"), "m_listeners")).isEmpty());
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_addressSpace, "m_listeners"), "m_listeners")).isEmpty());
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ZyGraphBuilderManager.instance(), "m_listeners"), "m_listeners")) == null);
}
Also used : CAddressSpaceNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.CAddressSpaceNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Test(org.junit.Test)

Example 97 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class CAddressSpaceNodeTest method testUnloadedClosed.

@Test
public void testUnloadedClosed() throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException, LoadCancelledException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final CAddressSpaceNode node = new CAddressSpaceNode(m_tree, new DefaultMutableTreeNode(), m_database, m_project, m_addressSpace, m_container);
    assertEquals("Address Space (?)", node.toString());
    m_addressSpace.load();
    assertEquals("Address Space (0)", node.toString());
    final MockModule unloadedModule = new MockModule(m_provider, false);
    m_addressSpace.getContent().addModule(new MockModule(m_provider, true));
    m_addressSpace.getContent().addModule(unloadedModule);
    assertEquals("Address Space (2)", node.toString());
    assertEquals(2, node.getChildCount());
    m_addressSpace.getContent().removeModule(unloadedModule);
    assertEquals("Address Space (1)", node.toString());
    assertEquals(1, node.getChildCount());
    m_addressSpace.close();
    node.dispose();
    m_container.dispose();
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")) == null);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_project, "m_listeners"), "m_listeners")).isEmpty());
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_addressSpace, "m_listeners"), "m_listeners")).isEmpty());
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ZyGraphBuilderManager.instance(), "m_listeners"), "m_listeners")) == null);
}
Also used : CAddressSpaceNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.CAddressSpaceNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Test(org.junit.Test)

Example 98 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class CAddressSpaceNodeTest method testUnloaded.

@Test
public void testUnloaded() throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException, LoadCancelledException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final CAddressSpaceNode node = new CAddressSpaceNode(m_tree, new DefaultMutableTreeNode(), m_database, m_project, m_addressSpace, m_container);
    assertEquals("Address Space (?)", node.toString());
    m_addressSpace.load();
    assertEquals("Address Space (0)", node.toString());
    final MockModule unloadedModule = new MockModule(m_provider, false);
    m_addressSpace.getContent().addModule(new MockModule(m_provider, true));
    m_addressSpace.getContent().addModule(unloadedModule);
    assertEquals("Address Space (2)", node.toString());
    assertEquals(2, node.getChildCount());
    m_addressSpace.getContent().removeModule(unloadedModule);
    assertEquals("Address Space (1)", node.toString());
    assertEquals(1, node.getChildCount());
    node.dispose();
    m_container.dispose();
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")) == null);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_project, "m_listeners"), "m_listeners")).isEmpty());
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_addressSpace, "m_listeners"), "m_listeners")).isEmpty());
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ZyGraphBuilderManager.instance(), "m_listeners"), "m_listeners")) == null);
}
Also used : CAddressSpaceNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.CAddressSpaceNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Test(org.junit.Test)

Aggregations

MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)98 Test (org.junit.Test)90 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)45 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)32 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)26 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)24 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)14 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)14 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)13 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)13 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)12 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 CCodeBookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmarkManager)12 MockAddress (com.google.security.zynamics.zylib.disassembly.MockAddress)12 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)11 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)11 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)10 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)10 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)10 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)9