#!/usr/bin/env python3 """Run: dbus-run-session -- python3 tests/tray_runtime.py (real Hyprland required).""" import json import os from pathlib import Path import subprocess import tempfile import time import dbus ROOT = Path(__file__).resolve().parents[1] BASE = ['quickshell', 'ipc', '--path', str(ROOT / 'quickshell'), 'call'] def ipc(target, method, *args): p = subprocess.run(BASE + [target, method, *map(str,args)], text=True, capture_output=True) try: return json.loads(p.stdout) if p.returncode == 0 and p.stdout.strip() else None except ValueError: raise AssertionError(f'IPC failed: {p.stdout} {p.stderr}') def eventually(check, timeout=8): end = time.monotonic()+timeout while time.monotonic() 100, popout() assert ipc('trayTest','popoutScreenshot','/tmp/glassmxrph-popout-preview.png') layers = json.loads(subprocess.check_output(['hyprctl','-j','layers'])) assert any(item['namespace'] == 'glassMxrph-popout' for output in layers.values() for level in output['levels'].values() for item in level) assert ipc('trayTest','leaveBar') eventually(lambda: not popout()['open'] and not popout()['visible']) assert ipc('trayTest','hoverModule','windowItem-0') time.sleep(.4); assert not popout()['open'], 'Cold hover ignored the hover delay' eventually(lambda: popout()['open'], timeout=4) assert ipc('trayTest','leaveBar') eventually(lambda: not popout()['open']) else: print('SKIP: no programs on the focused workspace for window previews') # Click-opened menus are sticky and take keyboard focus. assert ipc('trayTest','click',ident,2) eventually(lambda: state()['opened'] and state()['grabbing'] and not popout()['open']) ipc('tray','close'); eventually(lambda: not state()['opened']) fixture.terminate(); fixture.wait(timeout=5) eventually(lambda: len(state()['items']) == 0 and not state()['opened']) finally: if fixture and fixture.poll() is None: fixture.terminate(); fixture.wait(timeout=5) shell.terminate(); shell.wait(timeout=5) output.flush() Path("/tmp/glassmxrph-tray-runtime.log").write_text(logs.read_text()) text=logs.read_text() Path('/tmp/glassmxrph-tray-runtime.log').write_text(text) assert 'WARN' not in text and 'ERROR' not in text, text print('PASS: SNI discovery/removal, hover delay/cancellation, pointer handover, menu states/icons, nested menus, DBus actions, disabled entries, live check updates, activation, no-menu tooltips, instant hover handover, active-window preview, hover menus without focus grabs, per-monitor anchoring, clean logs.')