added new clearBeforeDraw Layer property which enables you to skip canvas clearing before each draw. Added new warn() method to test suite, and added error and warning colorings to the test counter

This commit is contained in:
Eric Rowell
2012-06-23 16:11:58 -07:00
parent 6b36c7ed93
commit 80eb50a708
7 changed files with 108 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,14 +1,22 @@
var numTests = 0;
var testCounter = null;
function test(condition, message, dataUrlTest) {
function warn(condition, message) {
test(condition, message, true);
}
function test(condition, message, warn) {
if(!condition) {
if(dataUrlTest) {
if(warn) {
testCounter.style.backgroundColor = 'orange';
testCounter.style.color = 'black';
console.warn(message + ' (NOTE: use Google Chrome for data url comparisons)');
}
else {
testCounter.style.backgroundColor = 'red';
testCounter.style.color = 'black';
throw new Error(message);
}
}
numTests++;

View File

@@ -40,7 +40,7 @@ Test.prototype.tests = {
});
stage.toDataURL(function(startDataUrl) {
test(urls[0] === startDataUrl, 'start data url is incorrect', true);
warn(urls[0] === startDataUrl, 'start data url is incorrect');
/*
* simulate drag and drop
*/
@@ -72,7 +72,7 @@ Test.prototype.tests = {
test(dragEnd, 'dragend event was not triggered');
stage.toDataURL(function(endDataUrl) {
test(urls[1] === endDataUrl, 'end data url is incorrect');
warn(urls[1] === endDataUrl, 'end data url is incorrect');
});
});
},
@@ -180,7 +180,7 @@ Test.prototype.tests = {
stage.add(layer);
stage.toDataURL(function(startDataUrl) {
test(urls[0] === startDataUrl, 'start data url is incorrect');
warn(urls[0] === startDataUrl, 'start data url is incorrect');
/*
* simulate drag and drop
@@ -201,7 +201,7 @@ Test.prototype.tests = {
});
stage.toDataURL(function(endDataUrl) {
test(urls[1] === endDataUrl, 'end data url is incorrect');
warn(urls[1] === endDataUrl, 'end data url is incorrect');
});
});
},
@@ -240,7 +240,7 @@ Test.prototype.tests = {
stage.add(layer);
stage.toDataURL(function(startDataUrl) {
test(startDataUrl === urls[0], 'start data url is incorrect');
warn(startDataUrl === urls[0], 'start data url is incorrect');
stage._mousemove({
clientX: 377,
@@ -248,7 +248,7 @@ Test.prototype.tests = {
});
stage.toDataURL(function(endDataUrl) {
test(urls[1] === endDataUrl, 'end data url is incorrect');
warn(urls[1] === endDataUrl, 'end data url is incorrect');
});
});
},

View File

@@ -362,7 +362,7 @@ Test.prototype.tests = {
layer.draw();
stage.toDataURL(function(startDataUrl) {
test(startDataUrl === urls[0], 'start data url is incorrect');
warn(startDataUrl === urls[0], 'start data url is incorrect');
test(triangle.getId() === 'myTriangle', 'triangle id should be myTriangle');
@@ -378,7 +378,7 @@ Test.prototype.tests = {
layer.draw();
stage.toDataURL(function(endDataUrl) {
test(endDataUrl === urls[0], 'end data url is incorrect');
warn(endDataUrl === urls[0], 'end data url is incorrect');
});
});
},
@@ -940,6 +940,41 @@ Test.prototype.tests = {
layer.draw();
},
'LAYER - set clearBeforeDraw to false': function(containerId) {
var urls = dataUrls['LAYER - set clearBeforeDraw to false'];
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer({
clearBeforeDraw: false,
throttle: 999
});
var circle = new Kinetic.Ellipse({
x: 100,
y: stage.getHeight() / 2,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4
});
layer.add(circle);
stage.add(layer);
for(var n = 0; n < 20; n++) {
circle.move(10, 0);
layer.draw();
}
stage.toDataURL(function(dataUrl) {
warn(urls[0] === dataUrl, 'data url is incorrect');
});
},
'LAYER - throttling': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,