Files
ShaguTweaks-ClassicAPI/tests/test_actionbar_grid.lua
T

17 lines
1.4 KiB
Lua

local root=(arg[1] or '.')..'/'
local update,events
ShaguTweaks={GetGlobalEnv=function() return getfenv(0) end,API={IsSupportedRuntime=function() return true end},hooksecurefunc=function(_,fn) update=fn end}
CreateFrame=function() events={RegisterEvent=function() end,SetScript=function(self,_,fn) self.fire=fn end};return events end
ActionButton_ShowGrid=function(b) b.showgrid=b.showgrid+1;b.shown=true end
ActionButton_HideGrid=function(b) b.showgrid=b.showgrid-1;if b.showgrid==0 and not b.action then b.shown=false end end
ActionButton1={showgrid=0,shown=false};ActionButton2={showgrid=0,shown=true,action=true}
BonusActionButton1={showgrid=0,shown=false}
dofile(root..'mods/actionbar-grid.lua')
ALWAYS_SHOW_MULTIBARS="1";events.fire();update();assert(ActionButton1.showgrid==1 and ActionButton1.shown and BonusActionButton1.shown)
ActionButton_ShowGrid(ActionButton1) -- dragging adds its own grid reference
ALWAYS_SHOW_MULTIBARS=0;update();assert(ActionButton1.showgrid==1 and ActionButton1.shown)
ActionButton_HideGrid(ActionButton1);assert(not ActionButton1.shown and ActionButton2.shown and not BonusActionButton1.shown)
update();assert(ActionButton1.showgrid==0)
ALWAYS_SHOW_MULTIBARS=1;update();assert(ActionButton1.shown and ActionButton1.showgrid==1)
print('Main/bonus action grids: native preference, idempotence, toggle off/on, drag references and filled buttons passed')