收起复用与完成态分析横幅。
来源栏已显示结果状态,横幅约 1.5 秒后只隐藏控件并保留 state()。已用 apps/studio/tests/test_analysis_progress.py 验证。
This commit is contained in:
@@ -3,8 +3,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from orisys_app_shared.i18n import set_locale, t
|
||||
from PySide6.QtCore import QTimer
|
||||
|
||||
from orisys_studio.ui.analysis_progress import AnalysisProgress
|
||||
from orisys_studio.ui.analysis_progress import (
|
||||
COMPLETE,
|
||||
REUSED,
|
||||
AnalysisProgress,
|
||||
_COLLAPSE_MS,
|
||||
)
|
||||
|
||||
|
||||
def test_analysis_progress_titles_name_the_outcome(qt_app) -> None:
|
||||
@@ -19,12 +25,57 @@ def test_analysis_progress_titles_name_the_outcome(qt_app) -> None:
|
||||
assert banner.title_label.text() == t("analysis.title_reused")
|
||||
assert not banner.progress_bar.isVisible()
|
||||
assert not banner.cancel_button.isVisible()
|
||||
assert banner.isVisible()
|
||||
assert banner.state() == REUSED
|
||||
|
||||
banner.complete(frames=12, elapsed_s=1.5)
|
||||
assert banner.title_label.text() == t("analysis.title_complete")
|
||||
assert banner.isVisible()
|
||||
assert banner.state() == COMPLETE
|
||||
|
||||
banner.cancelled(frames=3)
|
||||
assert banner.title_label.text() == t("analysis.title_cancelled")
|
||||
assert banner.isVisible()
|
||||
|
||||
banner.failed(reason="boom", frames=1)
|
||||
assert banner.title_label.text() == t("analysis.title_failed")
|
||||
assert banner.isVisible()
|
||||
|
||||
|
||||
def test_reused_and_complete_banners_collapse_without_clearing_state(qt_app) -> None:
|
||||
"""Success notices leave the rail's state intact after they stop taking height."""
|
||||
set_locale("en_US")
|
||||
banner = AnalysisProgress(theme="dark")
|
||||
|
||||
banner.reused(frames=12)
|
||||
assert banner.isVisible()
|
||||
QTimer.singleShot(0, lambda: None)
|
||||
qt_app.processEvents()
|
||||
# Advance past the collapse delay without waiting on the wall clock.
|
||||
banner._collapse_timer.setInterval(0)
|
||||
banner._collapse_timer.start()
|
||||
qt_app.processEvents()
|
||||
assert not banner.isVisible()
|
||||
assert banner.state() == REUSED
|
||||
|
||||
banner.complete(frames=8, elapsed_s=0.5)
|
||||
assert banner.isVisible()
|
||||
banner._collapse_timer.setInterval(0)
|
||||
banner._collapse_timer.start()
|
||||
qt_app.processEvents()
|
||||
assert not banner.isVisible()
|
||||
assert banner.state() == COMPLETE
|
||||
|
||||
banner.cancelled(frames=1)
|
||||
assert banner.isVisible()
|
||||
assert banner.state() == "cancelled"
|
||||
|
||||
banner.failed(reason="disk", frames=0)
|
||||
assert banner.isVisible()
|
||||
assert banner.state() == "failed"
|
||||
|
||||
banner.start()
|
||||
assert banner.isVisible()
|
||||
assert banner.state() == "running"
|
||||
assert not banner._collapse_timer.isActive()
|
||||
assert _COLLAPSE_MS == 1500
|
||||
|
||||
Reference in New Issue
Block a user