From bef770c2b322febf3cccb0a80d30ee26a90036f6 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sat, 13 Apr 2019 16:30:58 -0300 Subject: [PATCH] Update some tests with the new app.activeFrame/Layer behavior --- scripts/app_active.lua | 17 ++++++++++------- scripts/app_command.lua | 6 ++++++ scripts/tools.lua | 11 +++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/app_active.lua b/scripts/app_active.lua index 174e10182..c01eb15d9 100644 --- a/scripts/app_active.lua +++ b/scripts/app_active.lua @@ -1,4 +1,4 @@ --- Copyright (C) 2018 Igara Studio S.A. +-- Copyright (C) 2018-2019 Igara Studio S.A. -- -- This file is released under the terms of the MIT license. -- Read LICENSE.txt for more information. @@ -6,8 +6,6 @@ local s = Sprite(32, 64) assert(s == app.activeSprite) assert(s == app.site.sprite) -assert(s == app.activeCel.sprite) -assert(s == app.site.cel.sprite) assert(s == app.activeFrame.sprite) assert(s == app.site.frame.sprite) assert(1 == app.activeFrame.frameNumber) @@ -15,8 +13,13 @@ assert(1 == app.site.frame.frameNumber) assert(1 == app.site.frameNumber) assert(0.100 == app.activeFrame.duration) -- Default frame duration assert(0.100 == app.site.frame.duration) +assert(s == app.activeLayer.sprite) +assert(s == app.site.layer.sprite) +assert(s == app.activeCel.sprite) +assert(s == app.site.cel.sprite) --- TODO fix these tests when there is no UI ---app.command.NewFrame() ---assert(2 == app.activeFrame.frameNumber) ---assert(0.100 == app.activeFrame.duration) -- Default frame duration +app.activeFrame.duration = 0.8 + +app.command.NewFrame() +assert(2 == app.activeFrame.frameNumber) +assert(0.8 == app.activeFrame.duration) -- Copy frame duration of previous frame diff --git a/scripts/app_command.lua b/scripts/app_command.lua index 6013f8d0f..3cb51064d 100644 --- a/scripts/app_command.lua +++ b/scripts/app_command.lua @@ -1,3 +1,4 @@ +-- Copyright (C) 2019 Igara Studio S.A. -- Copyright (C) 2018 David Capello -- -- This file is released under the terms of the MIT license. @@ -26,17 +27,22 @@ do -- NewLayer/RemoveLayer assert(#s.layers == 1) local lay = s.layers[1] app.command.NewLayer{top=true} + local lay2 = app.activeLayer assert(#s.layers == 2) assert(s.layers[2].isImage) app.command.NewLayer{top=true, group=true} + local lay3 = app.activeLayer assert(#s.layers == 3) assert(s.layers[3].isGroup) + assert(app.activeLayer == lay3) app.command.RemoveLayer() + assert(app.activeLayer == lay2) assert(#s.layers == 2) app.command.RemoveLayer() + assert(app.activeLayer == lay) assert(#s.layers == 1) end diff --git a/scripts/tools.lua b/scripts/tools.lua index 7b4b4eef6..6415909b1 100644 --- a/scripts/tools.lua +++ b/scripts/tools.lua @@ -178,8 +178,15 @@ do -- required size. app.activeTool = 'pencil' app.useTool{ color=red, cel=bgCel1, points={ Point(0, 0) }} - app.useTool{ color=red, cel=bgCel2, points={ Point(1, 0) }} - app.useTool{ color=yellow, cel=fgCel1, points={ Point(1, 1) }} + app.useTool{ color=red, layer=bgCel2.layer, frame=bgCel2.frame, points={ Point(1, 0) }} + + -- After using the tool in bgCel2, the activeFrame is the frame + -- number 2. + assert(bgCel2.frame == app.activeFrame) + assert(bgCel2.frame == fgCel2.frame) + + app.activeFrame = fgCel1.frame + app.useTool{ color=yellow, layer=fgCel1.layer, points={ Point(1, 1) }} app.useTool{ color=yellow, cel=fgCel2, points={ Point(2, 1) }} assert(bgCel1.bounds == Rectangle(0, 0, 1, 1))