Search in sources :

Example 1 with CCodeBookmark

use of com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark in project binnavi by google.

the class CCodeBookmarkTableModelTest method test5getValueAtFail.

@Test
public void test5getValueAtFail() {
    final CCodeBookmarkManager bookmarkManager = new CCodeBookmarkManager();
    final CCodeBookmarkTableModel tableModel = new CCodeBookmarkTableModel(bookmarkManager);
    final CCodeBookmark bookmark = new CCodeBookmark(new MockModule(), new MockAddress(), "burzel");
    bookmarkManager.addBookmark(bookmark);
    try {
        tableModel.getValueAt(0, 4);
        fail();
    } catch (final IllegalArgumentException e) {
    }
}
Also used : 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 2 with CCodeBookmark

use of com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark in project binnavi by google.

the class CCodeBookmarkTableModelTest method test2setValueAtWorking.

@Test
public void test2setValueAtWorking() {
    final CCodeBookmarkManager bookmarkManager = new CCodeBookmarkManager();
    final CCodeBookmarkTableModel tableModel = new CCodeBookmarkTableModel(bookmarkManager);
    final CCodeBookmark bookmark = new CCodeBookmark(new MockModule(), new MockAddress(), "burzel");
    bookmarkManager.addBookmark(bookmark);
    assertEquals("burzel", tableModel.getValueAt(0, 2));
    tableModel.setValueAt("working", 0, 2);
    assertEquals(1, tableModel.getRowCount());
    assertEquals("working", tableModel.getValueAt(0, 2));
}
Also used : 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 3 with CCodeBookmark

use of com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark in project binnavi by google.

the class CCodeBookmarkTableModelTest method test8checkEditable.

@Test
public void test8checkEditable() {
    final CCodeBookmarkManager bookmarkManager = new CCodeBookmarkManager();
    final CCodeBookmarkTableModel tableModel = new CCodeBookmarkTableModel(bookmarkManager);
    final CCodeBookmark bookmark = new CCodeBookmark(new MockModule(), new MockAddress(), "burzel");
    bookmarkManager.addBookmark(bookmark);
    assertFalse(tableModel.isCellEditable(0, 0));
    assertFalse(tableModel.isCellEditable(0, 1));
    assertTrue(tableModel.isCellEditable(0, 2));
}
Also used : 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 4 with CCodeBookmark

use of com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark 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 5 with CCodeBookmark

use of com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark in project binnavi by google.

the class CBookmarkFunctions method deleteBookmarks.

/**
   * Deletes a list of bookmarks.
   *
   * @param manager Code bookmark manager from which the bookmarks are deleted.
   * @param rows Indices of the table rows of the bookmarks to delete.
   */
public static void deleteBookmarks(final CCodeBookmarkManager manager, final int[] rows) {
    Preconditions.checkNotNull(manager, "IE01262: Manager argument can not be null");
    Preconditions.checkNotNull(rows, "IE01263: Rows argument can not be null");
    final List<CCodeBookmark> bookmarks = new ArrayList<CCodeBookmark>();
    for (final int row : rows) {
        bookmarks.add(manager.get(row));
    }
    for (final CCodeBookmark bookmark : bookmarks) {
        manager.removeBookmark(bookmark);
    }
}
Also used : CCodeBookmark(com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark) ArrayList(java.util.ArrayList)

Aggregations

CCodeBookmark (com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmark)9 CCodeBookmarkTableModel (com.google.security.zynamics.binnavi.Gui.CodeBookmarks.CCodeBookmarkTableModel)8 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)8 CCodeBookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmarkManager)8 MockAddress (com.google.security.zynamics.zylib.disassembly.MockAddress)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1