fix: align contextual CSS rendering and Word styles

This commit is contained in:
2026-10-30 13:12:05 +08:00
parent cc4f91899e
commit f9bf62b71c
17 changed files with 313 additions and 53 deletions
+10 -22
View File
@@ -92,12 +92,11 @@ def main() -> int:
(switch_root / "first.md").write_text("# First\n", encoding="utf-8")
(nested_root / "inside.md").write_text("# Inside\n", encoding="utf-8")
first_reader = empty_window._reader_from_tab(fixed_reader_host)
first_load_loop = QEventLoop()
if first_reader is not None:
first_reader.loadFinished.connect(first_load_loop.quit)
empty_window.open_document(project_root / "sample.md", add_history=False)
QTimer.singleShot(5000, first_load_loop.quit)
first_load_loop.exec()
wait_until(
lambda: first_reader is not None and fixed_reader_host.stack.currentWidget() is first_reader,
timeout_ms=30000,
)
if empty_window.tabs.currentWidget() is not fixed_reader_host:
checks.append("first_open_fixed_tab_host")
if first_reader is None or fixed_reader_host.stack.currentWidget() is not first_reader:
@@ -682,9 +681,7 @@ def main() -> int:
window.set_theme_background_from_action(peony_action)
if window.theme_background != "peony":
checks.append("background_enabled_for_colorful")
toc_refresh_loop = QEventLoop()
QTimer.singleShot(700, toc_refresh_loop.quit)
toc_refresh_loop.exec()
wait_until(lambda: not window.web_view.page().isLoading(), timeout_ms=30000)
if not hasattr(window, "manage_external_apps_action"):
checks.append("manage_external_apps_action")
close_window = MainWindow(project_root=project_root)
@@ -724,11 +721,9 @@ def main() -> int:
result["scroll_y"] = float(value or 0)
except (TypeError, ValueError):
result["scroll_y"] = -1
toc_loop.quit()
window.web_view.page().runJavaScript("Math.max(0, window.scrollY || document.documentElement.scrollTop || 0)", store_scroll)
QTimer.singleShot(1000, toc_loop.quit)
toc_loop.exec()
wait_until(lambda: "scroll_y" in result, timeout_ms=30000)
if result.get("scroll_y", -1) < 0:
checks.append("toc_second_click_scroll")
if window.search_index.search("斐波那契") == []:
@@ -820,18 +815,11 @@ def main() -> int:
pass
pdf_test_path = project_root / "__gui_smoke_export.pdf"
try:
pdf_loop = QEventLoop()
window.export_pdf_to_path(pdf_test_path)
def poll_pdf_export() -> None:
if pdf_test_path.exists() or getattr(window, "_pdf_export_page", None) is None:
pdf_loop.quit()
return
QTimer.singleShot(100, poll_pdf_export)
QTimer.singleShot(100, poll_pdf_export)
QTimer.singleShot(15000, pdf_loop.quit)
pdf_loop.exec()
wait_until(
lambda: pdf_test_path.exists() or getattr(window, "_pdf_export_page", None) is None,
timeout_ms=60000,
)
if not pdf_test_path.exists() or pdf_test_path.stat().st_size <= 0:
checks.append("export_pdf_write")
finally: