test broken because overlapping (is failing in master)

This commit is contained in:
Claudio Barril 2014-12-21 14:33:11 -03:00
parent 9e08a50c2d
commit ff6ff266c5

View File

@ -10,37 +10,37 @@ describe("Free Test Suite", function() {
}); });
}); });
it("avoidCollisionTest", function () { function branchCollision(treeSet, node, heightById) {
var children = treeSet.getChildren(node);
var childOfRootNode = treeSet._rootNodes.contains(node);
function branchCollision(treeSet, node, heightById) { _.each(children, function(child) {
var children = treeSet.getChildren(node); var siblings = treeSet.getSiblings(child);
var childOfRootNode = treeSet._rootNodes.contains(node); if (childOfRootNode) {
siblings = siblings.filter(function(sibling) {
_.each(children, function(child) { return (child.getOrder() % 2) == (sibling.getOrder() % 2);
var siblings = treeSet.getSiblings(child); });
if (childOfRootNode) { }
siblings = siblings.filter(function(sibling) { _.each(siblings, function(sibling) {
return (child.getOrder() % 2) == (sibling.getOrder() % 2); branchesOverlap(child, sibling, heightById);
});
}
_.each(siblings, function(sibling) {
branchesOverlap(child, sibling, heightById);
}, this);
}, this); }, this);
}, this);
_.each(children, function(child) { _.each(children, function(child) {
branchCollision(treeSet, child, heightById); branchCollision(treeSet, child, heightById);
}, this); }, this);
} }
function branchesOverlap(branchA, branchB, heightById) { function branchesOverlap(branchA, branchB, heightById) {
var topA = branchA.getPosition().y - heightById[branchA.getId()]/2; var topA = branchA.getPosition().y - heightById[branchA.getId()]/2;
var bottomA = branchA.getPosition().y + heightById[branchA.getId()]/2; var bottomA = branchA.getPosition().y + heightById[branchA.getId()]/2;
var topB = branchB.getPosition().y - heightById[branchB.getId()]/2; var topB = branchB.getPosition().y - heightById[branchB.getId()]/2;
var bottomB = branchB.getPosition().y + heightById[branchB.getId()]/2; var bottomB = branchB.getPosition().y + heightById[branchB.getId()]/2;
expect([bottomA, topA]).toNotBeBranchesOverlap([bottomB,topB]); expect([bottomA, topA]).toNotBeBranchesOverlap([bottomB,topB]);
} }
it("avoidCollisionTree1Test", function () {
var position = {x:0,y:0}; var position = {x:0,y:0};
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE); var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
@ -92,6 +92,55 @@ describe("Free Test Suite", function() {
}); });
//FIXME: This is broken in master. This configuration has two topics overlapping.
it("avoidCollisionTree2Test", function () {
var position = {x:0,y:0};
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
// Prepare a sample graph ...
manager.addNode(1, TestSuite.NODE_SIZE, position);
manager.addNode(2, TestSuite.NODE_SIZE, position);
manager.addNode(3, TestSuite.NODE_SIZE, position);
manager.addNode(4, TestSuite.NODE_SIZE, position);
manager.addNode(5, TestSuite.NODE_SIZE, position);
manager.addNode(6, TestSuite.NODE_SIZE, position);
manager.addNode(7, TestSuite.NODE_SIZE, position);
manager.addNode(8, TestSuite.NODE_SIZE, position);
manager.addNode(9, TestSuite.NODE_SIZE, position);
manager.addNode(10, TestSuite.NODE_SIZE, position);
manager.addNode(11, TestSuite.NODE_SIZE, position);
manager.addNode(12, TestSuite.NODE_SIZE, position);
manager.addNode(13, TestSuite.NODE_SIZE, position);
manager.addNode(14, TestSuite.NODE_SIZE, position);
manager.addNode(15, TestSuite.NODE_SIZE, position);
manager.addNode(16, TestSuite.NODE_SIZE, position);
manager.addNode(17, TestSuite.NODE_SIZE, position);
manager.addNode(18, TestSuite.NODE_SIZE, position);
manager.addNode(19, TestSuite.NODE_SIZE, position);
manager.addNode(20, TestSuite.NODE_SIZE, position);
manager.addNode(21, TestSuite.NODE_SIZE, position);
manager.addNode(22, TestSuite.NODE_SIZE, position);
manager.connectNode(0,1,0).connectNode(0,2,1).connectNode(0,3,2).connectNode(0,4,3);
manager.connectNode(4,21,0).connectNode(4,22,0);
manager.connectNode(1,5,0);
manager.connectNode(5,6,0).connectNode(6,8,0).connectNode(8,9,0);
manager.connectNode(5,7,1).connectNode(7,10,0);
manager.connectNode(3,11,0).connectNode(11,14,0).connectNode(14,18,0).connectNode(14,19,1).connectNode(14,20,2);
manager.connectNode(3,12,1).connectNode(12,15,0).connectNode(12,16,1).connectNode(12,17,2);
manager.connectNode(3,13,2);
manager.layout(true);
var treeSet = manager._treeSet;
_.each(treeSet._rootNodes, function(rootNode) {
var heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode);
branchCollision(treeSet, rootNode, heightById);
}, this);
});
it("predictTest", function () { it("predictTest", function () {
var position = {x:0,y:0}; var position = {x:0,y:0};
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE); var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);