Files
WoW-Hybrid-gateway/tests/native_guild_chat_focus_test.lua
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

24 lines
2.7 KiB
Lua

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 child=read(arg[1]);local xml=read(arg[2]);local toc=read(arg[3]);local original=read(arg[4]);
local function body(source,name)return assert(source:match("(function "..name.."%(self%).-\nend)"));end
assert(toc:find("## SavedVariablesPerCharacter: g_clubIdToSeenApplicants, g_sourceGuildKeepChatFocused",1,true));
assert(xml:find('parentKey="KeepChatFocused" inherits="UICheckButtonTemplate"',1,true));
assert(xml:find('self:SetTextInsets(0, 156, 0, 0);',1,true));
assert(xml:find('<OnEscapePressed function="EditBox_ClearFocus"/>',1,true));
assert(body(child,"CommunitiesChatEditBox_OnHide")==body(original,"CommunitiesChatEditBox_OnHide"));
assert(body(child,"CommunitiesChatEditBox_OnFocusGained")==body(original,"CommunitiesChatEditBox_OnFocusGained"));
assert(load(body(child,"CommunitiesChatKeepFocus_OnLoad")))();
assert(load(body(child,"CommunitiesChatKeepFocus_OnClick")))();
assert(load(body(child,"CommunitiesChatEditBox_OnEnterPressed")))();
local checkbox={Text={SetText=function(self,s)self.text=s end},SetChecked=function(self,b)self.checked=b end,GetChecked=function(self)return self.checked end};
CommunitiesChatKeepFocus_OnLoad(checkbox);assert(checkbox.checked==false and checkbox.Text.text=="Keep chat focused");
local sent={};local parent={Chat={SendMessage=function(_,message)sent[#sent+1]=message end}};
local edit={text="one",cleared=0,focused=0,GetText=function(self)return self.text end,SetText=function(self,s)self.text=s end,GetParent=function()return parent end,ClearFocus=function(self)self.cleared=self.cleared+1 end,SetFocus=function(self)self.focused=self.focused+1 end};
CommunitiesChatEditBox_OnEnterPressed(edit);assert(#sent==1 and sent[1]=="one" and edit.text=="" and edit.cleared==1 and edit.focused==0);
checkbox.checked=true;CommunitiesChatKeepFocus_OnClick(checkbox);assert(g_sourceGuildKeepChatFocused==true);
edit.text="two";CommunitiesChatEditBox_OnEnterPressed(edit);assert(#sent==2 and sent[2]=="two" and edit.text=="" and edit.cleared==1 and edit.focused==1);
CommunitiesChatEditBox_OnEnterPressed(edit);assert(#sent==2 and edit.focused==2); -- empty Enter does not resend
local nextView={Text=checkbox.Text,SetChecked=checkbox.SetChecked};CommunitiesChatKeepFocus_OnLoad(nextView);assert(nextView.checked==true); -- retained native saved value
checkbox.checked=false;CommunitiesChatKeepFocus_OnClick(checkbox);edit.text="three";CommunitiesChatEditBox_OnEnterPressed(edit);assert(#sent==3 and edit.cleared==2 and edit.focused==2);
print("PASS frozen original chat Enter sends once/clears text, default-off focus, on focus retention, native saved preference, unchanged Escape/hide/focus-gained")