merge: preserve DSH lifecycle while syncing target branch

This commit is contained in:
阿白叔 committed 2026-10-31 14:48:59 +08:00
commit d3bdff81e5
70 files changed
+3030 -201

No files matched your search

+2 -1
View File
@@ -36,7 +36,8 @@ def ui(qtbot, tmp_path):
def settle():
qtbot.waitUntil(lambda:not window._workers and not window._task_query.busy
and not window._context_query.busy and not window._feedback_query.busy
and not window._log_presenter.query.busy and not window._dsh_operations.worker,timeout=5000)
and not window._log_presenter.query.busy and not window._resource_status.busy
and not window._dsh_operations.worker,timeout=5000)
def open_task(task):
window.open_task(task.task_id)
qtbot.waitUntil(lambda:not window._context_query.busy and not window._loading,timeout=5000)
+82
View File
@@ -93,6 +93,19 @@ def test_repeated_refresh_does_not_reconfigure_composition(qtbot):
assert len(backend.calls)==1
def test_deferred_material_refresh_never_uses_a_destroyed_window(qtbot,qapp):
from PySide6.QtCore import QCoreApplication,QEvent
window=QWidget() # This test owns destruction rather than pytest-qt teardown.
backend=Backend()
controller=AcrylicController(window,backend=backend)
controller.eventFilter(window,QEvent(QEvent.Type.WindowActivate))
window.deleteLater()
QCoreApplication.sendPostedEvents(None,QEvent.Type.DeferredDelete)
controller.refresh()
qapp.processEvents()
assert not backend.calls
def test_backend_exception_uses_solid_surface(qtbot):
window=QWidget();qtbot.addWidget(window)
class Broken(Backend):
@@ -158,3 +171,72 @@ def test_real_window_has_svg_controls_and_persistent_material_preference(ui):
image=window.plan_panel.table.viewport().grab().toImage()
color=image.pixelColor(image.width()-8,image.height()-8)
assert color.alpha()==255 and min(color.red(),color.green(),color.blue())>=245
@pytest.mark.parametrize('reduced',[False,True])
def test_high_contrast_fallback_uses_window_palette_and_tracks_policy_change(qtbot,qapp,request,reduced):
from PySide6.QtGui import QColor,QPalette
from PySide6.QtWidgets import QLabel,QLineEdit
from dx_productivity.trial_task_center.ui.material import MaterialMainWindow
from dx_productivity.trial_task_center.ui.styles import APP_STYLESHEET
original_palette=qapp.palette()
request.addfinalizer(lambda:qapp.setPalette(original_palette))
palette=QPalette(original_palette)
palette.setColor(QPalette.ColorRole.Window,QColor('#181818'))
palette.setColor(QPalette.ColorRole.WindowText,QColor('#fafafa'))
palette.setColor(QPalette.ColorRole.Base,QColor('#181818'))
palette.setColor(QPalette.ColorRole.Text,QColor('#fafafa'))
qapp.setPalette(palette)
window=MaterialMainWindow();qtbot.addWidget(window)
window.setStyleSheet(APP_STYLESHEET)
search=QLineEdit('Readable query',window,objectName='taskSearch')
search.setGeometry(30,30,180,30)
title=QLabel('Project name',window,objectName='projectTitle')
class ContrastBackend(Backend):
contrast=True
def high_contrast(self):return self.contrast
def available(self):return not self.contrast
backend=ContrastBackend()
controller=AcrylicController(window,backend=backend)
controller.set_reduced_transparency(reduced)
controller.refresh()
window.resize(240,160);window.show()
assert window.property('highContrastFallback')
assert not window.property('acrylicEnabled')
color=window.grab().toImage().pixelColor(10,10)
assert color==QColor('#181818')
search.setFocus()
assert search.palette().color(QPalette.ColorRole.Base)==QColor('#181818')
assert search.palette().color(QPalette.ColorRole.Text)==QColor('#fafafa')
assert title.palette().color(QPalette.ColorRole.WindowText)==QColor('#fafafa')
backend.contrast=False
controller.refresh()
assert not window.property('highContrastFallback')
assert window.property('acrylicEnabled') is not reduced
assert window.styleSheet()==APP_STYLESHEET
@pytest.mark.parametrize('selected',[False,True])
def test_high_contrast_task_titles_render_with_system_text_colors(qtbot,selected):
from PySide6.QtCore import QRect,Qt
from PySide6.QtGui import QColor,QImage,QPainter,QPalette,QStandardItem,QStandardItemModel
from PySide6.QtWidgets import QListWidget,QStyle,QStyleOptionViewItem
from dx_productivity.trial_task_center.ui.task_list import TaskItemDelegate
window=QWidget();qtbot.addWidget(window)
window.setProperty('highContrastFallback',True)
listing=QListWidget(window)
model=QStandardItemModel();model.appendRow(QStandardItem('01. Board Name\nReady'))
option=QStyleOptionViewItem();option.widget=listing
option.rect=QRect(0,0,220,76);option.font=listing.font()
option.state=QStyle.StateFlag.State_Enabled
palette=QPalette(listing.palette())
palette.setColor(QPalette.ColorRole.Text,QColor('#ffff00'))
palette.setColor(QPalette.ColorRole.HighlightedText,QColor('#00ff00'))
option.palette=palette
if selected:option.state|=QStyle.StateFlag.State_Selected
picture=QImage(220,76,QImage.Format.Format_ARGB32);picture.fill(QColor('#000000'))
painter=QPainter(picture)
TaskItemDelegate(listing).paint(painter,option,model.index(0,0));painter.end()
expected=QColor('#00ff00'if selected else'#ffff00')
# Check actual painted title glyphs, not only the widget's palette property.
assert sum(picture.pixelColor(x,y)==expected for x in range(43,190)for y in range(11,34))>5
@@ -41,6 +41,20 @@ def test_current_task_executes_only_after_confirmation_and_no_match_is_completed
assert len(rows)==1 and rows[0]['result']['tasks'][0]['no_match_items']==1
def test_batch_execute_button_tracks_remaining_tasks(ui):
w = ui.window
w._quick_run_confirmer = lambda *_args: True
w._prepare_quick_run()
ui.settle()
# A completed selection must still allow execution of its pending sibling.
assert w.task_list.queue_button.isEnabled()
w.task_list.queue_button.click()
ui.settle()
assert len(ui.calls) == 2
assert not w.task_list.queue_button.isEnabled(), 'a completed batch must not offer a no-op execution button'
assert w.run_panel.new_round_button.isEnabled()
@pytest.mark.parametrize('value',[False,True])
def test_changed_value_policy_stops_stale_confirmation_before_worker(ui,value):
w=ui.window;task=ui.tasks[0]
@@ -90,6 +104,17 @@ def test_regular_mutation_locks_navigation_until_completion(ui,qtbot):
ui.open(ui.tasks[1])
def test_execution_callback_failure_releases_run_controls(ui,qtbot):
w=ui.window
w._begin_run(ui.tasks[0].task_id)
w._run_async(lambda: 'result', lambda _result: (_ for _ in ()).throw(RuntimeError('render failed')),
expected_task_id=ui.tasks[0].task_id)
ui.settle()
assert w._batch_stop is None
assert not w.run_panel.busy_indicator.isVisible()
assert not w.run_panel.force_stop_button.isVisible()
def test_close_during_execution_requests_boundary_pause_and_waits(ui,qtbot):
w=ui.window;started,release=Event(),Event()
def work():
@@ -1,5 +1,6 @@
"""Readable logs and execution feedback on the current project-task interface."""
"""UI log and feedback coverage, collectable alongside the service feedback tests."""
import json
import pytest
from dx_productivity.trial_task_center.errors import TaskCenterError
from dx_productivity.trial_task_center.ui.messages import (
_aligned_log_line, _format_task_log_lines, _nc_sync_log_lines,
@@ -54,6 +55,24 @@ def test_preflight_error_keeps_reason_and_stable_id_in_operator_feedback(ui):
assert error.error_id in ui.window._log_presenter.log_text
@pytest.mark.parametrize('kind', ['missing', 'invalid', 'forced', 'resources'])
def test_supervisor_failure_feedback_keeps_support_id_and_recovery_instruction(ui, kind):
from dx_productivity.trial_task_center.supervisor_evidence import MissingSupervisorResult, InvalidSupervisorResult
from dx_productivity.trial_task_center.batch_resources import BatchResourceCleanupError
errors = {
'missing': MissingSupervisorResult(exit_code=79, stderr_tail='worker failed'),
'invalid': InvalidSupervisorResult(exit_code=0),
'forced': TaskCenterError('user_forced_stop', '已强制结束,请先核验恢复。'),
'resources': BatchResourceCleanupError('资源确认失败,请重新清理资源。'),
}
error = errors[kind]
ui.window._show_error(error)
text = ui.window.run_panel.operator_band.text()
assert error.error_id in text
assert error.message in text
assert error.error_id in ui.window._log_presenter.log_text
def test_running_feedback_names_owner_and_keeps_navigation_available(ui,qtbot):
from threading import Event
release,started=Event(),Event()
+38
View File
@@ -59,3 +59,41 @@ def test_redesign_small_window_keeps_save_and_execute_visible(ui,qtbot):
for button in [window.plan_panel.save_button,window.run_panel.quick_run_button,window.task_list.new_button]:
rect=button.rect();point=button.mapTo(window,rect.bottomRight())
assert point.x()<window.width()and point.y()<window.height()
def test_menu_keeps_command_hidden_before_registration(qtbot):
from dx_productivity.trial_task_center.ui.command_menu import CommandMenu
owner=QWidget();qtbot.addWidget(owner)
button=QPushButton('Hidden command',owner)
button.hide()
called=[];button.clicked.connect(lambda:called.append(True))
menu=CommandMenu(owner)
action=menu.add_button(button)
assert button.isHidden()
assert not action.isVisible()
menu.sync();action.trigger()
assert not called
button.show();menu.sync();action.trigger()
assert action.isVisible() and called==[True]
def test_force_stop_is_directly_visible_during_execution_at_minimum_size(ui,qtbot):
window=ui.window
window._begin_run(ui.tasks[0].task_id)
window._update_gates()
try:
window.resize(980,700);qtbot.wait(30)
run=window.run_panel
assert run.force_stop_button.parent() is run
assert run.force_stop_button.isVisible()
assert run.force_stop_button.isEnabled()
assert run.stop_queue_button.isVisible()
for button in (run.force_stop_button,run.stop_queue_button):
point=button.mapTo(window,button.rect().bottomRight())
assert 0<=point.x()<window.width() and 0<=point.y()<window.height()
window._pause_queue()
assert run.force_stop_button.isVisible() and run.force_stop_button.isEnabled()
finally:
window._finish_run()
window._update_gates()
assert not window.run_panel.force_stop_button.isVisible()