Files
WoW-Hybrid-gateway/tests/character_control_test.py
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

36 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""Actual original roster-button glyphs; no UI input or credential fixtures."""
import io,os,subprocess,sys
from pathlib import Path
from PIL import Image
root=Path(__file__).resolve().parents[1];sys.path.insert(0,str(root/'ops'))
from client_ui import CHARACTER_CONTROL_BOXES,character_select_control_images,is_character_select_screen,native_character_select_control_images
from client_session import classify
pixels=Image.new('RGB',(1920,1080),'black');fixture=root/'docs/evidence/automation/character-controls'
for name,box in CHARACTER_CONTROL_BOXES.items():
image=Image.open(fixture/(name.lower().replace(' ','-')+'.png'))
assert image.size==(box[2]-box[0],box[3]-box[1]);pixels.paste(image,box[:2])
recognized=[]
for expected,image in character_select_control_images(pixels).items():
encoded=io.BytesIO();image.save(encoded,format='PNG')
result=subprocess.run(['tesseract','stdin','stdout','--psm','7'],input=encoded.getvalue(),capture_output=True,env=dict(os.environ,OMP_THREAD_LIMIT='1'),check=True)
text=result.stdout.decode().strip();assert text==expected,'Actual outlined control remains unrecognized'
recognized.append(text)
controls=' '.join(recognized)
assert is_character_select_screen(controls) and classify(controls+' Elwynn Forest')=='characters'
assert classify('Email or phone Password Remember account Log in '+controls+' Elwynn Forest')=='login'
assert classify('Disconnected '+controls+' Elwynn Forest')=='disconnected'
for partial in ('Enter World Elwynn Forest','Create Character Elwynn Forest','Toggle Character List Elwynn Forest'):
assert classify(partial)=='loading-or-unknown','Partial roster markers must not authorize world input'
assert classify('Elwynn Forest')=='world'
assert character_select_control_images(Image.new('RGB',(800,600)))=={}
print('Actual outlined Enter World/Create Character glyphs recognized independently of names; login/disconnect precedence, partial-roster world rejection and exact-size guard pass. No client input.')
pixels=Image.new('RGB',(2560,1440));pixels.paste(Image.open(fixture/'ghost-create-character-native.png'),(2160,1294))
views=native_character_select_control_images(pixels)
assert len(views)==1
b=io.BytesIO();views['Create Character'].save(b,format='PNG')
r=subprocess.run(['tesseract','stdin','stdout','--psm','7'],input=b.getvalue(),capture_output=True,env=dict(os.environ,OMP_THREAD_LIMIT='1'),check=True)
assert r.stdout.decode().strip()=='Create Character'
assert native_character_select_control_images(Image.new('RGB',(800,600)))=={}