mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
add integration tests for PNG export & scaled export
This commit is contained in:
@@ -27,8 +27,10 @@ function isChecked(selector) {
|
||||
function setPiskelFromGrid(grid) {
|
||||
casper.evaluate(
|
||||
'function () {\
|
||||
var B = "#000000", T = Constants.TRANSPARENT_COLOR;\
|
||||
var frame = pskl.model.Frame.fromPixelGrid(' + grid + ');\
|
||||
var B = "#0000FF", T = Constants.TRANSPARENT_COLOR;\
|
||||
var R = "#FF0000", G = "#00FF00";\
|
||||
var grid = pskl.utils.FrameUtils.toFrameGrid(' + grid + ');\
|
||||
var frame = pskl.model.Frame.fromPixelGrid(grid);\
|
||||
var layer = pskl.model.Layer.fromFrames("l1", [frame]);\
|
||||
var piskel = pskl.model.Piskel.fromLayers([layer], 12, {name : "test", description : ""});\
|
||||
pskl.app.piskelController.setPiskel(piskel);\
|
||||
@@ -38,12 +40,17 @@ function setPiskelFromGrid(grid) {
|
||||
function piskelFrameEqualsGrid(grid, layer, frame) {
|
||||
return casper.evaluate(
|
||||
'function () {\
|
||||
var B = "#000000", T = Constants.TRANSPARENT_COLOR;\
|
||||
var B = "#0000FF", T = Constants.TRANSPARENT_COLOR;\
|
||||
var R = "#FF0000", G = "#00FF00";\
|
||||
var piskel = pskl.app.piskelController.getPiskel();\
|
||||
var frame = piskel.getLayerAt(' + layer +').getFrameAt(' + frame + ');\
|
||||
var grid = ' + grid +';\
|
||||
var isValid = true;\
|
||||
var log = [];\
|
||||
frame.forEachPixel(function (color, col, row) {\
|
||||
if (pskl.utils.colorToInt(color) !== pskl.utils.colorToInt(grid[row][col])) {\
|
||||
log.push(color, grid[row][col]);\
|
||||
}\
|
||||
isValid = isValid && pskl.utils.colorToInt(color) === pskl.utils.colorToInt(grid[row][col]);\
|
||||
});\
|
||||
return isValid;\
|
||||
@@ -57,6 +64,16 @@ function isDrawerExpanded() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the provided piskel specific event.
|
||||
*
|
||||
* @param {String} eventName
|
||||
* name of the event to listen to
|
||||
* @param {Function} onSuccess
|
||||
* callback to call when the event is successfully catched
|
||||
* @param {Function} onError
|
||||
* callback to call when failing to get the event (most likely, timeout)
|
||||
*/
|
||||
function waitForEvent(eventName, onSuccess, onError) {
|
||||
var cleanup = function () {
|
||||
casper.evaluate(
|
||||
@@ -89,3 +106,27 @@ function waitForEvent(eventName, onSuccess, onError) {
|
||||
});\
|
||||
}');
|
||||
}
|
||||
|
||||
function replaceFunction(test, path, method) {
|
||||
// Check the path provided corresponds to an existing method, otherwise the
|
||||
// test probably needs to be updated.
|
||||
test.assertEquals(evalLine('typeof ' + path),'function',
|
||||
'The prototype of GifExportController still contains downloadImageData_ as a function');
|
||||
|
||||
// Replace the method in content.
|
||||
casper.evaluate('function () {' + path + ' = ' + method + '}');
|
||||
}
|
||||
|
||||
function setPiskelFromImageSrc(src) {
|
||||
casper.evaluate(
|
||||
'function () {\
|
||||
pskl.utils.FrameUtils.createFromImageSrc("' + src + '", false, function (frame) {\
|
||||
var layer = pskl.model.Layer.fromFrames("l1", [frame]);\
|
||||
var piskel = pskl.model.Piskel.fromLayers([layer], 12, {\
|
||||
name: "piskel",\
|
||||
description: "description"\
|
||||
});\
|
||||
pskl.app.piskelController.setPiskel(piskel);\
|
||||
});\
|
||||
}');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user