Kaleido/scripts/verify_ui.py
Elijah 2b585badac
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m27s
Initial Beta build
2026-10-24 09:09:55 -07:00

89 lines
5.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Remote-only UI regression checks on the authorized onn; captures remain private."""
import argparse,json,pathlib,re,sys,time,xml.etree.ElementTree as ET
sys.path.insert(0,str(pathlib.Path(__file__).resolve().parent))
from device import adb,OUT,screenshot
results=[]
def key(code,count=1):
for _ in range(count):
adb('shell','input','keyevent',str(code));time.sleep(.22)
def snapshot():
adb('shell','uiautomator','dump','/data/local/tmp/kaleido-window.xml')
return ET.fromstring(adb('shell','cat','/data/local/tmp/kaleido-window.xml'))
def labels(root):return [n.get('text','') for n in root.iter('node') if n.get('text')]
def focus(root):
n=next((n for n in root.iter('node') if n.get('focused')=='true'),None)
if n is None:return ''
return n.get('content-desc','') or ' '.join(labels(n))
def wait(check,description,timeout=25):
deadline=time.monotonic()+timeout
while time.monotonic()<deadline:
root=snapshot()
if check(root):return root
time.sleep(.2)
raise AssertionError(description+'; last focus='+focus(root)+'; labels='+str(labels(root)[:10]))
def text(value):return wait(lambda root:value in labels(root),'Expected text '+value)
def focused(value):return wait(lambda root:value in focus(root),'Expected focus '+value)
def passed(name):results.append(name);print('PASS '+name,flush=True)
def capture(name):time.sleep(.4);screenshot('final-'+name)
def launch():
adb('shell','am','force-stop','tv.kaleido.app')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity')
text('Continue Watching')
wait(lambda r:labels(r).count('KALEIDO')==1,'Cold-start splash must finish')
focused('Home')
def browse():
launch();key(20);wait(lambda r:focus(r) in ('Play','Resume'),'Home hero action');capture('home')
key(20);wait(lambda r:bool(focus(r)) and focus(r) not in ('Home','Play','Resume'),'Continue Watching focus');capture('home-continue')
passed('Large cinematic Home hero and separate landscape Continue Watching')
key(22);selected=focus(snapshot());key(23)
wait(lambda r:any(x.startswith('Resume') or x=='Play' for x in labels(r)),'Playable details')
key(4);focused(selected);passed('Discovery details returns to the same focused card')
key(19);wait(lambda r:focus(r) in ('Play','Resume'),'Return to Home hero');key(19);focused('Home');key(22);text('Recently released');focused('Movies')
capture('movies-discover');key(20);focused('Discover');key(22);focused('Library');key(23)
text('All genres ⌄');focused('Library');capture('movies-library')
passed('Movies prioritizes recent releases and retains a separate filtered A-Z grid')
key(20);wait(lambda r:bool(focus(r)) and 'Library' not in focus(r),'Library content or filter focus')
key(4);focused('Discover');key(19);focused('Movies');key(22)
text('Next episodes');focused('TV Shows');capture('tv-discover')
key(20);focused('Discover');key(20);wait(lambda r:bool(focus(r)) and focus(r)!='Discover','TV next episode focus')
capture('tv-next-episodes');key(20);text('New seasons');capture('tv-new-seasons');key(20);text('New episodes');capture('tv-new-episodes')
passed('TV prioritizes next episodes, new seasons, and new episodes')
key(4);focused('Home');passed('Section Back returns to Home navigation')
key(22,4);focused('Settings');key(23);text('Settings');focused('Sign in with Plex');key(23)
text('Sign in to Plex');text('plex.tv/link')
wait(lambda r:any(re.fullmatch(r'[A-Z0-9]{4,6}',s) for s in labels(r)),'Live Plex PIN')
capture('plex-sign-in');key(4);text('Settings');key(4);focused('Home')
passed('Plex account linking obtains a real PIN and cancellation preserves the session')
def player():
adb('shell','am','force-stop','tv.kaleido.app')
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','9776','--el','testOffset','90000','--ei','testMode','2')
time.sleep(12);key(127);focused('Play');capture('player')
passed('Compact player controls over actual video')
key(19);focused('Playback timeline');key(22);capture('timeline');key(20);focused('Play')
passed('D-pad Up focuses timeline, Right seeks, Down returns to play')
key(22,2);focused('Audio tracks');key(23);text('Audio');capture('audio')
key(4);focused('Audio tracks');key(22);focused('Subtitles');key(23);text('Off');capture('subtitles')
passed('Audio and subtitle panels open, close, and restore focus')
key(4);focused('Subtitles');key(22);focused('Playback options');key(23);text('Playback options')
key(20,3);focused('Speed');key(23);text('Playback speed');focused('1.0×');key(20);focused('1.25×');key(23)
focused('Playback options');key(23);text('Speed · 1.25×');key(4);focused('Playback options')
key(23);text('Playback options');key(23);text('Playback mode');focused('Transcode');key(19);focused('Direct stream');key(23)
focused('Playback options');time.sleep(5);key(23);text('Mode · Direct stream');key(4);focused('Playback options')
passed('Player gear changes speed and Direct stream while retaining focus')
key(4)
wait(lambda r:focus(r)=='' and '2 Fast 2 Furious' not in labels(r),'Controls hidden by Back')
key(23);focused('Play');key(126);time.sleep(6)
wait(lambda r:'2 Fast 2 Furious' not in labels(r),'Controls auto-hide during playback')
passed('OK reveals controls; Back and playback timer hide them')
key(4);text('Continue Watching');passed('Back exits playback to live home')
if __name__=='__main__':
parser=argparse.ArgumentParser();parser.add_argument('phase',choices=['browse','player']);args=parser.parse_args()
try:
globals()[args.phase]()
finally:
(OUT/('ui-'+args.phase+'-results.json')).write_text(json.dumps(results,indent=2))
print(f'Completed {len(results)} UI checks',flush=True)