use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class ModuleHelpersTest method testGetFunction_3.
@Test
public void testGetFunction_3() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final Database database = new Database(new MockDatabase());
final MockModule mockModule = new MockModule();
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);
new CFunctionContainer(mockModule, Lists.<INaviFunction>newArrayList(parentFunction));
CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), parentFunction);
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);
assertEquals(module.getFunctions().get(0), ModuleHelpers.getFunction(module, "Mock Function"));
assertNull(ModuleHelpers.getFunction(module, ""));
try {
ModuleHelpers.getFunction(null, (String) null);
fail();
} catch (final NullPointerException e) {
}
try {
ModuleHelpers.getFunction(module, (String) null);
fail();
} catch (final NullPointerException e) {
}
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule 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);
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule 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());
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class CCodeBookmarkTableModelTest method test6getColumnName.
@Test
public void test6getColumnName() {
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("Module", tableModel.getColumnName(0));
assertEquals("Address", tableModel.getColumnName(1));
assertEquals("Description", tableModel.getColumnName(2));
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class CCodeBookmarkTableModelTest method test3setValueAtFail.
@Test
public void test3setValueAtFail() {
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));
try {
tableModel.setValueAt("working", 0, 1);
fail();
} catch (final IllegalArgumentException e) {
}
}
Aggregations