35 lines
2.5 KiB
Lua
35 lines
2.5 KiB
Lua
local root = arg[1];
|
|
local frames, state, launches, quits, result = {}, 0, 0, 0, 1;
|
|
local methods = {};
|
|
function methods:SetScript(k,f) self[k] = f; end
|
|
function methods:Show() self.shown = true; end
|
|
function methods:Hide() self.shown = false; end
|
|
function methods:IsShown() return self.shown; end
|
|
function methods:CreateTexture() return setmetatable({}, {__index=methods}); end
|
|
function methods:CreateFontString() return setmetatable({}, {__index=methods}); end
|
|
for _, name in ipairs({'SetSize','SetPoint','SetText','SetFrameStrata','EnableMouse','SetAllPoints','SetColorTexture','SetWidth'}) do methods[name]=function() end; end
|
|
function CreateFrame(kind,name,parent,template)
|
|
local f=setmetatable({name=name,parent=parent,shown=true}, {__index=methods}); frames[#frames+1]=f; return f;
|
|
end
|
|
GlueParent=CreateFrame('Frame'); AccountLogin=CreateFrame('Frame'); CharacterSelect=CreateFrame('Frame'); CharacterSelect:Hide();
|
|
C_Login={GetTurtleRealmSnapshot=function(q,r,c) assert(r==0 and c==0); if q==14 then return state; end assert(q==15); launches=launches+1; return result; end};
|
|
ForceQuit=function() quits=quits+1; end;
|
|
dofile(root..'/compat/glue/octo_update.lua');
|
|
local button, dialog, accept, poll = frames[4],frames[5],frames[6],frames[8];
|
|
assert(C_OctoUpdate.GetState()=='unknown'); poll:OnUpdate(1); assert(not button.shown);
|
|
state=1; assert(C_OctoUpdate.GetState()=='current'); poll:OnUpdate(1); assert(not button.shown);
|
|
state=2; poll:OnUpdate(1); assert(button.shown and launches==0);
|
|
button:OnClick(); assert(dialog.shown and launches==0); frames[7]:OnClick(); assert(not dialog.shown and launches==0);
|
|
result=0; button:OnClick(); accept:OnClick(); assert(launches==1 and quits==0);
|
|
result=1; accept:OnClick(); assert(launches==2 and quits==1);
|
|
ForceQuit=nil; assert(not C_OctoUpdate.ApplyAndRestart() and launches==2);
|
|
AccountLogin:Hide(); CharacterSelect:Show(); poll:OnUpdate(1); assert(button.shown);
|
|
CharacterSelect:Hide(); poll:OnUpdate(1); assert(not button.shown and not dialog.shown);
|
|
C_Login.GetTurtleRealmSnapshot=function() error('unavailable') end; assert(C_OctoUpdate.GetState()=='unknown');
|
|
-- Script-before-XML: no button is constructed until the glue root exists.
|
|
local count=#frames; C_OctoUpdate=nil; GlueParent=nil;
|
|
dofile(root..'/compat/glue/octo_update.lua');
|
|
assert(#frames==count+1); local bootstrap=frames[#frames]; bootstrap:OnUpdate(1); assert(#frames==count+1);
|
|
GlueParent=CreateFrame('Frame'); bootstrap:OnUpdate(1); assert(bootstrap.OnUpdate==nil and not bootstrap.shown);
|
|
print('update glue: state, confirmation, failed launch and quit ordering passed');
|