36 lines
2.0 KiB
Lua
36 lines
2.0 KiB
Lua
-- Exercise the actual submenu filtering and reuse without the WoW renderer.
|
|
local file=assert(io.open('window.lua'))
|
|
local source=file:read('*a');file:close()
|
|
local first=assert(string.find(source,' frame.ToggleFightList = function',1,true))
|
|
local last=assert(string.find(source,' frame.btnResize =',first,true))
|
|
local function text()
|
|
return {SetText=function(self,value) self.value=value end}
|
|
end
|
|
local list={entries={},fights={},shown=false,
|
|
IsShown=function(self) return self.shown end,
|
|
Show=function(self) self.shown=true end,Hide=function(self) self.shown=false end,
|
|
ClearAllPoints=function() end,SetPoint=function(self,point,anchor) self.anchor=anchor end,
|
|
SetHeight=function(self,value) self.height=value end,
|
|
SetBackdrop=function() end,SetBackdropColor=function() end,SetBackdropBorderColor=function() end}
|
|
for i=1,20 do list.entries[i]={caption=text(),time=text(),Show=list.Show,Hide=list.Hide} end
|
|
local frame={fightList=list,btnFights={},btnWipes={},GetID=function() return 1 end}
|
|
local config={[1]={segment=1}}
|
|
ShaguDPS={fights={list={
|
|
{id=3,kill=true,name='Kill',duration=60},
|
|
{id=2,kill=false,name='Wipe',duration=30},
|
|
{id=1,kill=true,name='Older kill',duration=90},
|
|
}}}
|
|
assert(loadstring('return function(frame,config)\n'..string.sub(source,first,last-1)..'\nend'))()(frame,config)
|
|
frame:ToggleFightList(false)
|
|
assert(list.shown and list.anchor==frame.btnFights and list.entries[1].id==3 and list.entries[2].id==1)
|
|
assert(not list.entries[3].shown,'kill submenu excludes wipes')
|
|
local scratch=list.fights
|
|
frame:ToggleFightList(true)
|
|
assert(list.shown and list.anchor==frame.btnWipes and list.entries[1].id==2)
|
|
assert(not list.entries[2].shown and list.fights==scratch,'wipe submenu filters and reuses storage')
|
|
frame:ToggleFightList(true);assert(not list.shown,'same submenu toggles closed')
|
|
ShaguDPS.fights.list={}
|
|
frame:ToggleFightList(true)
|
|
assert(list.entries[1].id==nil and string.find(list.entries[1].caption.value,'No boss wipes',1,true))
|
|
print('Separate Fights/Wipes submenu filtering and empty-state checks passed (Lua 5.0)')
|