mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-19 11:01:08 +00:00
Fix tests removing extra context.Restore();
This commit is contained in:
parent
a8b56e783e
commit
dfc574c099
7 changed files with 23 additions and 17 deletions
|
|
@ -3,7 +3,7 @@ node_js:
|
|||
- "0.12"
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
script: 'npm run build && npm run test && npm run lint && npm run lint_tests'
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq libgif-dev libpng-dev libjpeg8-dev libpango1.0-dev libcairo2-dev
|
||||
script: 'npm run build && npm run test && npm run lint && npm run lint_tests'
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@
|
|||
"uglify-js": "2.4.x",
|
||||
"jscs": "2.1.x",
|
||||
"jshint": "2.8.x",
|
||||
"qunit": "0.7.2",
|
||||
"istanbul": "0.3.x"
|
||||
"qunit": "0.7.x",
|
||||
"istanbul": "0.4.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
|
|
|
|||
|
|
@ -887,7 +887,6 @@
|
|||
}
|
||||
|
||||
this.fire('after:render');
|
||||
canvasToDrawOn.restore();
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
|||
1
test.js
1
test.js
|
|
@ -5,6 +5,7 @@ testrunner.options.log.tests = false;
|
|||
testrunner.options.log.assertions = false;
|
||||
|
||||
testrunner.options.coverage = true;
|
||||
testrunner.options.maxBlockDuration = 120000;
|
||||
|
||||
testrunner.run({
|
||||
deps: "./test/fixtures/test_script.js",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
var el = fabric.document.createElement('canvas');
|
||||
el.width = 600; el.height = 600;
|
||||
|
||||
var canvas = this.canvas = fabric.isLikelyNode ? fabric.createCanvasForNode() : new fabric.Canvas(el);
|
||||
var canvas = this.canvas = fabric.isLikelyNode ? fabric.createCanvasForNode(600, 600, {enableRetinaScaling: false}) : new fabric.Canvas(el);
|
||||
|
||||
// function _createImageElement() {
|
||||
// return fabric.isLikelyNode ? new (require('canvas').Image)() : fabric.document.createElement('img');
|
||||
|
|
@ -515,19 +515,25 @@ test('toObject without default values', function() {
|
|||
});
|
||||
|
||||
test('test group transformMatrix', function() {
|
||||
var rect1 = new fabric.Rect({ top: 5, left: 5, width: 5, height: 5, strokeWidth: 0, fill: 'black', opacity: 1}),
|
||||
rect2 = new fabric.Rect({ top: 15, left: 15, width: 5, height: 5, strokeWidth: 0, fill: 'black', opacity: 1}),
|
||||
group = new fabric.Group([ rect1, rect2 ]),
|
||||
ctx = canvas.contextContainer, isTransparent = fabric.util.isTransparent;
|
||||
var rect1 = new fabric.Rect({ top: 1, left: 1, width: 2, height: 2, strokeWidth: 0, fill: 'red', opacity: 1}),
|
||||
rect2 = new fabric.Rect({ top: 4, left: 4, width: 2, height: 2, strokeWidth: 0, fill: 'red', opacity: 1}),
|
||||
group = new fabric.Group([ rect1, rect2 ], {opacity: 1, fill: 'blue', strokeWidth: 0}),
|
||||
isTransparent = fabric.util.isTransparent,
|
||||
ctx = canvas.contextContainer;
|
||||
canvas.add(group);
|
||||
equal(canvas.enableRetinaScaling, false);
|
||||
equal(isTransparent(ctx, 0, 0, 0), true);
|
||||
equal(isTransparent(ctx, 1, 1, 0), false);
|
||||
equal(isTransparent(ctx, 2, 2, 0), false);
|
||||
equal(isTransparent(ctx, 3, 3, 0), true);
|
||||
equal(isTransparent(ctx, 8, 8, 0), false);
|
||||
var imageData = ctx.getImageData(0, 0, (tolerance * 2) || 1, (tolerance * 2) || 1);
|
||||
equal(imageData, [0]);
|
||||
group.transformMatrix = [1.2, 0, 0, 1.2, 1, 1];
|
||||
equal(isTransparent(ctx, 4, 4, 0), false);
|
||||
group.transformMatrix = [2, 0, 0, 2, 1, 1];
|
||||
canvas.renderAll();
|
||||
equal(isTransparent(ctx, 101, 101, 0), true);
|
||||
equal(isTransparent(ctx, 131, 131, 0), false);
|
||||
equal(isTransparent(ctx, 0, 0, 0), true);
|
||||
equal(isTransparent(ctx, 1, 1, 0), true);
|
||||
equal(isTransparent(ctx, 2, 2, 0), true);
|
||||
equal(isTransparent(ctx, 3, 3, 0), false);
|
||||
equal(isTransparent(ctx, 4, 4, 0), false);
|
||||
});
|
||||
// asyncTest('cloning group with image', function() {
|
||||
// var rect = new fabric.Rect({ top: 100, left: 100, width: 30, height: 10 }),
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@
|
|||
var object = shadow.toObject(),
|
||||
shadow2 = new fabric.Shadow(object),
|
||||
object2 = shadow2.toObject();
|
||||
equal(shadow.affectStroke, shadow2.affectStroke)
|
||||
equal(shadow.affectStroke, shadow2.affectStroke);
|
||||
deepEqual(object, object2);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@
|
|||
|
||||
// temp workaround for text objects not obtaining width under node
|
||||
text.width = 100;
|
||||
text.textAlign = 'justify'
|
||||
text.textAlign = 'justify';
|
||||
equal(removeTranslate(text.toSVG()), removeTranslate(TEXT_SVG_JUSTIFIED));
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue