Add integration tests for resize content and resize from other origin

This commit is contained in:
juliandescottes
2017-01-08 20:38:12 +01:00
parent a328e4d20e
commit 70085bc056
9 changed files with 213 additions and 25 deletions

View File

@ -1,3 +1,5 @@
/* globals casper, setPiskelFromGrid, piskelFrameEqualsGrid, isDrawerExpanded, getValue, isChecked, evalLine */
casper.test.begin('Test resize feature works, and check the output', 19, function(test) {
test.timeout = test.fail.bind(test, ['Test timed out']);
@ -5,16 +7,8 @@ casper.test.begin('Test resize feature works, and check the output', 19, functio
test.assertExists('#drawing-canvas-container canvas', 'Piskel ready, test starting');
// Setup test Piskel
casper.evaluate(function () {
var B = '#000000', T = Constants.TRANSPARENT_COLOR;
var frame = pskl.model.Frame.fromPixelGrid([
[B, T],
[T, B]
]);
var layer = pskl.model.Layer.fromFrames('l1', [frame]);
var piskel = pskl.model.Piskel.fromLayers([layer], 12, {name : 'test', description : ''});
pskl.app.piskelController.setPiskel(piskel);
});
setPiskelFromGrid('[[B, T],' +
' [T, B]]');
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
test.assertDoesntExist('.settings-section-resize', 'Check if resize settings drawer is closed');
@ -62,21 +56,13 @@ casper.test.begin('Test resize feature works, and check the output', 19, functio
test.assertEquals(evalLine('pskl.app.piskelController.getPiskel().getWidth()'), 4, 'Piskel width is now 4 pixels');
test.assertEquals(evalLine('pskl.app.piskelController.getPiskel().getHeight()'), 4, 'Piskel height is now 4 pixels');
test.assert(casper.evaluate(function () {
var B = '#000000', T = Constants.TRANSPARENT_COLOR;
var frame = pskl.app.piskelController.getPiskel().getLayerAt(0).getFrameAt(0);
var grid = [
[B, T, T, T],
[T, B, T, T],
[T, T, T, T],
[T, T, T, T],
]
var isValid = true;
frame.forEachPixel(function (color, col, row) {
isValid = isValid && pskl.utils.colorToInt(color) === pskl.utils.colorToInt(grid[row][col]);
});
return isValid;
}), 'Resized piskel content is as expected');
// Check that the piskel content has been resized.
test.assert(piskelFrameEqualsGrid('[\
[B, T, T, T], \
[T, B, T, T], \
[T, T, T, T], \
[T, T, T, T], \
]', 0, 0), 'Resized piskel content is as expected');
}
casper