use of com.google.security.zynamics.binnavi.disassembly.MockView in project binnavi by google.
the class GroupNodeTest method testConstructor.
@Test
public void testConstructor() {
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 INaviGroupNode internalGroupNode = new CGroupNode(0, 0, 0, 0, 0, Color.RED, false, false, new HashSet<CTag>(), new ArrayList<IComment>(), false, new MockSqlProvider());
final GroupNode node = new GroupNode(view, internalGroupNode, viewTagManager);
assertEquals("Group Node [0 elements]", node.toString());
}
use of com.google.security.zynamics.binnavi.disassembly.MockView in project binnavi by google.
the class GroupNodeTest method testSetText.
@Test
public void testSetText() throws CouldntSaveDataException, com.google.security.zynamics.binnavi.API.disassembly.CouldntSaveDataException, CouldntLoadDataException {
final Database database = new Database(new MockDatabase());
final SQLProvider provider = new MockSqlProvider();
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 INaviGroupNode internalGroupNode = new CGroupNode(0, 0, 0, 0, 0, Color.RED, false, false, new HashSet<CTag>(), new ArrayList<IComment>(), false, provider);
final GroupNode node = new GroupNode(view, internalGroupNode, viewTagManager);
final MockGroupNodeListener listener = new MockGroupNodeListener();
final CUserManager userManager = CUserManager.get(provider);
final IUser user = userManager.addUser(" TEST APPEND GROUP NODE COMMENT ");
userManager.setCurrentActiveUser(user);
node.addListener(listener);
final List<IComment> comments = node.appendComment("Hannes");
assertEquals("appendedComment;", listener.events);
assertEquals(comments, node.getComment());
node.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.disassembly.MockView in project binnavi by google.
the class ModuleHelpersTest method testGetFunction_1.
@Test
public void testGetFunction_1() {
final Database database = new Database(new MockDatabase());
@SuppressWarnings("unused") 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);
try {
internalModule.load();
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
} catch (final LoadCancelledException exception) {
CUtilityFunctions.logException(exception);
}
@SuppressWarnings("unused") 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 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, internalModule, nodeTagManager, viewTagManager);
assertEquals(module.getFunctions().get(0), ModuleHelpers.getFunction(module, 0x123));
assertNull(ModuleHelpers.getFunction(module, 0x1235));
try {
ModuleHelpers.getFunction(null, -1);
fail();
} catch (final NullPointerException e) {
}
try {
ModuleHelpers.getFunction(module, -1);
fail();
} catch (final IllegalArgumentException e) {
}
}
use of com.google.security.zynamics.binnavi.disassembly.MockView 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.MockView in project binnavi by google.
the class ViewTest method testCreateCodeNode.
@Test
public void testCreateCodeNode() throws PartialLoadException, com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException {
final MockViewListener listener = new MockViewListener();
m_view.addListener(listener);
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, m_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, m_provider);
final Function function = new Function(module, parentFunction);
final List<Instruction> instructions = Lists.newArrayList(new Instruction(new MockInstruction()));
m_view.load();
final CodeNode node = m_view.createCodeNode(function, instructions);
assertEquals(node, m_view.getGraph().getNodes().get(0));
assertEquals(listener.events, "addedNode;changedGraphType;");
assertEquals(com.google.security.zynamics.binnavi.API.disassembly.GraphType.Flowgraph, m_view.getGraphType());
m_view.removeListener(listener);
}
Aggregations