Core regression / Python core, intervention UI and release configuration (push) Successful in 6m54s
Core regression / JavaScript syntax (push) Successful in 8s
Core regression / Python core, intervention UI and release configuration (pull_request) Successful in 5m22s
Core regression / JavaScript syntax (pull_request) Successful in 7s
97 lines
4.5 KiB
Python
97 lines
4.5 KiB
Python
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
from PySide6.QtCore import QRect, QByteArray
|
|
from PySide6.QtGui import QAccessible
|
|
from PySide6.QtWidgets import QApplication
|
|
|
|
from test_ui_remediation import window
|
|
|
|
|
|
@pytest.mark.parametrize('scale,saved,decorated', [(1.25, False, False), (1.5, False, False),
|
|
(1.5, True, False), (1.5, False, True), (3.0, False, True)])
|
|
def test_first_and_restored_windows_fit_scaled_workarea(window, qtbot, monkeypatch, scale, saved, decorated):
|
|
area = QRect(0, 0, int(1920 / scale), int(1032 / scale))
|
|
screen = SimpleNamespace(availableGeometry=lambda: area, logicalDotsPerInch=lambda: 96 * scale,
|
|
devicePixelRatio=lambda: scale, name=lambda: 'controlled-scaled-screen')
|
|
window._layout_settings.remove('main_window/geometry')
|
|
window.resize(1616, 1100)
|
|
if saved:
|
|
window._layout_settings.setValue('main_window/geometry', window.saveGeometry())
|
|
monkeypatch.setattr(QApplication, 'primaryScreen', lambda: screen)
|
|
monkeypatch.setattr(QApplication, 'screenAt', lambda _: screen)
|
|
if decorated:
|
|
def frame():
|
|
client = window.geometry()
|
|
return client.adjusted(-8, -31, 8, 8) if window.isVisible() else client
|
|
monkeypatch.setattr(window, 'frameGeometry', frame)
|
|
window._restore_window_geometry()
|
|
window.show()
|
|
QApplication.processEvents()
|
|
assert area.contains(window.frameGeometry()), (area, window.frameGeometry(), window.minimumSize())
|
|
for button in (window.plan_panel.save_button, window.run_panel.quick_run_button, window.task_list.new_button):
|
|
if scale == 3.0:
|
|
window.workspace_scroll.ensureWidgetVisible(button, 0, 0)
|
|
QApplication.processEvents()
|
|
point = button.mapTo(window.workspace_scroll.viewport(), button.rect().bottomRight())
|
|
assert window.workspace_scroll.viewport().rect().contains(point)
|
|
point = button.mapTo(window, button.rect().bottomRight())
|
|
assert window.rect().contains(point), (button.objectName(), point, window.size())
|
|
|
|
|
|
def test_both_table_headers_restore_width_order_and_sort(window, qtbot):
|
|
for table in (window.mapping_table, window.plan_panel.table):
|
|
header = table.horizontalHeader()
|
|
header.resizeSection(0, 173)
|
|
header.moveSection(0, 2)
|
|
header.setSortIndicator(1, header.sortIndicatorOrder())
|
|
expected = {name: bytes(widget.saveState()) for name, widget in window._layout_widgets().items()
|
|
if name in {'rules', 'targets'}}
|
|
window.close()
|
|
qtbot.waitUntil(lambda: window._closed)
|
|
reopened = type(window)(window.service)
|
|
qtbot.addWidget(reopened)
|
|
try:
|
|
reopened.show()
|
|
qtbot.waitUntil(lambda: not reopened._task_query.busy and not reopened._context_query.busy)
|
|
for name, data in expected.items():
|
|
assert bytes(reopened._layout_widgets()[name].saveState()) == data
|
|
reopened._layout_settings.setValue('single_project/rules', QByteArray(b'broken header'))
|
|
reopened._layout_settings.sync()
|
|
finally:
|
|
reopened.close()
|
|
|
|
|
|
def test_result_log_is_an_independent_reopenable_window(window, qtbot):
|
|
panel = window.run_panel
|
|
panel.toggle_log_button.click()
|
|
first = panel.log_dialog
|
|
assert first is not None and first.isWindow() and first.isVisible()
|
|
first.set_content('first evidence', ())
|
|
first.close()
|
|
assert panel.log_dialog is None and not panel.toggle_log_button.isChecked()
|
|
panel.toggle_log_button.click()
|
|
second = panel.log_dialog
|
|
assert second is not None and second is not first and second.isWindow()
|
|
second.set_content('new evidence', ())
|
|
assert second.log_text == 'new evidence'
|
|
second.tabs.setCurrentIndex(1)
|
|
interface = QAccessible.queryAccessibleInterface(second.log_view)
|
|
assert interface.text(QAccessible.Text.Name) == '任务日志'
|
|
second.close()
|
|
|
|
|
|
@pytest.mark.parametrize('corrupt', ['broken header', QByteArray(b'broken header')])
|
|
def test_invalid_saved_header_types_use_default_layout(window, qtbot, corrupt):
|
|
window._layout_settings.setValue('single_project/rules', corrupt)
|
|
window._layout_settings.setValue('single_project/targets', corrupt)
|
|
window._layout_settings.sync()
|
|
reopened = type(window)(window.service)
|
|
qtbot.addWidget(reopened)
|
|
try:
|
|
reopened.show()
|
|
assert reopened.mapping_table.horizontalHeader().sectionSize(0) == 220
|
|
assert reopened.plan_panel.table.horizontalHeader().sectionSize(0) == 55
|
|
finally:
|
|
reopened.close()
|