Remember external applications and add GUI smoke test
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
os.environ.setdefault("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-gpu --no-sandbox")
|
||||
os.environ.setdefault("QTWEBENGINE_DISABLE_SANDBOX", "1")
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
from PySide6.QtCore import QTimer
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from mdhelper.main_window import MainWindow, ReaderView
|
||||
|
||||
|
||||
def main() -> int:
|
||||
project_root = PROJECT_ROOT
|
||||
app = QApplication.instance() or QApplication([sys.argv[0]])
|
||||
window = MainWindow(project_root=project_root, initial_path=project_root / "sample.md")
|
||||
window.show()
|
||||
|
||||
checks: list[str] = []
|
||||
|
||||
def verify() -> None:
|
||||
if window.current_file != (project_root / "sample.md").resolve():
|
||||
checks.append("current_file")
|
||||
if window.tabs.count() < 1:
|
||||
checks.append("tabs")
|
||||
if not isinstance(window.tabs.currentWidget(), ReaderView):
|
||||
checks.append("reader_view")
|
||||
if not window.export_pdf_action.isEnabled():
|
||||
checks.append("export_pdf_action")
|
||||
if not window.export_html_action.isEnabled():
|
||||
checks.append("export_html_action")
|
||||
if window.search_index.search("斐波那契") == []:
|
||||
checks.append("search_index")
|
||||
window.close()
|
||||
app.quit()
|
||||
|
||||
QTimer.singleShot(1600, verify)
|
||||
app.exec()
|
||||
|
||||
if checks:
|
||||
print("GUI smoke failed:", ", ".join(checks))
|
||||
return 1
|
||||
|
||||
print("GUI smoke ok")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user