feat: 完成PySide6主窗口骨架
- 实现 MainWindow + 固定顺序五 Tab QTabWidget + 状态栏 - 新增 offscreen GUI 单元测试覆盖 Tab 顺序和状态栏切换 - 缺 PySide6 时提供明确启动错误,避免无声失败 - 更新任务看板、API 合约、当前状态和进度记录
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
from app import gui
|
||||
|
||||
if gui.QT_IMPORT_ERROR is not None:
|
||||
raise unittest.SkipTest("PySide6 未安装")
|
||||
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from app.gui import MainWindow, TAB_TITLES
|
||||
|
||||
|
||||
class GuiTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.app = QApplication.instance() or QApplication([])
|
||||
|
||||
def test_main_window_has_five_tabs_in_workflow_order(self):
|
||||
window = MainWindow()
|
||||
self.addCleanup(window.close)
|
||||
|
||||
self.assertEqual(5, window.tabs.count())
|
||||
self.assertEqual(
|
||||
TAB_TITLES,
|
||||
[window.tabs.tabText(index) for index in range(window.tabs.count())],
|
||||
)
|
||||
self.assertEqual("就绪", window.statusBar().currentMessage())
|
||||
|
||||
def test_tab_switch_updates_status_bar(self):
|
||||
window = MainWindow()
|
||||
self.addCleanup(window.close)
|
||||
|
||||
window.tabs.setCurrentIndex(2)
|
||||
|
||||
self.assertEqual("③ 更新shopee", window.tabs.tabText(window.tabs.currentIndex()))
|
||||
self.assertEqual("当前:③ 更新shopee", window.statusBar().currentMessage())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user