100 lines
6.5 KiB
Lua
100 lines
6.5 KiB
Lua
-- Execute the actual frozen original-asset callback bodies, with transport
|
|
-- mocked at its existing native C_ChatInfo boundary, not a replacement window.
|
|
local function read(path)
|
|
local f=assert(io.open(path,"rb"));local s=f:read("*a");f:close();return (s:gsub("\r\n","\n"));
|
|
end
|
|
local compile=loadstring or load;
|
|
local helper=read(arg[1]);
|
|
local click=function(widget) return GuildControlUI_SourceRankFlag(widget:GetID(), widget:GetChecked()); end
|
|
local nameFocus=function(widget) return GuildControlUI_SourceRankName(widget:GetParent():GetID(), widget:GetText()); end
|
|
if arg[2] then
|
|
local child=helper;local xml=read(arg[2]);
|
|
local callback=assert(child:match("(function GuildControlUI_CheckClicked%(self%).-\nend)"));
|
|
local focus=assert(xml:match("<OnEditFocusLost>(.-)</OnEditFocusLost>"));
|
|
assert(not callback:find("GuildControlSetRankFlag",1,true));
|
|
assert(not focus:find("GuildControlSaveRank",1,true));
|
|
assert(focus:find("GuildControlUI_SourceRankName",1,true));
|
|
assert(child:find('self:RegisterEvent("CHAT_MSG_SYSTEM");',1,true));
|
|
assert(child:find('self:RegisterEvent("PLAYER_GUILD_UPDATE");',1,true));
|
|
assert(child:find('function GuildControlUI_OnShow(self)\n\tGuildControlUI_SourceRankQuery();',1,true));
|
|
assert(child:find('if GuildControlUI_SourceRankEvent(event, message) then return; end',1,true));
|
|
helper=assert(child:match("^(.-)\nBANK_TAB_OFFSET ="));
|
|
assert(compile(callback))();click=GuildControlUI_CheckClicked;
|
|
nameFocus=assert(compile("return function(self)\n"..focus.."\nend"))();
|
|
end
|
|
local sent,errors,timers={},{},{};local refreshed=0;
|
|
local inGuild=false;function IsInGuild() return inGuild; end
|
|
C_ChatInfo={SendAddonMessage=function(prefix,text,channel,target)
|
|
assert(prefix=="GWTURTLE" and channel=="WHISPER" and target=="OwnedLeader");sent[#sent+1]=text;
|
|
end};
|
|
function UnitName(unit)assert(unit=="player");return "OwnedLeader" end
|
|
UIErrorsFrame={AddMessage=function(_,s)errors[#errors+1]=s end};
|
|
C_Timer={After=function(_,f)timers[#timers+1]=f end};
|
|
local filter
|
|
local function register(event, callback) assert(event == "CHAT_MSG_SYSTEM"); filter = callback end
|
|
if os.getenv("GW_TEST_LEGACY_CHAT_FILTER") == "1" then
|
|
ChatFrame_AddMessageEventFilter = register
|
|
else
|
|
ChatFrameUtil = {AddMessageEventFilter = register}
|
|
end
|
|
GuildControlUI={currentRank=2,currFrame={},rankUpdate=function()refreshed=refreshed+1 end};
|
|
SOUNDKIT={IG_MAINMENU_OPTION_CHECKBOX_OFF=1,IG_MAINMENU_OPTION_CHECKBOX_ON=2};function PlaySound()end
|
|
assert(compile(helper))();
|
|
local value=false;local widget={GetID=function()return 13 end,GetChecked=function()return value end};
|
|
GuildControlUI_SourceRankQuery(); -- GuildControlUI_OnLoad and OnShow both call this.
|
|
GuildControlUI_SourceRankEvent("PLAYER_GUILD_UPDATE","player");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD ERROR invalid-or-stale-request");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 21 1 0");
|
|
click(widget);
|
|
assert(#sent==0 and #errors==0 and refreshed==0);
|
|
inGuild=true;
|
|
click(widget);assert(sent[#sent]=="guild1 state" and #errors==1); -- no snapshot, no mutation
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 21 7 0");
|
|
click(widget);assert(sent[#sent]=="guild1 1 21 7 flag 2 13 0");
|
|
local n=#sent;value=true;click(widget);assert(#sent==n); -- pending blocks double click
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 21 8 1");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD CONFIRMED 1");
|
|
click(widget);assert(sent[#sent]=="guild1 2 21 8 flag 2 13 1");
|
|
local before=#errors;local oldRefresh=refreshed;
|
|
GuildControlUI_SourceRankEvent("PLAYER_GUILD_UPDATE","party1");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD REJECTED 1 8");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD ERROR 1 invalid-or-stale-request");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD ERROR invalid-or-stale-request");
|
|
timers[1]();
|
|
assert(#errors==before and refreshed==oldRefresh);
|
|
assert(not GuildControlUI_SourceRankEvent("GUILD_RANKS_UPDATE_ACTIVE_PLAYER"));
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD CONFIRMED 2");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 21 9 2");
|
|
local box={SetTextColor=function()end,startName="Guild Master",GetText=function()return "Guild Masterx"end,GetParent=function()return {GetID=function()return 1 end}end};
|
|
nameFocus(box);assert(sent[#sent]=="guild1 3 21 9 name 1 4775696c64204d617374657278");
|
|
assert(filter(nil,nil,"GWTURTLE1 GUILD STATE 21 9 3") and not filter(nil,nil,"ordinary guild text"));
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD REJECTED 3 server");
|
|
assert(#errors==before+1 and errors[#errors]:find("did not confirm",1,true));
|
|
for i=1,13 do
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 21 "..(9+i).." "..(2+i));
|
|
click({GetID=function()return i end,GetChecked=function()return false end});
|
|
assert(sent[#sent]:match(" flag 2 "..i.." 0$"));
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD CONFIRMED "..(3+i));
|
|
end
|
|
GuildControlUI_SourceRankEvent("PLAYER_GUILD_UPDATE","player");n=#sent;
|
|
click(widget);assert(#sent==n+1 and sent[#sent]=="guild1 state");
|
|
-- A matching local validation error or a genuine mutation timeout is still visible.
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 21 31 16");
|
|
click(widget);before=#errors;
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD ERROR 17 invalid-or-stale-request");
|
|
assert(#errors==before+1 and errors[#errors]:find("did not confirm",1,true));
|
|
click(widget);before=#errors;
|
|
timers[#timers]();assert(#errors==before+1 and errors[#errors]:find("No guild confirmation",1,true));
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 21 32 18");
|
|
click(widget);local late=timers[#timers];before=#errors;n=#sent;
|
|
inGuild=false;GuildControlUI_SourceRankEvent("PLAYER_GUILD_UPDATE","player");
|
|
late();GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD REJECTED 19 8");
|
|
assert(#sent==n and #errors==before);
|
|
inGuild=true;GuildControlUI_SourceRankEvent("PLAYER_GUILD_UPDATE","player");
|
|
assert(#sent==n+1 and sent[#sent]=="guild1 state");
|
|
GuildControlUI_SourceRankEvent("CHAT_MSG_SYSTEM","GWTURTLE1 GUILD STATE 42 1 0");
|
|
click(widget);assert(sent[#sent]=="guild1 20 42 1 flag 2 13 1");
|
|
late();assert(#errors==before);
|
|
assert(refreshed>0);
|
|
print("PASS guild rank query, thirteen flag intents, name edit, confirmation, rejection, timeout and guild change")
|