fix: preserve live selection validity and preferred panel geometry
This commit is contained in:
1 parent
9caf33df38
commit
d6df3f99fb
8 files changed
+268
-15
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
from dx_productivity.ui.app import create_main_window
|
||||
@@ -140,3 +141,32 @@ def test_repeated_panel_toggle_keeps_single_watcher_and_page_instances(qtbot, fi
|
||||
assert tuple(window.selection_watcher.findChildren(QTimer)) == timers
|
||||
assert len(window.findChildren(SelectionWatcher)) == 1
|
||||
assert window.property_change_controller.page.model.item(0, 0).text() == 'C1'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('content', [None, '{malformed', '[]', '{"state":"ready"}'])
|
||||
def test_initial_unavailable_selection_waits_then_pauses_and_recovers(qtbot, fixture_path, tmp_path, monkeypatch, content):
|
||||
from dx_productivity.ui import selection_watcher as watcher_module
|
||||
now = [100.0]
|
||||
monkeypatch.setattr(watcher_module.time, 'monotonic', lambda: now[0])
|
||||
if content is not None:
|
||||
(tmp_path / 'selection.json').write_text(content, encoding='utf-8')
|
||||
window, data = setup_window(qtbot, fixture_path, tmp_path, monkeypatch)
|
||||
window.show_toolbar()
|
||||
original = window.refdes_controller.snapshot
|
||||
assert '等待' in window.selection_status.text()
|
||||
assert window.bridge_status.text() != '桥接已连接'
|
||||
assert '已选' not in window.toolbar.status_label.text()
|
||||
now[0] += 10
|
||||
window.selection_watcher._check()
|
||||
assert '暂停' in window.selection_status.text()
|
||||
assert window.refdes_controller.snapshot is original
|
||||
publish(tmp_path, data, ['uid:uid-c-a'])
|
||||
window.selection_watcher._check()
|
||||
assert window.bridge_status.text() == '桥接已连接'
|
||||
assert 'C1' in window.toolbar.status_label.text()
|
||||
payload = json.loads((tmp_path / 'selection.json').read_text(encoding='utf-8'))
|
||||
payload['selected_keys'] = 12
|
||||
(tmp_path / 'selection.json').write_text(json.dumps(payload), encoding='utf-8')
|
||||
window.selection_watcher._check()
|
||||
assert '暂停' in window.selection_status.text()
|
||||
assert 'C1' not in window.toolbar.status_label.text()
|
||||
Reference in new issue
Block a user