local root=assert(arg[1]);local clock=100;local combat=false;local where='none';local width=1920 local P={Localized=function(a)return a end,hardwareProfile={checkedAt=100,loaded=true,thermalCoverage="full"}} Enum={PlayerSwingType={MainHand=0,OffHand=1,Ranged=2}} RuenUIDB={};RuenUICharacter={};UIParent={} local made={};local function noop()end function CreateFrame(_,name) local f={scripts={},shown=false} for _,k in ipairs({'SetSize','SetPoint','SetFrameStrata','EnableMouse','SetHeight','SetMinMaxValues','SetStatusBarTexture','SetStatusBarColor','RegisterEvent','RegisterUnitEvent','SetWidth','ClearAllPoints','SetAllPoints','SetColorTexture'})do f[k]=noop end function f:SetScript(k,v)self.scripts[k]=v end function f:Show()self.shown=true end;function f:Hide()self.shown=false end function f:SetValue(v)self.value=v end;function f:SetAlpha(v)self.alpha=v end function f:CreateTexture()return CreateFrame('Texture')end made[#made+1]=f;if name then _G[name]=f end;return f end function GetTime()return clock end;function time()return clock end function InCombatLockdown()return combat end local speeds={2,2.5,3};function UnitAttackSpeed()return unpack(speeds)end local secret={};function issecretvalue(v)return v==secret end assert(loadfile(root..'SwingTimers.lua'))('test',P) P.InitializeSwingTimers(function()return true end) local dock=RuenSwingTimers local event=dock.scripts.OnEvent assert(not dock.shown and not dock.scripts.OnUpdate) event(dock,'PLAYER_SWING',2,0);assert(dock.shown and dock.byType[0].shown) clock=101;dock.scripts.OnUpdate();assert(dock.byType[0].value==.5) event(dock,'PLAYER_SWING',3,2);event(dock,'PLAYER_SWING',2.5,1) assert(dock.byType[1].shown and dock.byType[2].shown) clock=105;dock.scripts.OnUpdate();assert(not dock.shown and not dock.scripts.OnUpdate) event(dock,'PLAYER_SWING',secret,0);event(dock,'PLAYER_SWING',3,secret);assert(not dock.shown) event(dock,'PLAYER_SWING',2,0);event(dock,'PLAYER_REGEN_ENABLED');assert(not dock.shown) event(dock,'PLAYER_SWING',2,1);speeds={2};event(dock,'UNIT_INVENTORY_CHANGED','player');assert(not dock.shown) combat=true;P.SwingCommand('preview');assert(not dock.shown);combat=false P.SwingCommand('preview');assert(dock.shown);P.SwingCommand('off');assert(not dock.shown and not dock.scripts.OnUpdate) print('PASS: three native swing lanes, progress, fade, no idle ticks, equipment, combat end, secret values, preview and off') local cvars={};local writes=0 C_CVar={GetCVar=function(k)return cvars[k] or '2'end,SetCVar=function(k,v)assert(not combat,'graphics modified in combat');writes=writes+1;cvars[k]=tostring(v)end} function IsGraphicsSettingValueSupported()return 0 end function IsInInstance()return where~='none',where end function GetPhysicalScreenSize()return width,1080 end assert(loadfile(root..'Optimizer.lua'))('test',P);P.InitializeOptimizer();local f=made[#made] P.OptimizerCommand('start');assert(cvars.RAIDsettingsEnabled=='1' and cvars.RenderScale=='1') local function frames(n,dt)for _=1,n do clock=clock+dt; if f.scripts.OnUpdate then f.scripts.OnUpdate(f,dt)end end end -- Two passing windows per tier, bounded at eight windows. frames(72*600,1/72) local d=RuenUIDB.optimizer assert(d.profiles.world.calibrated and d.profiles.world.metTarget,'world should pass') assert(not d.profiles.raid.calibrated,'solo must not validate raid') assert(cvars.maxFPS=='60','trial cap leaked') assert(not f.scripts.OnUpdate,'settled optimizer must not poll every frame') where='raid';f.scripts.OnEvent(f,'ZONE_CHANGED_NEW_AREA');frames(72*61,1/72) combat=true;local before=writes;frames(72*120,1/72);assert(writes==before,'combat edits occurred') combat=false;f.scripts.OnEvent(f,'PLAYER_REGEN_ENABLED');frames(72*500,1/72) assert(d.profiles.raid.calibrated,'raid did not calibrate') assert(not f.scripts.OnUpdate,'settled raid optimizer must sleep') P.OptimizerCommand('restore');assert(not RuenUIDB.optimizer and cvars.RAIDsettingsEnabled=='2') -- Sustained low performance chooses the low tier and reports unmet target. where='none';P.hardwareProfile={};P.OptimizerCommand('start');frames(25*600,1/25) d=RuenUIDB.optimizer;assert(d.profiles.world.calibrated and not d.profiles.world.metTarget and d.profiles.world.tier==1) P.OptimizerCommand('pause');assert(not f.scripts.OnUpdate and not d.enabled) P.hardwareProfile={checkedAt=clock,loaded=true,thermalPressure=true};P.OptimizerCommand('start') assert(d.target==45 and d.ceiling==2,'thermal evidence ignored') P.OptimizerCommand('pause') print('PASS: headroom calibration, separate real-world/raid tests, actual frame percentiles, combat deferral, thermal input, pause and exact undo')