proper tests
This commit is contained in:
21
cht/app.py
21
cht/app.py
@@ -1,3 +1,4 @@
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
@@ -55,6 +56,11 @@ class ChtApp(Adw.Application):
|
||||
win = ChtWindow(application=self)
|
||||
win.present()
|
||||
|
||||
# Auto-connect for E2E testing: --auto-connect
|
||||
# Delay gives the GUI time to fully render before starting the stream.
|
||||
if os.environ.get("_CHT_AUTO_CONNECT") == "1" and not win._lifecycle.is_streaming:
|
||||
GLib.timeout_add(2000, lambda: win._on_connect_clicked(None) or False)
|
||||
|
||||
|
||||
_STDERR_SKIP = [b"eglExportDMABUFImage"]
|
||||
|
||||
@@ -89,6 +95,16 @@ def _filter_stderr():
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="CHT — Stream Viewer + Agent")
|
||||
parser.add_argument("--auto-connect", action="store_true", help="Connect on startup")
|
||||
parser.add_argument("--python", action="store_true", help="Use Python transport (default)")
|
||||
parser.add_argument("--rust", action="store_true", help="Use Rust transport")
|
||||
args, gtk_args = parser.parse_known_args()
|
||||
|
||||
# Store parsed options so do_activate can read them
|
||||
os.environ["_CHT_AUTO_CONNECT"] = "1" if args.auto_connect else "0"
|
||||
os.environ["_CHT_RUST_TRANSPORT"] = "1" if args.rust else "0"
|
||||
|
||||
_filter_stderr()
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
@@ -96,9 +112,10 @@ def main():
|
||||
datefmt="%H:%M:%S",
|
||||
)
|
||||
log = logging.getLogger("cht")
|
||||
log.info("CHT starting")
|
||||
log.info("CHT starting (transport=%s, auto_connect=%s)",
|
||||
"rust" if args.rust else "python", args.auto_connect)
|
||||
app = ChtApp()
|
||||
return app.run(sys.argv)
|
||||
return app.run([sys.argv[0]] + gtk_args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user