mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Symmetric Sorter Tests asserted
This commit is contained in:
parent
c8d178cb3a
commit
42f2763ec0
@ -122,20 +122,32 @@ mindplot.layout.BalancedTestSuite = new Class({
|
||||
manager.plot("testBalanced13", {width:1000, height:400});
|
||||
|
||||
// Check that everything is ok
|
||||
$assert(manager.find(1).getPosition().x > manager.find(0).getPosition().x, "even order nodes must be at right of central topic");
|
||||
$assert(manager.find(3).getPosition().x > manager.find(0).getPosition().x, "even order nodes must be at right of central topic");
|
||||
$assert(manager.find(5).getPosition().x > manager.find(0).getPosition().x, "even order nodes must be at right of central topic");
|
||||
$assert(manager.find(2).getPosition().x < manager.find(0).getPosition().x, "odd order nodes must be at right of central topic");
|
||||
$assert(manager.find(4).getPosition().x < manager.find(0).getPosition().x, "odd order nodes must be at right of central topic");
|
||||
$assert(manager.find(6).getPosition().x < manager.find(0).getPosition().x, "odd order nodes must be at right of central topic");
|
||||
$assert(manager.find(7).getPosition().x > manager.find(3).getPosition().x, "children of 1st level even order nodes must be to the right");
|
||||
$assert(manager.find(8).getPosition().x > manager.find(7).getPosition().x, "children of 1st level even order nodes must be to the right");
|
||||
$assert(manager.find(9).getPosition().x > manager.find(7).getPosition().x, "children of 1st level even order nodes must be to the right");
|
||||
$assert(manager.find(10).getPosition().x < manager.find(6).getPosition().x, "children of 1st level odd order nodes must be to the left");
|
||||
$assert(manager.find(11).getPosition().x < manager.find(10).getPosition().x, "children of 1st level odd order nodes must be to the left");
|
||||
$assert(manager.find(12).getPosition().x < manager.find(10).getPosition().x, "children of 1st level odd order nodes must be to the left");
|
||||
$assert(manager.find(1).getPosition().x > manager.find(0).getPosition().x,
|
||||
"even order nodes must be at right of central topic");
|
||||
$assert(manager.find(3).getPosition().x > manager.find(0).getPosition().x,
|
||||
"even order nodes must be at right of central topic");
|
||||
$assert(manager.find(5).getPosition().x > manager.find(0).getPosition().x,
|
||||
"even order nodes must be at right of central topic");
|
||||
$assert(manager.find(2).getPosition().x < manager.find(0).getPosition().x,
|
||||
"odd order nodes must be at right of central topic");
|
||||
$assert(manager.find(4).getPosition().x < manager.find(0).getPosition().x,
|
||||
"odd order nodes must be at right of central topic");
|
||||
$assert(manager.find(6).getPosition().x < manager.find(0).getPosition().x,
|
||||
"odd order nodes must be at right of central topic");
|
||||
$assert(manager.find(7).getPosition().x > manager.find(3).getPosition().x,
|
||||
"children of 1st level even order nodes must be to the right");
|
||||
$assert(manager.find(8).getPosition().x > manager.find(7).getPosition().x,
|
||||
"children of 1st level even order nodes must be to the right");
|
||||
$assert(manager.find(9).getPosition().x > manager.find(7).getPosition().x,
|
||||
"children of 1st level even order nodes must be to the right");
|
||||
$assert(manager.find(10).getPosition().x < manager.find(6).getPosition().x,
|
||||
"children of 1st level odd order nodes must be to the left");
|
||||
$assert(manager.find(11).getPosition().x < manager.find(10).getPosition().x,
|
||||
"children of 1st level odd order nodes must be to the left");
|
||||
$assert(manager.find(12).getPosition().x < manager.find(10).getPosition().x,
|
||||
"children of 1st level odd order nodes must be to the left");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testBalancedPredict: function() {
|
||||
@ -173,25 +185,31 @@ mindplot.layout.BalancedTestSuite = new Class({
|
||||
console.log("\tAdded as child of node 0 and dropped at (165, -70):");
|
||||
var prediction1a = manager.predict(0, {x:165, y:-70});
|
||||
this._plotPrediction(graph1, prediction1a);
|
||||
$assert(prediction1a.position.x == 130 && prediction1a.position.y == -100, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1a.position.y < manager.find(1).getPosition().y &&
|
||||
prediction1a.position.x == manager.find(1).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1a.order == 0, "Prediction order should be 0");
|
||||
|
||||
console.log("\tAdded as child of node 0 and dropped at (165, -10):");
|
||||
var prediction1b = manager.predict(0, {x:165, y:-10});
|
||||
this._plotPrediction(graph1, prediction1b);
|
||||
$assert(prediction1b.position.x == 130 && prediction1b.position.y == -30, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1b.position.y > manager.find(1).getPosition().y &&
|
||||
prediction1b.position.y < manager.find(3).getPosition().y &&
|
||||
prediction1b.position.x == manager.find(1).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1b.order == 2, "Prediction order should be 2");
|
||||
|
||||
console.log("\tAdded as child of node 0 and dropped at (145, 15):");
|
||||
var prediction1c = manager.predict(0, {x:145, y:15});
|
||||
this._plotPrediction(graph1, prediction1c);
|
||||
$assert(prediction1c.position.x == 130 && prediction1c.position.y == 30, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1c.position.y > manager.find(3).getPosition().y &&
|
||||
prediction1c.position.y < manager.find(5).getPosition().y &&
|
||||
prediction1c.position.x == manager.find(3).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1c.order == 4, "Prediction order should be 4");
|
||||
|
||||
console.log("\tAdded as child of node 0 and dropped at (145, 70):");
|
||||
var prediction1d = manager.predict(0, {x:145, y:70});
|
||||
this._plotPrediction(graph1, prediction1d);
|
||||
$assert(prediction1d.position.x == 130 && prediction1d.position.y == 100, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1d.position.y > manager.find(5).getPosition().y &&
|
||||
prediction1d.position.x == manager.find(5).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1d.order == 6, "Prediction order should be 6");
|
||||
|
||||
// Graph 2
|
||||
@ -200,27 +218,32 @@ mindplot.layout.BalancedTestSuite = new Class({
|
||||
console.log("\tAdded as child of node 0 and dropped at (-145, -50):");
|
||||
var prediction2a = manager.predict(0, {x:-145, y:-50});
|
||||
this._plotPrediction(graph2, prediction2a);
|
||||
$assert(prediction2a.position.x == -130 && prediction2a.position.y == -80, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2a.position.y < manager.find(2).getPosition().y &&
|
||||
prediction2a.position.x == manager.find(2).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2a.order == 1, "Prediction order should be 1");
|
||||
|
||||
console.log("\tAdded as child of node 0 and dropped at (-145, -10):");
|
||||
var prediction2b = manager.predict(0, {x:-145, y:-10});
|
||||
this._plotPrediction(graph2, prediction2b);
|
||||
$assert(prediction2b.position.x == -130 && prediction2b.position.y == -10, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2b.order == 3, "Prediction order should be 1");
|
||||
$assert(prediction2b.position.y > manager.find(2).getPosition().y &&
|
||||
prediction2b.position.y < manager.find(4).getPosition().y &&
|
||||
prediction2b.position.x == manager.find(2).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2b.order == 3, "Prediction order should be 3");
|
||||
|
||||
console.log("\tAdded as child of node 0 and dropped at (-145, 40):");
|
||||
var prediction2c = manager.predict(0, {x:-145, y:400});
|
||||
this._plotPrediction(graph2, prediction2c);
|
||||
$assert(prediction2c.position.x == -130 && prediction2c.position.y == 60, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2c.order == 5, "Prediction order should be 1");
|
||||
$assert(prediction2c.position.y > manager.find(4).getPosition().y &&
|
||||
prediction2c.position.x == manager.find(4).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2c.order == 5, "Prediction order should be 5");
|
||||
|
||||
// Graph 3
|
||||
console.log("\tPredict nodes added with no position:");
|
||||
var graph3 = manager.plot("testBalancedPredict3", {width:1000, height:400});
|
||||
var prediction3 = manager.predict(0, null);
|
||||
this._plotPrediction(graph3, prediction3);
|
||||
$assert(prediction3.position.x < manager.find(0).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction3.position.y > manager.find(4).getPosition().y &&
|
||||
prediction3.position.x == manager.find(4).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction3.order == 5, "Prediction order should be 5");
|
||||
|
||||
console.log("\tPredict nodes added with no position:");
|
||||
@ -230,8 +253,9 @@ mindplot.layout.BalancedTestSuite = new Class({
|
||||
var graph4 = manager.plot("testBalancedPredict4", {width:1000, height:400});
|
||||
var prediction4 = manager.predict(0, null);
|
||||
this._plotPrediction(graph4, prediction4);
|
||||
$assert(prediction4.position.x > manager.find(0).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction4.order == 6);
|
||||
$assert(prediction4.position.y > manager.find(5).getPosition().y &&
|
||||
prediction4.position.x == manager.find(5).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction4.order == 6, "Prediction order should be 6");
|
||||
|
||||
console.log("\tPredict nodes added only a root node:");
|
||||
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5);
|
||||
@ -241,9 +265,13 @@ mindplot.layout.BalancedTestSuite = new Class({
|
||||
var prediction5b = manager.predict(0, {x: 40, y: 100});
|
||||
this._plotPrediction(graph5, prediction5a);
|
||||
this._plotPrediction(graph5, prediction5b);
|
||||
$assert(prediction5a.position.x > manager.find(0).getPosition().x && prediction5a.position.y == manager.find(0).getPosition().y, "Prediction is incorrectly positioned");
|
||||
$assert(prediction5a.position.x > manager.find(0).getPosition().x &&
|
||||
prediction5a.position.y == manager.find(0).getPosition().y, "Prediction is incorrectly positioned");
|
||||
$assert(prediction5a.order == 0, "Prediction order should be 0");
|
||||
$assert(prediction5a.position.x == prediction5b.position.x && prediction5a.position.y == prediction5b.position.y, "Both predictions should be the same");
|
||||
$assert(prediction5a.position.x == prediction5b.position.x &&
|
||||
prediction5a.position.y == prediction5b.position.y, "Both predictions should be the same");
|
||||
$assert(prediction5a.order == prediction5b.order, "Both predictions should be the same");
|
||||
|
||||
console.log("OK!\n\n");
|
||||
}
|
||||
});
|
@ -67,48 +67,50 @@ mindplot.layout.FreeTestSuite = new Class({
|
||||
manager.layout();
|
||||
manager.plot("testFreePosition1", {width:1400, height:600});
|
||||
|
||||
console.log("move node 12 to (300,30)");
|
||||
console.log("\tmove node 12 to (300,30)");
|
||||
manager.moveNode(12, {x:300, y:30});
|
||||
manager.layout();
|
||||
manager.plot("testFreePosition2", {width:1400, height:600});
|
||||
|
||||
console.log("move node 13 to (340,180)");
|
||||
console.log("\tmove node 13 to (340,180)");
|
||||
manager.moveNode(13, {x:340, y:180});
|
||||
manager.layout(true);
|
||||
manager.plot("testFreePosition3", {width:1400, height:600});
|
||||
|
||||
console.log("move node 11 to (250,-50)");
|
||||
console.log("\tmove node 11 to (250,-50)");
|
||||
manager.moveNode(11, {x:250, y:-50});
|
||||
manager.layout(true);
|
||||
manager.plot("testFreePosition4", {width:1400, height:600});
|
||||
|
||||
console.log("move node 7 to (350,-190)");
|
||||
console.log("\tmove node 7 to (350,-190)");
|
||||
manager.moveNode(7, {x:350, y:-190});
|
||||
manager.layout(true);
|
||||
manager.plot("testFreePosition5", {width:1400, height:600});
|
||||
|
||||
console.log("add node 23 to 12:");
|
||||
console.log("\tadd node 23 to 12:");
|
||||
manager.addNode(23, mindplot.layout.TestSuite.NODE_SIZE, position);
|
||||
manager.connectNode(12,23,3);
|
||||
manager.layout(true);
|
||||
manager.plot("testFreePosition6", {width:1400, height:600});
|
||||
|
||||
console.log("move node 4 to (-300, 190)");
|
||||
console.log("\tmove node 4 to (-300, 190)");
|
||||
manager.moveNode(4, {x:-300, y:190});
|
||||
manager.layout(true);
|
||||
manager.plot("testFreePosition7", {width:1400, height:600});
|
||||
|
||||
console.log("add node 24 to 3:");
|
||||
console.log("\tadd node 24 to 3:");
|
||||
manager.addNode(24, mindplot.layout.TestSuite.NODE_SIZE, position);
|
||||
manager.connectNode(3,24,3);
|
||||
manager.layout(true);
|
||||
manager.plot("testFreePosition8", {width:1400, height:600});
|
||||
|
||||
console.log("add node 25 to 17:");
|
||||
console.log("\tadd node 25 to 17:");
|
||||
manager.addNode(25, mindplot.layout.TestSuite.NODE_SIZE, position);
|
||||
manager.connectNode(17,25,0);
|
||||
manager.layout(true);
|
||||
manager.plot("testFreePosition9", {width:1400, height:600});
|
||||
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testFreePredict: function() {
|
||||
@ -166,6 +168,8 @@ mindplot.layout.FreeTestSuite = new Class({
|
||||
this._plotPrediction(graph, predict2);
|
||||
this._plotPrediction(graph, predict3);
|
||||
this._plotPrediction(graph, predict4);
|
||||
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testReconnectFreeNode: function() {
|
||||
@ -201,24 +205,24 @@ mindplot.layout.FreeTestSuite = new Class({
|
||||
manager.layout();
|
||||
manager.plot("testReconnectFreeNode1", {width:1000, height:400});
|
||||
|
||||
console.log("move node 5");
|
||||
console.log("\tmove node 5");
|
||||
manager.moveNode(5, {x:250, y:30});
|
||||
manager.layout();
|
||||
manager.plot("testReconnectFreeNode2", {width:1000, height:400});
|
||||
|
||||
console.log("reconnect node 5 to node 2");
|
||||
console.log("\treconnect node 5 to node 2");
|
||||
manager.disconnectNode(5);
|
||||
manager.connectNode(2,5,2);
|
||||
manager.layout();
|
||||
manager.plot("testReconnectFreeNode3", {width:1000, height:400});
|
||||
|
||||
console.log("move node 8");
|
||||
console.log("\tmove node 8");
|
||||
manager.moveNode(8, {x:-370, y:60});
|
||||
manager.layout();
|
||||
manager.plot("testReconnectFreeNode4", {width:1000, height:400});
|
||||
|
||||
//TODO(gb): fix this. node 11 is not positioned correctly
|
||||
console.log("reconnect node 5 to node 10");
|
||||
console.log("\treconnect node 5 to node 10");
|
||||
manager.disconnectNode(5);
|
||||
manager.connectNode(10,5,0);
|
||||
manager.layout();
|
||||
@ -233,5 +237,7 @@ mindplot.layout.FreeTestSuite = new Class({
|
||||
// manager.moveNode(8, {x:370, y:30});
|
||||
// manager.layout();
|
||||
// manager.plot("testReconnectFreeNode2", {width:1000, height:400});
|
||||
|
||||
console.log("OK!\n\n");
|
||||
}
|
||||
});
|
@ -26,6 +26,7 @@ mindplot.layout.SymmetricTestSuite = new Class({
|
||||
},
|
||||
|
||||
testSymmetry: function() {
|
||||
console.log("testSymmetry:")
|
||||
var position = {x:0,y:0};
|
||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
@ -64,9 +65,14 @@ mindplot.layout.SymmetricTestSuite = new Class({
|
||||
// All nodes should be positioned symmetrically with respect to their common ancestors
|
||||
$assert(manager.find(14).getPosition().y == -manager.find(13).getPosition().y, "Symmetry is not respected");
|
||||
$assert(manager.find(5).getPosition().y == -manager.find(11).getPosition().y, "Symmetry is not respected");
|
||||
$assert(manager.find(11).getPosition().y - manager.find(6).getPosition().y == -(manager.find(12).getPosition().y - manager.find(6).getPosition().y), "Symmetry is not respected");
|
||||
$assert(manager.find(8).getPosition().y - manager.find(1).getPosition().y == -(manager.find(11).getPosition().y - manager.find(1).getPosition().y), "Symmetry is not respected");
|
||||
$assert(manager.find(9).getPosition().y - manager.find(1).getPosition().y == -(manager.find(11).getPosition().y - manager.find(1).getPosition().y), "Symmetry is not respected");
|
||||
$assert(manager.find(11).getPosition().y - manager.find(6).getPosition().y ==
|
||||
-(manager.find(12).getPosition().y - manager.find(6).getPosition().y), "Symmetry is not respected");
|
||||
$assert(manager.find(8).getPosition().y - manager.find(1).getPosition().y ==
|
||||
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y), "Symmetry is not respected");
|
||||
$assert(manager.find(9).getPosition().y - manager.find(1).getPosition().y ==
|
||||
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y), "Symmetry is not respected");
|
||||
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testSymmetricPredict: function() {
|
||||
@ -101,37 +107,111 @@ mindplot.layout.SymmetricTestSuite = new Class({
|
||||
|
||||
manager.layout();
|
||||
|
||||
console.log("\tAdded as child of node 9 and dropped at (-280, 45):");
|
||||
// Graph
|
||||
var graph1 = manager.plot("testSymmetricPredict1", {width:1000, height:400});
|
||||
this._plotPrediction(graph1, manager.predict(9, {x:-280, y:45}));
|
||||
|
||||
console.log("\tAdded as child of node 9 and dropped at (-280, 45):");
|
||||
var prediction1a = manager.predict(9, {x:-280, y:45});
|
||||
this._plotPrediction(graph1, prediction1a);
|
||||
$assert(prediction1a.position.x < manager.find(9).getPosition().x &&
|
||||
prediction1a.position.y == manager.find(9).getPosition().y, "Prediction incorrectly positioned");
|
||||
$assert(prediction1a.order == 0, "Prediction order should be 0");
|
||||
|
||||
console.log("\tAdded as child of node 1 and dropped at (155, -90):");
|
||||
this._plotPrediction(graph1, manager.predict(1, {x:-155, y:-90}));
|
||||
var prediction1b = manager.predict(1, {x:-155, y:-90});
|
||||
this._plotPrediction(graph1, prediction1b);
|
||||
$assert(prediction1b.position.x > manager.find(1).getPosition().x &&
|
||||
prediction1b.position.y == manager.find(1).getPosition().y, "Prediction is incorrectly positioned");
|
||||
$assert(prediction1b.order == 0, "Prediction order should be 0");
|
||||
|
||||
// Graph 2
|
||||
var graph2 = manager.plot("testSymmetricPredict2", {width:1000, height:400});
|
||||
|
||||
console.log("\tAdded as child of node 5 and dropped at (380, -30):");
|
||||
var prediction2d = manager.predict(5, {x:380, y:-30});
|
||||
this._plotPrediction(graph2, prediction2d);
|
||||
$assert(prediction2d.position.y < manager.find(7).getPosition().y &&
|
||||
prediction2d.position.x == manager.find(7).getPosition().x, "Prediction is incorrectly positioned" );
|
||||
$assert(prediction2d.order == 0, "Prediction order should be 0");
|
||||
|
||||
console.log("\tAdded as child of node 5 and dropped at (375, 15):");
|
||||
var graph2 = manager.plot("testSymmetricPredict2", {width:1000, height:400});
|
||||
this._plotPrediction(graph2, manager.predict(5, {x:375, y:15}));
|
||||
var prediction2a = manager.predict(5, {x:375, y:15});
|
||||
this._plotPrediction(graph2, prediction2a);
|
||||
$assert(prediction2a.position.y > manager.find(7).getPosition().y &&
|
||||
prediction2a.position.y < manager.find(8).getPosition().y &&
|
||||
prediction2a.position.x == manager.find(7).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2a.order == 1, "Prediction order should be 1");
|
||||
|
||||
console.log("\tAdded as child of node 5 and dropped at (375, 45):");
|
||||
this._plotPrediction(graph2, manager.predict(5, {x:375, y:45}));
|
||||
var prediction2b = manager.predict(5, {x:375, y:45});
|
||||
this._plotPrediction(graph2, prediction2b);
|
||||
$assert(prediction2b.position.y > manager.find(8).getPosition().y &&
|
||||
prediction2b.position.y < manager.find(11).getPosition().y &&
|
||||
prediction2b.position.x == manager.find(7).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2b.order == 2, "Prediction order should be 2");
|
||||
|
||||
console.log("\tAdded as child of node 5 and dropped at (375, 45):");
|
||||
this._plotPrediction(graph2, manager.predict(5, {x:375, y:65}));
|
||||
console.log("\tAdded as child of node 5 and dropped at (380, -30):");
|
||||
this._plotPrediction(graph2, manager.predict(5, {x:380, y:-30}));
|
||||
var prediction2c = manager.predict(5, {x:375, y:65});
|
||||
this._plotPrediction(graph2, prediction2c);
|
||||
$assert(prediction2c.position.y > manager.find(11).getPosition().y &&
|
||||
prediction2c.position.x == manager.find(11).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction2c.order == 3, "Prediction order should be 3");
|
||||
|
||||
// Graph 3
|
||||
var graph3 = manager.plot("testSymmetricPredict3", {width:1000, height:400});
|
||||
|
||||
console.log("\tAdded as child of node 3 and dropped at (280, 45):");
|
||||
var graph3 = manager.plot("testSymmetricPredict3", {width:1000, height:400});
|
||||
this._plotPrediction(graph3, manager.predict(3, {x:280, y:45}));
|
||||
var prediction3a = manager.predict(3, {x:280, y:45});
|
||||
this._plotPrediction(graph3, prediction3a);
|
||||
$assert(prediction3a.position.y > manager.find(5).getPosition().y &&
|
||||
prediction3a.position.y < manager.find(6).getPosition().y &&
|
||||
prediction3a.position.x == manager.find(5).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction3a.order == 2, "Prediction order should be 2");
|
||||
|
||||
console.log("\tAdded as child of node 3 and dropped at (255, 110):");
|
||||
this._plotPrediction(graph3, manager.predict(3, {x:255, y:110}));
|
||||
var prediction3b = manager.predict(3, {x:255, y:110});
|
||||
this._plotPrediction(graph3, prediction3b);
|
||||
$assert(prediction3b.position.y > manager.find(6).getPosition().y &&
|
||||
prediction3b.position.x == manager.find(6).getPosition().x, "Prediction incorrectly positioned");
|
||||
$assert(prediction3b.order == 3, "Prediction order should be 3");
|
||||
|
||||
// Graph 4
|
||||
console.log("\tAdded as child of node 2 and dropped at (-260, 0):");
|
||||
|
||||
var graph4 = manager.plot("testSymmetricPredict4", {width:1000, height:400});
|
||||
this._plotPrediction(graph4, manager.predict(2, {x:-260, y:0}));
|
||||
var prediction4 = manager.predict(2, {x:-260, y:0});
|
||||
this._plotPrediction(graph4, prediction4);
|
||||
$assert(prediction4.position.y > manager.find(9).getPosition().y &&
|
||||
prediction4.position.y < manager.find(10).getPosition().y &&
|
||||
prediction4.position.x == manager.find(9).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction4.order == 1, "Prediction order should be 1");
|
||||
|
||||
// Graph 5
|
||||
console.log("\tPredict nodes added with no position:");
|
||||
var graph5 = manager.plot("testSymmetricPredict5", {width:1000, height:400});
|
||||
this._plotPrediction(graph5, manager.predict(1, null));
|
||||
this._plotPrediction(graph5, manager.predict(2, null));
|
||||
this._plotPrediction(graph5, manager.predict(3, null));
|
||||
this._plotPrediction(graph5, manager.predict(10, null));
|
||||
var prediction5a = manager.predict(1, null);
|
||||
this._plotPrediction(graph5, prediction5a);
|
||||
$assert(prediction5a.position.y == manager.find(1).getPosition().y &&
|
||||
prediction5a.position.x > manager.find(1).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction5a.order == 0, "Prediction order should be 0");
|
||||
|
||||
var prediction5b = manager.predict(2, null);
|
||||
this._plotPrediction(graph5, prediction5b);
|
||||
$assert(prediction5b.position.y > manager.find(10).getPosition().y &&
|
||||
prediction5b.position.x < manager.find(2).getPosition().x &&
|
||||
prediction5b.position.x == manager.find(10).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction5b.order == 2, "Prediction order should be 2");
|
||||
|
||||
var prediction5c = manager.predict(3, null);
|
||||
this._plotPrediction(graph5, prediction5c);
|
||||
$assert(prediction5c.position.y > manager.find(6).getPosition().y &&
|
||||
prediction5c.position.x > manager.find(3).getPosition().x &&
|
||||
prediction5c.position.x == manager.find(6).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction5c.order == 3, "Prediction order should be 3");
|
||||
|
||||
var prediction5d = manager.predict(10, null);
|
||||
this._plotPrediction(graph5, prediction5d);
|
||||
$assert(prediction5d.position.y == manager.find(10).getPosition().y &&
|
||||
prediction5d.position.x < manager.find(10).getPosition().x, "Prediction is incorrectly positioned");
|
||||
$assert(prediction5d.order == 0, "Prediction order should be 0");
|
||||
}
|
||||
});
|
@ -57,7 +57,7 @@ mindplot.layout.TestSuite = new Class({
|
||||
$assert(manager.find(1).getPosition().x == manager.find(6).getPosition().x, "Sibling nodes are not horizontally aligned");
|
||||
$assert(manager.find(1).getPosition().x == manager.find(7).getPosition().x, "Sibling nodes are not horizontally aligned");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testEvents: function() {
|
||||
@ -89,7 +89,7 @@ mindplot.layout.TestSuite = new Class({
|
||||
// Check no events where fired
|
||||
$assert(events.length == 0, "Unnecessary tree updated.");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testEventsComplex: function() {
|
||||
@ -128,7 +128,7 @@ mindplot.layout.TestSuite = new Class({
|
||||
// Check only 4 nodes were repositioned
|
||||
$assert(events.length == 4, "Only 4 nodes should be repositioned.");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testDisconnect: function() {
|
||||
@ -181,7 +181,7 @@ mindplot.layout.TestSuite = new Class({
|
||||
// Check that nodes 1 and 3 are now vertically aligned
|
||||
$assert(manager.find(1).getPosition().y == manager.find(3).getPosition().y, "Nodes 1 and 3 should now be vertically aligned");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testReconnect: function() {
|
||||
@ -230,7 +230,7 @@ mindplot.layout.TestSuite = new Class({
|
||||
$assert(manager.find(4).getPosition().x > manager.find(6).getPosition().x, "Node 6 and their children should be to the left of node 4");
|
||||
$assert(manager.find(6).getPosition().x > manager.find(11).getPosition().x && manager.find(11).getPosition().x == manager.find(12).getPosition().x, "Nodes 11 and 12 should be to the left of node 6 and horizontally aligned");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testRemoveNode: function() {
|
||||
@ -294,7 +294,7 @@ mindplot.layout.TestSuite = new Class({
|
||||
$assert(manager.find(7).getOrder() == 1, "Node 7 should have order 1");
|
||||
$assert(manager.find(9).getOrder() == 3, "Node 9 should have order 3");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testSize: function() {
|
||||
@ -375,7 +375,7 @@ mindplot.layout.TestSuite = new Class({
|
||||
// Check that all enlarged nodes shift children accordingly
|
||||
$assert(yPosNode2 - manager.find(2).getPosition().y == 20, "Node 2 should have been shifted by 20");
|
||||
|
||||
console.log("\n");
|
||||
console.log("OK!\n\n");
|
||||
},
|
||||
|
||||
testReconnectSingleNode: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user