mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-25 01:43:36 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
5920c09c85
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,3 +1,3 @@
|
||||
[submodule "third_party/json"]
|
||||
path = third_party/json
|
||||
url = https://github.com/rxi/json.lua
|
||||
url = https://github.com/aseprite/json.lua
|
||||
|
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2018-2020 Igara Studio S.A.
|
||||
Copyright (c) 2018-2021 Igara Studio S.A.
|
||||
Copyright (c) 2018 David Capello
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
@ -4,14 +4,14 @@ Test suite for [Aseprite](https://github.com/aseprite/aseprite)
|
||||
to avoid breaking backward compatibility.
|
||||
|
||||
This project is cloned by the
|
||||
[.travis.yml](https://github.com/aseprite/aseprite/blob/master/.travis.yml) file
|
||||
[build.yml](https://github.com/aseprite/aseprite/blob/main/.github/workflows/build.yml) file
|
||||
on Aseprite project to do several automated tests:
|
||||
|
||||
* Save/load file formats correctly. For this we have `.aseprite`, `.png`,
|
||||
`.gif`, etc. files [sprites](https://github.com/aseprite/tests/tree/master/sprites)
|
||||
`.gif`, etc. files [sprites](https://github.com/aseprite/tests/tree/main/sprites)
|
||||
folder.
|
||||
* Test backward compatibility with [Aseprite CLI](https://www.aseprite.org/docs/cli/) options
|
||||
* Future [scripting API](https://github.com/aseprite/api) using [scripts](https://github.com/aseprite/tests/tree/master/scripts)
|
||||
* Future [scripting API](https://github.com/aseprite/api) using [scripts](https://github.com/aseprite/tests/tree/main/scripts)
|
||||
|
||||
## How to run tests?
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
# Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
|
||||
function list_files() {
|
||||
oldwd=$(pwd $PWDARG)
|
||||
@ -177,27 +177,31 @@ cd $oldwd
|
||||
# --save-as group without showing hidden children
|
||||
# https://github.com/aseprite/aseprite/issues/2084#issuecomment-525835889
|
||||
|
||||
if [[ "$(uname)" =~ "MINGW" ]] || [[ "$(uname)" =~ "MSYS" ]] ; then
|
||||
# Ignore this test on Windows because we cannot give * as a parameter (?)
|
||||
echo Do nothing
|
||||
else
|
||||
d=$t/save-as-groups-and-hidden
|
||||
mkdir $d
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer '*' -save-as "$d/g2-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer '*' -ignore-layer items -save-as "$d/g2-all-without-items.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer '*' -ignore-layer gun -save-as "$d/g2-all-without-gun1.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer '*' -ignore-layer sword -save-as "$d/g2-all-without-sword1.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer '*' -ignore-layer items/gun -save-as "$d/g2-all-without-gun2.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer '*' -ignore-layer items/sword -save-as "$d/g2-all-without-sword2.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer '*' -ignore-layer player -save-as "$d/g2-all-without-player.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer \* -save-as "$d/g2-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer \* -ignore-layer items -save-as "$d/g2-all-without-items.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer \* -ignore-layer gun -save-as "$d/g2-all-without-gun1.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer \* -ignore-layer sword -save-as "$d/g2-all-without-sword1.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer \* -ignore-layer items/gun -save-as "$d/g2-all-without-gun2.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer \* -ignore-layer items/sword -save-as "$d/g2-all-without-sword2.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer \* -ignore-layer player -save-as "$d/g2-all-without-player.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer player -save-as "$d/g2-player.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer items -save-as "$d/g2-items.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer 'items/*' -save-as "$d/g2-items-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer items/\* -save-as "$d/g2-items-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer sword -save-as "$d/g2-sword.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups2.aseprite -layer gun -save-as "$d/g2-gun.png" || exit 1
|
||||
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer a -save-as "$d/g3-a.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer b -save-as "$d/g3-b.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer c -save-as "$d/g3-c.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer 'a/*' -save-as "$d/g3-a-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer 'b/*' -save-as "$d/g3-b-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer 'c/*' -save-as "$d/g3-c-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer a/\* -save-as "$d/g3-a-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer b/\* -save-as "$d/g3-b-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer c/\* -save-as "$d/g3-c-all.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer a/a -save-as "$d/g3-aa.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer b/a -save-as "$d/g3-ba.png" || exit 1
|
||||
$ASEPRITE -b sprites/groups3abc.aseprite -layer c/a -save-as "$d/g3-ca.png" || exit 1
|
||||
@ -249,3 +253,4 @@ expect_rendered_layers(img("g3-cb"), g3, { "c/b" })
|
||||
expect_rendered_layers(img("g3-cc"), g3, { "c/c" })
|
||||
EOF
|
||||
$ASEPRITE -b -script "$d/compare.lua" || exit 1
|
||||
fi
|
||||
|
@ -14,7 +14,7 @@ function fail() {
|
||||
}
|
||||
|
||||
function expect() {
|
||||
if [[ $1 != $($2) ]] ; then
|
||||
if [[ $1 != "$($2 | tr -d "\r")" ]] ; then
|
||||
echo "FAILED: $2"
|
||||
echo "EXPECTED: $1"
|
||||
echo "RESULT: $($2)"
|
||||
@ -33,7 +33,7 @@ if [[ "$filter" != "" ]]; then
|
||||
fi
|
||||
|
||||
t=$(mktemp -d)
|
||||
if [[ "$(uname)" =~ "MINGW32" ]] || [[ "$(uname)" =~ "MSYS_NT-10.0" ]] ; then
|
||||
if [[ "$(uname)" =~ "MINGW" ]] || [[ "$(uname)" =~ "MSYS" ]] ; then
|
||||
PWDARG=-W
|
||||
t=$(cd "$t" && pwd $PWDARG)
|
||||
else
|
||||
@ -45,13 +45,14 @@ export ASEPRITE_USER_FOLDER=$t
|
||||
if [[ "$filter" == "" ]] || [[ "console" =~ $filter ]]; then
|
||||
echo ----------------------------------------------------------------------
|
||||
echo "Testing console..."
|
||||
echo "uname=$(uname)"
|
||||
|
||||
$ASEPRITE -b --script scripts/console_assert.lua >$t/tmp 2>&1
|
||||
! grep -q "this should be in the output" $t/tmp && fail "print() text not found in output"
|
||||
! grep -q "assertion failed" $t/tmp && fail "assert() text not found in output"
|
||||
grep -q "this should not be in the output" $t/tmp && fail "text that shouldn't be in the output is"
|
||||
|
||||
if [[ "$(uname)" =~ "MINGW32" ]] || [[ "$(uname)" =~ "MSYS_NT-10.0" ]] ; then
|
||||
if [[ "$(uname)" =~ "MINGW" ]] || [[ "$(uname)" =~ "MSYS" ]] ; then
|
||||
echo Ignore console tests on Windows
|
||||
else
|
||||
$ASEPRITE -b --script scripts/console_print.lua >$t/tmp 2>&1
|
||||
|
@ -52,3 +52,26 @@ do
|
||||
assert(runTestsFound)
|
||||
assert(readmeFound)
|
||||
end
|
||||
|
||||
-- Create directories
|
||||
do
|
||||
assert(fs.makeDirectory("_tmp"))
|
||||
assert(fs.isDirectory("_tmp"))
|
||||
|
||||
assert(fs.makeAllDirectories("_tmp/a/b"))
|
||||
assert(fs.isDirectory("_tmp/a"))
|
||||
assert(fs.isDirectory("_tmp/a/b"))
|
||||
|
||||
assert(fs.removeDirectory("_tmp/a/b"))
|
||||
assert(not fs.isDirectory("_tmp/a/b"))
|
||||
assert(fs.isDirectory("_tmp/a"))
|
||||
|
||||
assert(not fs.removeDirectory("_tmp")) -- Should fail
|
||||
assert(fs.isDirectory("_tmp/a"))
|
||||
assert(fs.isDirectory("_tmp"))
|
||||
|
||||
assert(fs.removeDirectory("_tmp/a"))
|
||||
assert(fs.removeDirectory("_tmp"))
|
||||
assert(not fs.isDirectory("_tmp/a"))
|
||||
assert(not fs.isDirectory("_tmp"))
|
||||
end
|
||||
|
@ -1,10 +1,13 @@
|
||||
-- Copyright (C) 2019 Igara Studio S.A.
|
||||
-- Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
-- Preferences for tools
|
||||
do
|
||||
-- The first time we get the tool preferences in CLI mode, we get
|
||||
-- the default options for this tool (in GUI, we get the current
|
||||
-- user-defined options).
|
||||
local t = app.preferences.tool('pencil')
|
||||
assert(t.opacity == 255)
|
||||
assert(t.tolerance == 0)
|
||||
@ -14,10 +17,10 @@ do
|
||||
t.brush.size = 2
|
||||
assert(t.brush.size == 2)
|
||||
|
||||
-- Getting the tool again will give us the default configuration
|
||||
-- again in batch mode
|
||||
-- Getting the tool again must give us the configuration that was
|
||||
-- set inside the script
|
||||
t = app.preferences.tool('pencil')
|
||||
assert(t.brush.size == 1)
|
||||
assert(t.brush.size == 2)
|
||||
end
|
||||
|
||||
-- Preferences for documents
|
||||
|
55
scripts/paint_bucket.lua
Normal file
55
scripts/paint_bucket.lua
Normal file
@ -0,0 +1,55 @@
|
||||
-- Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
dofile('./test_utils.lua')
|
||||
|
||||
app.activeTool = 'paint_bucket'
|
||||
assert(app.activeTool.id == 'paint_bucket')
|
||||
assert(app.activeBrush.type == BrushType.CIRCLE)
|
||||
assert(app.activeBrush.size == 1)
|
||||
assert(app.activeBrush.angle == 0)
|
||||
assert(app.preferences.tool('paint_bucket').floodfill.pixel_connectivity == 0)
|
||||
|
||||
local function test_paint_bucket(colorMode, a, b, c)
|
||||
local spr = Sprite(4, 4, colorMode)
|
||||
local img = app.activeImage
|
||||
|
||||
array_to_pixels({ a, a, a, a,
|
||||
a, b, b, a,
|
||||
a, a, b, a,
|
||||
a, a, a, b, }, img)
|
||||
|
||||
app.useTool{ points={Point(0, 0)}, color=b }
|
||||
expect_img(img, { b, b, b, b,
|
||||
b, b, b, b,
|
||||
b, b, b, b,
|
||||
b, b, b, b, })
|
||||
|
||||
app.undo()
|
||||
-- FOUR_CONNECTED=0
|
||||
app.preferences.tool('paint_bucket').floodfill.pixel_connectivity = 0
|
||||
assert(app.preferences.tool('paint_bucket').floodfill.pixel_connectivity == 0)
|
||||
app.useTool{ points={Point(1, 1)}, color=c }
|
||||
expect_img(img, { a, a, a, a,
|
||||
a, c, c, a,
|
||||
a, a, c, a,
|
||||
a, a, a, b, })
|
||||
|
||||
app.undo()
|
||||
-- EIGHT_CONNECTED=1
|
||||
app.preferences.tool('paint_bucket').floodfill.pixel_connectivity = 1
|
||||
assert(app.preferences.tool('paint_bucket').floodfill.pixel_connectivity == 1)
|
||||
app.useTool{ points={Point(1, 1)}, color=c }
|
||||
expect_img(img, { a, a, a, a,
|
||||
a, c, c, a,
|
||||
a, a, c, a,
|
||||
a, a, a, c, })
|
||||
end
|
||||
|
||||
local rgba = app.pixelColor.rgba
|
||||
local gray = app.pixelColor.graya
|
||||
test_paint_bucket(ColorMode.RGB, rgba(0, 0, 0), rgba(128, 128, 128), rgba(255, 255, 255))
|
||||
test_paint_bucket(ColorMode.GRAYSCALE, gray(0), gray(128), gray(255))
|
||||
test_paint_bucket(ColorMode.INDEXED, 1, 2, 3)
|
@ -1,4 +1,4 @@
|
||||
-- Copyright (C) 2019 Igara Studio S.A.
|
||||
-- Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
@ -8,7 +8,7 @@ assert(string.sub(tostring(app.version), 1, 1) == "1")
|
||||
assert(string.sub(tostring(app.version), 2, 2) == ".")
|
||||
assert(app.version.major == 1)
|
||||
|
||||
-- We cannot test the specific app.version from the master branch
|
||||
-- We cannot test the specific app.version from the "main" branch
|
||||
-- because it's "1.x-dev" (which is converted to "1.0-dev" as Version object)
|
||||
--assert(app.version > Version("1.2.10-beta4"))
|
||||
|
||||
|
2
third_party/json
vendored
2
third_party/json
vendored
@ -1 +1 @@
|
||||
Subproject commit bee7ee3431133009a97257bde73da8a34e53c15c
|
||||
Subproject commit dbf4b2dd2eb7c23be2773c89eb059dadd6436f94
|
Loading…
x
Reference in New Issue
Block a user