2011-02-16 16:11:26 -05:00
|
|
|
module('Layer');
|
|
|
|
|
|
|
|
test('previousSibling / nextSibling', function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
var proj = paper.project;
|
|
|
|
var firstLayer = proj.activeLayer;
|
2011-02-16 16:11:26 -05:00
|
|
|
var secondLayer = new Layer();
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return secondLayer.previousSibling == firstLayer;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return secondLayer.nextSibling == null;
|
|
|
|
}, true);
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
// Move another layer into secondLayer and check nextSibling /
|
|
|
|
// previousSibling:
|
|
|
|
var path = new Path();
|
|
|
|
var thirdLayer = new Layer();
|
|
|
|
secondLayer.appendBottom(thirdLayer);
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return secondLayer.children.length;
|
|
|
|
}, 2);
|
|
|
|
equals(function() {
|
|
|
|
return thirdLayer.nextSibling == path;
|
|
|
|
}, true);
|
2011-02-16 16:11:26 -05:00
|
|
|
secondLayer.appendTop(thirdLayer);
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return thirdLayer.nextSibling == null;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return thirdLayer.previousSibling == path;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
return proj.layers.length == 2;
|
2011-05-07 12:46:06 -04:00
|
|
|
}, true);
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
firstLayer.appendTop(secondLayer);
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
return proj.layers.length == 1;
|
2011-05-07 12:46:06 -04:00
|
|
|
}, true);
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('moveAbove / moveBelow', function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
var proj = paper.project;
|
|
|
|
var firstLayer = proj.activeLayer;
|
2011-02-16 16:11:26 -05:00
|
|
|
var secondLayer = new Layer();
|
|
|
|
secondLayer.moveBelow(firstLayer);
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return secondLayer.previousSibling == null;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return secondLayer.nextSibling == firstLayer;
|
|
|
|
}, true);
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
var path = new Path();
|
|
|
|
firstLayer.appendTop(path);
|
|
|
|
|
|
|
|
// move the layer above the path, inside the firstLayer:
|
|
|
|
secondLayer.moveAbove(path);
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return secondLayer.previousSibling == path;
|
|
|
|
}, true);
|
|
|
|
equals(function() {
|
|
|
|
return secondLayer.parent == firstLayer;
|
|
|
|
}, true);
|
2011-02-16 16:11:26 -05:00
|
|
|
// There should now only be one layer left:
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
return proj.layers.length;
|
2011-05-07 12:46:06 -04:00
|
|
|
}, 1);
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|