Search in sources :

Example 6 with MockAddress

use of com.google.security.zynamics.zylib.disassembly.MockAddress in project binnavi by google.

the class CBookmarkFunctionsTest method test3DeleteBookmarksNoManager.

@Test
public void test3DeleteBookmarksNoManager() {
    final CCodeBookmarkManager bookmarkManager = new CCodeBookmarkManager();
    final MockAddress mockAddress = new MockAddress();
    final MockModule mockModule = new MockModule();
    CBookmarkFunctions.addBookmark(bookmarkManager, mockModule, mockAddress);
    final int[] foo = { 0 };
    try {
        CBookmarkFunctions.deleteBookmarks(null, foo);
        fail();
    } catch (final NullPointerException e) {
    }
}
Also used : CCodeBookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmarkManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) Test(org.junit.Test)

Example 7 with MockAddress

use of com.google.security.zynamics.zylib.disassembly.MockAddress in project binnavi by google.

the class CBookmarksTableModelTest method test2getValueAt.

@Test
public void test2getValueAt() {
    final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final CBookmarkTableModel model = new CBookmarkTableModel(debuggerProvider);
    final IAddress address = new MockAddress();
    final CBookmark bookmark = new CBookmark(address, "foo");
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_0_SET);
    debuggerProvider.addDebugger(debugger);
    final BookmarkManager bookmarkManager = debugger.getBookmarkManager();
    bookmarkManager.addBookmark(bookmark);
    assertEquals(1, bookmarkManager.getNumberOfBookmarks());
    assertEquals("foo", model.getValueAt(0, 2));
    assertEquals(address.toHexString(), model.getValueAt(0, 1));
    assertEquals(debugger.getPrintableString(), model.getValueAt(0, 0));
    final int[] rows = { 0 };
    CBookmarkFunctions.deleteBookmarks(debuggerProvider, rows);
    assertEquals(0, bookmarkManager.getNumberOfBookmarks());
    model.dispose();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) CBookmarkTableModel(com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager) Test(org.junit.Test)

Example 8 with MockAddress

use of com.google.security.zynamics.zylib.disassembly.MockAddress in project binnavi by google.

the class CCodeBookmarkTableModelTest method test9checkRemoveListeners.

@Test
public void test9checkRemoveListeners() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final CCodeBookmarkManager bookmarkManager = new CCodeBookmarkManager();
    final CCodeBookmarkTableModel tableModel = new CCodeBookmarkTableModel(bookmarkManager);
    final LinkedHashSet<?> m_daListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(bookmarkManager, "m_listeners"), "m_listeners");
    assertEquals(1, m_daListeners.size());
    final CCodeBookmark bookmark = new CCodeBookmark(new MockModule(), new MockAddress(), "burzel");
    bookmarkManager.addBookmark(bookmark);
    final LinkedHashSet<?> m_bmListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(bookmark, "m_listeners"), "m_listeners");
    assertEquals(1, m_bmListeners.size());
    tableModel.dispose();
    assertTrue(m_daListeners.isEmpty());
    assertTrue(m_bmListeners.isEmpty());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CCodeBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark) CCodeBookmarkTableModel(com.google.security.zynamics.binnavi.Gui.CodeBookmarks.CCodeBookmarkTableModel) CCodeBookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmarkManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) Test(org.junit.Test)

Example 9 with MockAddress

use of com.google.security.zynamics.zylib.disassembly.MockAddress in project binnavi by google.

the class CProjectContainerTest method testGetViewsWithAddresses.

@Test
public void testGetViewsWithAddresses() throws CouldntLoadDataException {
    final CProjectContainer container = new CProjectContainer(m_database, m_project);
    @SuppressWarnings("unused") final INaviView view = container.createView("view1", "information");
    final UnrelocatedAddress address = new UnrelocatedAddress(new MockAddress());
    final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
    addresses.add(address);
    try {
        container.getViewsWithAddresses(null, true);
        fail();
    } catch (final NullPointerException e) {
    }
// assertNull(container.getViewsWithAddresses(addresses, true));
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) Test(org.junit.Test)

Example 10 with MockAddress

use of com.google.security.zynamics.zylib.disassembly.MockAddress in project binnavi by google.

the class CBoookmarkFunctionsTest method test2DeleteBookmarks.

@Test
public void test2DeleteBookmarks() {
    final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final CBookmarkTableModel model = new CBookmarkTableModel(debuggerProvider);
    final CBookmark bookmark = new CBookmark(new MockAddress(), "foo");
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_0_SET);
    debuggerProvider.addDebugger(debugger);
    final BookmarkManager bookmarkManager = debugger.getBookmarkManager();
    bookmarkManager.addBookmark(bookmark);
    assertEquals(1, bookmarkManager.getNumberOfBookmarks());
    final int[] rows = { 0 };
    CBookmarkFunctions.deleteBookmarks(debuggerProvider, rows);
    assertEquals(0, bookmarkManager.getNumberOfBookmarks());
    model.dispose();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) CBookmarkTableModel(com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockAddress(com.google.security.zynamics.zylib.disassembly.MockAddress) BookmarkManager(com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager) Test(org.junit.Test)

Aggregations

MockAddress (com.google.security.zynamics.zylib.disassembly.MockAddress)15 Test (org.junit.Test)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)12 CCodeBookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmarkManager)12 CCodeBookmarkTableModel (com.google.security.zynamics.binnavi.Gui.CodeBookmarks.CCodeBookmarkTableModel)8 CCodeBookmark (com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark)8 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)2 CBookmarkTableModel (com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel)2 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)2 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)2 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)2 BookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)2 CBookmark (com.google.security.zynamics.binnavi.models.Bookmarks.memory.CBookmark)2 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)1 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)1 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)1 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)1 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)1 IFilledList (com.google.security.zynamics.zylib.types.lists.IFilledList)1 LinkedHashSet (java.util.LinkedHashSet)1