Files
WoW-Hybrid-gateway/tests/native_source_store_preview_geometry_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

87 lines
6.0 KiB
Lua

-- Geometry boundary from original SmallStoreCard.Layout + actual atlas sizes.
-- Runtime rendering remains a distinct root-owned acceptance.
local root=arg[1] or '.'
local function read(path)local f=assert(io.open(path,'rb'));local s=f:read('*a');f:close();return s:gsub('\r\n','\n'):gsub('[ \t]+\n','\n')end
local function extract(s,signature)
local a=assert(s:find(signature..'\n',1,true));local b=assert(s:find('\nend',a,true));return s:sub(a,b+3)
end
local original=root..'/runtime/continuation-20261113/codex/PTR-feedback-disable/native70334-ui/interface/addons/blizzard_storeui/'
local xml=read(original..'blizzard_shared_storeuipatchwerk.xml')
local methods={}
local region
region=function(parent)
return setmetatable({parent=parent,width=0,height=0,points={},shown=true,scripts={},text='',mouse=false,wheel=false,isLeftButtonDown=false,isRightButtonDown=false},
{__index=function(t,k)
if methods[k]then return methods[k]end
if k=='OnMouseDown' or k=='OnMouseUp' or k=='OnMouseWheel' then return function()end end
local child=region(t);rawset(t,k,child);return child
end})
end
function methods:SetSize(w,h)self.width=w;self.height=h end
function methods:GetWidth()return self.width end
function methods:GetHeight()return self.height end
function methods:ClearAllPoints()self.points={}end
function methods:SetPoint(point,a,b,c,d)
local relative,relativePoint,x,y
if type(a)=='table' then relative,relativePoint,x,y=a,b,c or 0,d or 0
else relative,relativePoint,x,y=self.parent,point,a or 0,b or 0 end
self.points[#self.points+1]={point,relative,relativePoint,x,y}
end
function methods:SetAllPoints(parent)
self:ClearAllPoints();self:SetPoint('TOPLEFT',parent,'TOPLEFT',0,0);self:SetPoint('BOTTOMRIGHT',parent,'BOTTOMRIGHT',0,0)
end
function methods:GetNumPoints()return #self.points end
function methods:GetPoint(i)return table.unpack(self.points[i],1,5)end
function methods:SetViewInsets(...)self.insets={...}end
function methods:SetShown(v)self.shown=v end
function methods:Show()self.shown=true end
function methods:Hide()self.shown=false end
function methods:IsShown()return self.shown end
function methods:SetText(v)self.text=v end
function methods:GetText()return self.text end
function methods:SetTextColor()end
function methods:GetScript(k)return self.scripts[k]end
function methods:SetScript(k,v)self.scripts[k]=v end
function methods:EnableMouse(v)self.mouse=v end
function methods:IsMouseEnabled()return self.mouse end
function methods:EnableMouseWheel(v)self.wheel=v end
function methods:IsMouseWheelEnabled()return self.wheel end
function methods:GetID()return self.id end
local function atlasSize(name,target)
local w,h=xml:match('<Texture name="'..name..'"[^>]*>%s*<Size x="(%d+)" y="(%d+)"')
assert(w and h,name);target:SetSize(tonumber(w),tonumber(h))
end
local card=region();card.id=42
atlasSize('store%-card',card.Card);atlasSize('store%-card%-selected',card.SelectedTexture);atlasSize('store%-card%-hover',card.HighlightTexture)
assert(card.Card.width==146 and card.Card.height==209 and card.SelectedTexture.width==140 and card.SelectedTexture.height==203)
StoreFrame_GetCellPixelSize=function(template)assert(template=='SmallStoreCardTemplate');return 146,209 end
SmallStoreCardMixin={}
assert(load(extract(read(original..'blizzard_shared_smallproductcardtemplates.lua'),'function SmallStoreCardMixin:Layout()')))()
unpack=table.unpack;SmallStoreCardMixin.Layout(card)
assert(card.Card:GetNumPoints()==1 and card.Card.points[1][1]=='CENTER' and card.Card.width==146)
assert(card.SelectedTexture:GetNumPoints()==1 and card.HighlightTexture:GetNumPoints()==1 and card.ProductName.width==120)
local oldInsets=table.concat(card.ModelScene.insets,',')
StoreFrame=region();StoreFrame.PageText.text='1 / 3'
StoreFrame.productCardPoolCollection={EnumerateActive=function()local done=false;return function()if not done then done=true;return card end end end}
local source=read(root..'/ops/native_source_store_secure.lua')
local first=assert(source:find('local function sourceGeometry(',1,true));local last=assert(source:find('function SourceStore_BeforeSetCategory()',first,true))
local info={sharedData={cards={{sourceEntryID=42}}}}
local provider={GetEntryInfo=function(_,id)assert(id==42);return info end}
ModelSceneMixin={OnMouseDown=function()end,OnMouseUp=function()end,OnMouseWheel=function()end}
StoreFrame_SetSelectedEntryID=function(id)assert(id==42)end;SourceStore_UpdateBuyButton=function()end
assert(load('local sourceStore,sourceShowPreview,sourceInternalPreview=...\n'..source:sub(first,last-1)))(provider,function()return true end,nil)
assert(SourceStore_ShowInternalPreview(info.sharedData.cards))
assert(card.Card:GetNumPoints()==2 and card.Card.points[1][1]=='TOPLEFT' and card.Card.points[1][2]==card and card.Card.points[2][1]=='BOTTOMRIGHT')
for _,texture in ipairs({card.SelectedTexture,card.HighlightTexture})do
assert(texture:GetNumPoints()==2 and texture.points[1][2]==card and texture.points[1][4]==3 and texture.points[1][5]==-3)
assert(texture.points[2][4]==-3 and texture.points[2][5]==3)
end
assert(card.ProductName:GetNumPoints()==2 and card.ProductName.points[1][1]=='BOTTOMLEFT' and card.ProductName.points[2][1]=='BOTTOMRIGHT')
assert(table.concat(card.ModelScene.insets,',')==oldInsets,'geometry-only repair altered proven camera/view insets')
assert(SourceStore_CloseInternalPreview())
assert(card.Card.width==146 and card.Card.height==209 and card.Card:GetNumPoints()==1 and card.Card.points[1][1]=='CENTER')
for _,texture in ipairs({card.SelectedTexture,card.HighlightTexture})do assert(texture.width==140 and texture.height==203 and texture:GetNumPoints()==1 and texture.points[1][1]=='CENTER')end
assert(card.ProductName.width==120 and card.ProductName.height==40 and card.ProductName:GetNumPoints()==1 and card.ProductName.points[1][1]=='BOTTOM' and card.ProductName.points[1][5]==42)
assert(table.concat(card.ModelScene.insets,',')==oldInsets)
print('PASS original small-card atlas/layout reproduces fixed inner regions; focus binds original art/overlays/title to pane and close restores exact browse geometry; native camera/insets unchanged')