mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Implement tests for bounds caching.
This commit is contained in:
parent
d3c83be3bb
commit
853263263e
2 changed files with 45 additions and 0 deletions
44
test/tests/Item_Bounds.js
Normal file
44
test/tests/Item_Bounds.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Paper.js
|
||||
*
|
||||
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
|
||||
* based on Scriptographer.org and designed to be largely API compatible.
|
||||
* http://paperjs.org/
|
||||
* http://scriptographer.org/
|
||||
*
|
||||
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
|
||||
* http://lehni.org/ & http://jonathanpuckey.com/
|
||||
*
|
||||
* Distributed under the MIT license. See LICENSE file for details.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
module('Item Bounds');
|
||||
|
||||
test('item.bounds caching', function() {
|
||||
var circle = new Path.Circle(new Point(100, 100), 50);
|
||||
var rectangle = new Path.Rectangle(new Point(75, 75), new Point(175, 175));
|
||||
var group = new Group([circle, rectangle]);
|
||||
compareRectangles(group.bounds, { x: 50, y: 50, width: 125, height: 125 }, 'group.bounds');
|
||||
rectangle.remove();
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 1);
|
||||
compareRectangles(group.bounds, { x: 50, y: 50, width: 100, height: 100 }, 'group.bounds without rectangle');
|
||||
group.addChild(rectangle);
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 2);
|
||||
compareRectangles(group.bounds, { x: 50, y: 50, width: 125, height: 125 }, 'group.bounds with rectangle');
|
||||
circle.remove();
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 1);
|
||||
compareRectangles(group.bounds, { x: 75, y: 75, width: 100, height: 100 }, 'group.bounds without circle');
|
||||
group.addChild(circle);
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 2);
|
||||
compareRectangles(group.bounds, { x: 50, y: 50, width: 125, height: 125 }, 'group.bounds with circle');
|
||||
});
|
|
@ -9,6 +9,7 @@
|
|||
/*#*/ include('Item.js');
|
||||
/*#*/ include('Item_Cloning.js');
|
||||
/*#*/ include('Item_Order.js');
|
||||
/*#*/ include('Item_Bounds.js');
|
||||
|
||||
/*#*/ include('Layer.js');
|
||||
/*#*/ include('Group.js');
|
||||
|
|
Loading…
Reference in a new issue