"""Check a fresh show page keeps its Back control and description in the safe area.""" import re from device import screenshot from verify_ui import launch,key,focused,wait,focus,labels,snapshot launch();key(22,2);focused('TV Shows');key(20);focused('Discover');key(22);focused('Library');key(23) wait(lambda r:any(x.startswith('All genres') for x in labels(r)),'Show library loaded');focused('Library');key(20) if '3 Body Problem' not in focus(snapshot()):key(21) focused('3 Body Problem');key(23);focused('Watch next') root=snapshot();screenshot('show-layout-current') title=next(n for n in root.iter('node') if n.get('text')=='3 Body Problem') bounds=list(map(int,re.findall(r'\d+',title.get('bounds')))) back=next((n for n in root.iter('node') if n.get('content-desc')=='Back'),None) print('Title bounds:',bounds,'Back visible:',back is not None,flush=True) assert bounds[1]>=88,'Show title was scrolled above the safe header area on initial focus' assert back is not None,'Back control must remain visible on initial show entry' back_bounds=list(map(int,re.findall(r'\d+',back.get('bounds')))) assert back_bounds[1]>=0 and back_bounds[3]>back_bounds[1],'Back control must stay inside the visible header' assert 'Seasons' in labels(root),'Seasons must lead the rows beneath show information' print('PASS safe show header and Seasons first on initial entry')