All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m41s
120 lines
6.4 KiB
Python
120 lines
6.4 KiB
Python
"""Only 0.4.0 UI changes: TV artwork, category cards, Clear, and quick skip cues."""
|
|
import argparse, json, time, urllib.parse, urllib.request
|
|
from contextlib import contextmanager
|
|
from device import ROOT, adb, screenshot
|
|
from verify_ui import launch, key, focused, wait, focus, labels, snapshot, text, passed, position
|
|
|
|
|
|
def search_title(query, expected):
|
|
launch(); key(22, 3); focused('Search'); key(23)
|
|
focused('Movies, shows, episodes, people')
|
|
adb('shell', 'input', 'text', query)
|
|
wait(lambda r: expected in labels(r), 'Search fixture '+expected)
|
|
key(66); focused(expected)
|
|
|
|
|
|
def search_check():
|
|
search_title('hazbin', 'Hazbin Hotel')
|
|
key(23); text('Seasons'); key(4); focused('Hazbin Hotel')
|
|
# Return to the field, then Right at the end reaches Clear.
|
|
key(19)
|
|
wait(lambda r: focus(r)=='hazbin', 'Search field above results')
|
|
key(4) # Close the Android TV keyboard before navigating app buttons.
|
|
key(22); focused('Clear'); screenshot('040-search-clear')
|
|
key(23)
|
|
root=wait(lambda r:'Movies, shows, episodes, people' in labels(r), 'Clear resets results')
|
|
assert 'Hazbin Hotel' not in labels(root)
|
|
assert 'Your collection' not in labels(root) and 'Find something worth watching.' not in labels(root)
|
|
assert all('Voice search' not in n.get('content-desc','') for n in root.iter('node'))
|
|
assert not any(n.get('text')=='Clear' for n in root.iter('node'))
|
|
adb('shell', 'input', 'text', 'silo'); text('TV shows'); key(66); focused('Silo')
|
|
screenshot('040-search-new-query')
|
|
passed('Clear removes query/results, restores typing, and microphone is absent')
|
|
|
|
|
|
def details_check():
|
|
search_title('hazbin', 'Hazbin Hotel'); key(23); text('Seasons')
|
|
screenshot('040-show-artwork')
|
|
# Initial show entry may have its first season focused already.
|
|
if 'Season 1' not in focus(snapshot()):key(20)
|
|
focused('Season 1'); key(23)
|
|
wait(lambda r:'Hazbin Hotel' in labels(r) and 'Season 1' in labels(r), 'Season details')
|
|
screenshot('040-season-artwork')
|
|
root=snapshot()
|
|
assert any(n.get('content-desc')=='Back' for n in root.iter('node'))
|
|
# Moving across episode cards retains the fixed header and useful focus.
|
|
if not any(x in focus(root) for x in ['Dad Beat Dad','Hello Rosie','Overture']):key(20)
|
|
before=focus(snapshot()); key(22); after=focus(snapshot())
|
|
assert before!=after and after, 'Episode selection must move'
|
|
screenshot('040-season-next-episode')
|
|
key(4); focused('Season 1')
|
|
passed('Hazbin show/season art captured; episode movement and Back focus preserved')
|
|
|
|
|
|
def categories_check():
|
|
for moves, name in [(1, 'Movies'), (2, 'TV Shows')]:
|
|
launch(); key(22, moves); focused(name); key(20); focused('Discover')
|
|
key(22, 2); focused('Categories'); key(23)
|
|
wait(lambda r:focus(r) not in ('','Categories'), 'Category entry')
|
|
root=snapshot()
|
|
assert not any(x in labels(root) for x in ['FILM','SERIES']), 'Categories must only label genres'
|
|
assert not any(x in labels(root) for x in ['The Batman','Hazbin Hotel']), 'Artwork titles must not appear on categories'
|
|
time.sleep(2); screenshot('040-'+name.lower().replace(' ','-')+'-categories')
|
|
first=focus(snapshot()); key(22); second=focus(snapshot())
|
|
assert first!=second
|
|
key(20); below=focus(snapshot()); assert below!=second
|
|
key(19); focused(second); key(21); focused(first)
|
|
key(23)
|
|
wait(lambda r:any('titles' in s for s in labels(r)), 'Scoped category results')
|
|
key(4); focused(first)
|
|
passed(name+' artwork cards: horizontal/vertical navigation, open and Back restoration')
|
|
|
|
|
|
@contextmanager
|
|
def preserve_movie_progress():
|
|
cfg=dict(l.split('=',1) for l in (ROOT/'.env').read_text().splitlines() if '=' in l and not l.startswith('#'))
|
|
server=cfg['PLEX_SERVER_URL'].strip('"\'').rstrip('/')
|
|
headers={'X-Plex-Token':cfg['PLEX_TOKEN'].strip('"\''),'Accept':'application/json'}
|
|
def request(path, params=None):
|
|
url=server+path+('?' + urllib.parse.urlencode(params) if params else '')
|
|
with urllib.request.urlopen(urllib.request.Request(url,headers=headers),timeout=30) as response:return response.read()
|
|
original=json.loads(request('/library/metadata/9776'))['MediaContainer']['Metadata'][0]
|
|
try:yield
|
|
finally:
|
|
adb('shell','am','force-stop','tv.kaleido.app');time.sleep(.4)
|
|
# testValidation suppresses Plex timeline/scrobble writes. Verify that contract.
|
|
restored=json.loads(request('/library/metadata/9776'))['MediaContainer']['Metadata'][0]
|
|
assert restored.get('viewOffset',0)==original.get('viewOffset',0), 'Preserve fixture progress'
|
|
assert restored.get('viewCount',0)==original.get('viewCount',0), 'Preserve watched state'
|
|
|
|
|
|
def skip_check():
|
|
with preserve_movie_progress():quick_skip_check()
|
|
|
|
|
|
def quick_skip_check():
|
|
adb('shell','am','force-stop','tv.kaleido.app'); adb('logcat','-c')
|
|
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','9776','--el','testOffset','90000','--ei','testMode','2','--ez','testValidation','true')
|
|
deadline=time.monotonic()+45
|
|
while 'READY item=9776' not in adb('logcat','-d','-s','KaleidoPlayback:I').decode(errors='replace'):
|
|
assert time.monotonic()<deadline, 'Playback ready'; time.sleep(.5)
|
|
key(127); focused('Play'); key(4); time.sleep(.4)
|
|
before=position()
|
|
adb('shell','input','keyevent','22'); time.sleep(.16); screenshot('040-skip-forward')
|
|
time.sleep(1.3); after=position()
|
|
assert 8500<=after-before<=11500, (before,after)
|
|
adb('shell','input','keyevent','21'); time.sleep(.16); screenshot('040-skip-back')
|
|
time.sleep(1.3); back=position(); assert abs(back-before)<1600, (before,back)
|
|
adb('shell','input','keyevent','22'); adb('shell','input','keyevent','22')
|
|
time.sleep(.12); screenshot('040-skip-repeated'); time.sleep(1.4)
|
|
assert 18500<=position()-back<=21500, 'Repeated taps must accumulate'
|
|
root=snapshot(); assert '2 Fast 2 Furious' not in labels(root), 'Cue must leave controls hidden'
|
|
key(23); focused('Play'); key(19); focused('Playback timeline')
|
|
key(22); key(20); focused('Play')
|
|
key(4); key(4)
|
|
passed('Actual +/-10s and repeated +20s seeks; cue screenshots; timeout and timeline coexist')
|
|
|
|
|
|
if __name__=='__main__':
|
|
parser=argparse.ArgumentParser();parser.add_argument('check',choices=['search','details','categories','skip'])
|
|
globals()[parser.parse_args().check+'_check']()
|