ruen-ui/tests/check-layout-policy.lua

26 lines
1.5 KiB
Lua

local root=assert(arg[1])
local P={}
assert(loadfile(root..'LayoutPolicy.lua'))('RuenUI',P)
local width,height
UIParent={GetWidth=function()return width end,GetHeight=function()return height end}
for _,case in ipairs({{1280,720,380,190},{1366,768,400,190},
{1920,1080,570,230},{2133,1200,620,260},{3840,2160,620,260},
{3840/2.8125,2160/2.8125,400,190}})do
width,height=case[1],case[2]
local w,h=P.DefaultChatSize()
assert(w==case[3] and h==case[4],'incorrect chat size for '..width..'x'..height)
end
local font,size,flags='native-cyrillic-capable-font',12,'OUTLINE'
local changes=0
ChatFrame1={GetFont=function()return font,size,flags end}
function FCF_SetChatWindowFontSize(_,frame,value)assert(frame==ChatFrame1);size=value;changes=changes+1 end
RuenUICharacter={};P.ApplyChatDefaults()
assert(size==14 and changes==1 and RuenUICharacter.chatFontOriginal.size==12)
P.ApplyChatDefaults();assert(changes==1,'font defaults reapplied')
size=16;P.RestoreChatDefaults();assert(size==16,'restore overwrote later font choice')
size=14;P.RestoreChatDefaults();assert(size==12,'font restore failed')
RuenUICharacter={version=5};size=18;P.ApplyChatDefaults();assert(size==18,'upgrade changed existing font')
local count=0;for _ in pairs(P.controlFrameSet)do count=count+1 end
assert(count==10 and #P.controlFrameNames==10,'control declarations inconsistent/duplicated')
print('PASS: responsive chat defaults at 720p-4K/logical UI scale; shared ten-frame reservations, readable fresh-install chat font, idempotency, custom font and upgrade preservation, conditional restore')