Implement tests for PlacedSymbol, which fail because of lack of Item#strokeBounds and problems with PlacedSymbol#rotate.

This commit is contained in:
Jonathan Puckey 2011-02-26 13:48:31 +01:00
parent 422b8911b8
commit fd2926bc45
3 changed files with 28 additions and 0 deletions

View file

@ -14,9 +14,11 @@
<script type="text/javascript" src="../src/basic/Size.js"></script>
<script type="text/javascript" src="../src/basic/Matrix.js"></script>
<script type="text/javascript" src="../src/document/Doc.js"></script>
<script type="text/javascript" src="../src/document/Symbol.js"></script>
<script type="text/javascript" src="../src/item/Item.js"></script>
<script type="text/javascript" src="../src/item/Group.js"></script>
<script type="text/javascript" src="../src/item/Layer.js"></script>
<script type="text/javascript" src="../src/item/PlacedSymbol.js"></script>
<script type="text/javascript" src="../src/item/PathStyle.js"></script>
<script type="text/javascript" src="../src/path/Segment.js"></script>
<script type="text/javascript" src="../src/path/PathItem.js"></script>
@ -45,6 +47,7 @@
<script type="text/javascript" src="tests/Path_Drawing_Commands.js"></script>
<script type="text/javascript" src="tests/Path_Bounds.js"></script>
<script type="text/javascript" src="tests/PathStyle.js"></script>
<script type="text/javascript" src="tests/PlacedSymbol.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit Test Suite</h1>

View file

@ -1,6 +1,7 @@
module('Path');
test('path.currentSegment', function() {
var doc = new Doc();
var path = new Path();
path.moveTo([50, 50]);
path.lineTo([100, 100]);

View file

@ -0,0 +1,24 @@
module('Placed Symbol');
test('placedSymbol bounds', function() {
var doc = new Doc();
var path = new Path.Circle([50, 50], 50);
var symbol = new Symbol(path);
var placedSymbol = new PlacedSymbol(symbol);
// These tests currently fail because we haven't implemented
// Item#strokeBounds yet.
compareRectangles(placedSymbol.bounds,
new Rectangle(-50.5, -50.5, 101, 101),
'PlacedSymbol initial bounds.');
placedSymbol.scale(0.5);
compareRectangles(placedSymbol.bounds,
{ x: -25.5, y: -25.5, width: 51, height: 51 },
'Bounds after scale');
placedSymbol.rotate(40);
compareRectangles(placedSymbol.bounds,
{ x: -25.50049, y: -25.50049, width: 51.00098, height: 51.00098 },
'Bounds after rotation');
});