mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix SVGImport tests to work with new Shape import.
This commit is contained in:
parent
9976033655
commit
83be3cb023
2 changed files with 50 additions and 50 deletions
|
@ -227,7 +227,7 @@ function compareItems(item, item2, cloned, checkIdentity, dontShareProject) {
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
var itemProperties = ['opacity', 'locked', 'visible', 'blendMode', 'name',
|
var itemProperties = ['opacity', 'locked', 'visible', 'blendMode', 'name',
|
||||||
'selected', 'clipMask'];
|
'selected', 'clipMask', 'guide'];
|
||||||
Base.each(itemProperties, function(key) {
|
Base.each(itemProperties, function(key) {
|
||||||
var value = item[key];
|
var value = item[key];
|
||||||
// When item was cloned and had a name, the name will be versioned
|
// When item was cloned and had a name, the name will be versioned
|
||||||
|
@ -272,7 +272,7 @@ function compareItems(item, item2, cloned, checkIdentity, dontShareProject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path specific
|
// Path specific
|
||||||
if (item2 instanceof Path) {
|
if (item instanceof Path) {
|
||||||
var keys = ['closed', 'fullySelected', 'clockwise'];
|
var keys = ['closed', 'fullySelected', 'clockwise'];
|
||||||
for (var i = 0, l = keys.length; i < l; i++) {
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
var key = keys[i];
|
var key = keys[i];
|
||||||
|
@ -282,6 +282,15 @@ function compareItems(item, item2, cloned, checkIdentity, dontShareProject) {
|
||||||
compareSegmentLists(item.segments, item2.segments, checkIdentity);
|
compareSegmentLists(item.segments, item2.segments, checkIdentity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shape specific
|
||||||
|
if (item instanceof Shape) {
|
||||||
|
var keys = ['shape', 'size', 'radius'];
|
||||||
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
|
var key = keys[i];
|
||||||
|
equals(item[key], item2[key], 'Compare Shape#' + key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Group specific
|
// Group specific
|
||||||
if (item instanceof Group) {
|
if (item instanceof Group) {
|
||||||
equals(function() {
|
equals(function() {
|
||||||
|
|
|
@ -34,7 +34,7 @@ test('make an svg line', function() {
|
||||||
|
|
||||||
var line = new Path.Line([x1, y1], [x2, y2]);
|
var line = new Path.Line([x1, y1], [x2, y2]);
|
||||||
|
|
||||||
compareSegmentLists(importedLine.segments, line.segments, true);
|
compareItems(importedLine, line);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('make an svg line with invalid values', function() {
|
test('make an svg line with invalid values', function() {
|
||||||
|
@ -49,7 +49,7 @@ test('make an svg line with invalid values', function() {
|
||||||
|
|
||||||
var line = new Path.Line([0, 0], [0, 0]);
|
var line = new Path.Line([0, 0], [0, 0]);
|
||||||
|
|
||||||
compareSegmentLists(importedLine.segments, line.segments, true);
|
compareItems(importedLine, line);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare rectangle values', function() {
|
test('compare rectangle values', function() {
|
||||||
|
@ -69,9 +69,9 @@ test('compare rectangle values', function() {
|
||||||
var topLeft = new Point(x, y);
|
var topLeft = new Point(x, y);
|
||||||
var size = new Size(width, height);
|
var size = new Size(width, height);
|
||||||
var rectangle = new Rectangle(topLeft, size);
|
var rectangle = new Rectangle(topLeft, size);
|
||||||
var realRectangle = new Path.Rectangle(rectangle);
|
var realRectangle = new Shape.Rectangle(rectangle);
|
||||||
|
|
||||||
compareSegmentLists(importedRectangle.segments, realRectangle.segments, true);
|
compareItems(importedRectangle, realRectangle);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@ test('compare negative rectangle values', function() {
|
||||||
var topLeft = new Point(x, y);
|
var topLeft = new Point(x, y);
|
||||||
var size = new Size(width, height);
|
var size = new Size(width, height);
|
||||||
var rectangle = new Rectangle(topLeft, size);
|
var rectangle = new Rectangle(topLeft, size);
|
||||||
var realRectangle = new Path.Rectangle(rectangle);
|
var realRectangle = new Shape.Rectangle(rectangle);
|
||||||
|
|
||||||
compareSegmentLists(importedRectangle.segments, realRectangle.segments, true);
|
compareItems(importedRectangle, realRectangle);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,9 +111,9 @@ test('compare invalid rectangle values', function() {
|
||||||
var topLeft = new Point(0, 0);
|
var topLeft = new Point(0, 0);
|
||||||
var size = new Size(0, 0);
|
var size = new Size(0, 0);
|
||||||
var rectangle = new Rectangle(topLeft, size);
|
var rectangle = new Rectangle(topLeft, size);
|
||||||
var realRectangle = new Path.Rectangle(rectangle);
|
var realRectangle = new Shape.Rectangle(rectangle);
|
||||||
|
|
||||||
compareSegmentLists(importedRectangle.segments, realRectangle.segments, true);
|
compareItems(importedRectangle, realRectangle);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare round rectangle values', function() {
|
test('compare round rectangle values', function() {
|
||||||
|
@ -138,9 +138,9 @@ test('compare round rectangle values', function() {
|
||||||
var size = new Size(width, height);
|
var size = new Size(width, height);
|
||||||
var cornerSize = new Size(rx, ry);
|
var cornerSize = new Size(rx, ry);
|
||||||
var rectangle = new Rectangle(topLeft, size);
|
var rectangle = new Rectangle(topLeft, size);
|
||||||
var roundRect = new Path.Rectangle(rectangle, cornerSize);
|
var roundRect = new Shape.Rectangle(rectangle, cornerSize);
|
||||||
|
|
||||||
compareSegmentLists(importedRectangle.segments, roundRect.segments, true);
|
compareItems(importedRectangle, roundRect);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare negative round rectangle values', function() {
|
test('compare negative round rectangle values', function() {
|
||||||
|
@ -165,9 +165,9 @@ test('compare negative round rectangle values', function() {
|
||||||
var size = new Size(width, height);
|
var size = new Size(width, height);
|
||||||
var cornerSize = new Size(rx, ry);
|
var cornerSize = new Size(rx, ry);
|
||||||
var rectangle = new Rectangle(topLeft, size);
|
var rectangle = new Rectangle(topLeft, size);
|
||||||
var roundRect = new Path.Rectangle(rectangle, cornerSize);
|
var roundRect = new Shape.Rectangle(rectangle, cornerSize);
|
||||||
|
|
||||||
compareSegmentLists(importedRectangle.segments, roundRect.segments, true);
|
compareItems(importedRectangle, roundRect);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare invalid round rectangle values', function() {
|
test('compare invalid round rectangle values', function() {
|
||||||
|
@ -192,9 +192,9 @@ test('compare invalid round rectangle values', function() {
|
||||||
var size = new Size(width, height);
|
var size = new Size(width, height);
|
||||||
var cornerSize = new Size(rx, ry);
|
var cornerSize = new Size(rx, ry);
|
||||||
var rectangle = new Rectangle(topLeft, size);
|
var rectangle = new Rectangle(topLeft, size);
|
||||||
var roundRect = new Path.Rectangle(rectangle, cornerSize);
|
var roundRect = new Shape.Rectangle(rectangle, cornerSize);
|
||||||
|
|
||||||
compareSegmentLists(importedRectangle.segments, roundRect.segments, true);
|
compareItems(importedRectangle, roundRect);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare ellipse values', function() {
|
test('compare ellipse values', function() {
|
||||||
|
@ -211,15 +211,12 @@ test('compare ellipse values', function() {
|
||||||
|
|
||||||
var importedEllipse = paper.project.importSVG(shape);
|
var importedEllipse = paper.project.importSVG(shape);
|
||||||
|
|
||||||
var center = new Point(cx, cy);
|
var ellipse = new Shape.Ellipse({
|
||||||
var offset = new Point(rx, ry);
|
center: new Point(cx, cy),
|
||||||
var topLeft = center.subtract(offset);
|
radius: new Point(rx, ry)
|
||||||
var bottomRight = center.add(offset);
|
});
|
||||||
|
|
||||||
var rect = new Rectangle(topLeft, bottomRight);
|
compareItems(importedEllipse, ellipse);
|
||||||
var ellipse = new Path.Ellipse(rect);
|
|
||||||
|
|
||||||
compareSegmentLists(importedEllipse.segments, ellipse.segments, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare negative ellipse values', function() {
|
test('compare negative ellipse values', function() {
|
||||||
|
@ -236,15 +233,12 @@ test('compare negative ellipse values', function() {
|
||||||
|
|
||||||
var importedEllipse = paper.project.importSVG(shape);
|
var importedEllipse = paper.project.importSVG(shape);
|
||||||
|
|
||||||
var center = new Point(cx, cy);
|
var ellipse = new Shape.Ellipse({
|
||||||
var offset = new Point(rx, ry);
|
center: new Point(cx, cy),
|
||||||
var topLeft = center.subtract(offset);
|
radius: new Point(rx, ry)
|
||||||
var bottomRight = center.add(offset);
|
});
|
||||||
|
|
||||||
var rect = new Rectangle(topLeft, bottomRight);
|
compareItems(importedEllipse, ellipse);
|
||||||
var ellipse = new Path.Ellipse(rect);
|
|
||||||
|
|
||||||
compareSegmentLists(importedEllipse.segments, ellipse.segments, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare invalid ellipse values', function() {
|
test('compare invalid ellipse values', function() {
|
||||||
|
@ -257,15 +251,12 @@ test('compare invalid ellipse values', function() {
|
||||||
|
|
||||||
var importedEllipse = paper.project.importSVG(shape);
|
var importedEllipse = paper.project.importSVG(shape);
|
||||||
|
|
||||||
var center = new Point(0, 0);
|
var ellipse = new Shape.Ellipse({
|
||||||
var offset = new Point(0, 0);
|
center: new Point(0, 0),
|
||||||
var topLeft = center.subtract(offset);
|
radius: new Point(0, 0)
|
||||||
var bottomRight = center.add(offset);
|
});
|
||||||
|
|
||||||
var rect = new Rectangle(topLeft, bottomRight);
|
compareItems(importedEllipse, ellipse);
|
||||||
var ellipse = new Path.Ellipse(rect);
|
|
||||||
|
|
||||||
compareSegmentLists(importedEllipse.segments, ellipse.segments, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare circle values', function() {
|
test('compare circle values', function() {
|
||||||
|
@ -281,9 +272,9 @@ test('compare circle values', function() {
|
||||||
var importedCircle = paper.project.importSVG(shape);
|
var importedCircle = paper.project.importSVG(shape);
|
||||||
|
|
||||||
var center = new Point(cx, cy);
|
var center = new Point(cx, cy);
|
||||||
var circle = new Path.Circle(center, r);
|
var circle = new Shape.Circle(center, r);
|
||||||
|
|
||||||
compareSegmentLists(importedCircle.segments, circle.segments, true);
|
compareItems(importedCircle, circle);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare negative circle values', function() {
|
test('compare negative circle values', function() {
|
||||||
|
@ -299,9 +290,9 @@ test('compare negative circle values', function() {
|
||||||
var importedCircle = paper.project.importSVG(shape);
|
var importedCircle = paper.project.importSVG(shape);
|
||||||
|
|
||||||
var center = new Point(cx, cy);
|
var center = new Point(cx, cy);
|
||||||
var circle = new Path.Circle(center, r);
|
var circle = new Shape.Circle(center, r);
|
||||||
|
|
||||||
compareSegmentLists(importedCircle.segments, circle.segments, true);
|
compareItems(importedCircle, circle);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,9 +306,9 @@ test('compare invalid circle values', function() {
|
||||||
var importedCircle = paper.project.importSVG(shape);
|
var importedCircle = paper.project.importSVG(shape);
|
||||||
|
|
||||||
var center = new Point(0, 0);
|
var center = new Point(0, 0);
|
||||||
var circle = new Path.Circle(center, 0);
|
var circle = new Shape.Circle(center, 0);
|
||||||
|
|
||||||
compareSegmentLists(importedCircle.segments, circle.segments, true);
|
compareItems(importedCircle, circle);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -339,7 +330,7 @@ test('compare polygon values', function() {
|
||||||
poly.closePath();
|
poly.closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
compareSegmentLists(importedPolygon.segments, poly.segments, true);
|
compareItems(importedPolygon, poly);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare negative polygon values', function() {
|
test('compare negative polygon values', function() {
|
||||||
|
@ -360,7 +351,7 @@ test('compare negative polygon values', function() {
|
||||||
poly.closePath();
|
poly.closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
compareSegmentLists(importedPolygon.segments, poly.segments, true);
|
compareItems(importedPolygon, poly);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare polyline values', function() {
|
test('compare polyline values', function() {
|
||||||
|
@ -381,7 +372,7 @@ test('compare polyline values', function() {
|
||||||
poly.closePath();
|
poly.closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
compareSegmentLists(importedPolyline.segments, poly.segments, true);
|
compareItems(importedPolyline, poly);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compare negative polyline values', function() {
|
test('compare negative polyline values', function() {
|
||||||
|
@ -402,5 +393,5 @@ test('compare negative polyline values', function() {
|
||||||
poly.closePath();
|
poly.closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
compareSegmentLists(importedPolyline.segments, poly.segments, true);
|
compareItems(importedPolyline, poly);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue