feat: 内置并统一使用项目 ADB (#149)
This commit is contained in:
@@ -14,6 +14,7 @@ from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from qfluentwidgets import InfoBarPosition
|
||||
|
||||
from src.adb_runtime import BundledAdbError
|
||||
from src.android_device_service import AndroidDeviceSearchError
|
||||
from src.db import open_database
|
||||
from src.pdd_ui import PDDTaskPage
|
||||
@@ -1174,6 +1175,40 @@ class PDDTaskPageEventTest(unittest.TestCase):
|
||||
self.assertEqual(result, 0)
|
||||
self.assertTrue(window.maximized)
|
||||
|
||||
def test_application_startup_shows_dialog_when_bundled_adb_is_missing(self):
|
||||
class FakeApplication:
|
||||
@staticmethod
|
||||
def setAttribute(*_args):
|
||||
pass
|
||||
|
||||
def __init__(self, _args):
|
||||
pass
|
||||
|
||||
def exec_(self):
|
||||
return 0
|
||||
|
||||
class FakeWindow:
|
||||
def showMaximized(self):
|
||||
pass
|
||||
|
||||
window = FakeWindow()
|
||||
message = "内置 ADB 文件缺失:adb.exe。请重新安装完整的软件包。"
|
||||
with patch("src.ui_main.QApplication", FakeApplication), patch(
|
||||
"src.ui_main.MainWindow", return_value=window
|
||||
), patch("src.ui_main.setTheme"), patch(
|
||||
"src.ui_main.mark_current_version_healthy"
|
||||
), patch(
|
||||
"src.ui_main.configure_bundled_adb_environment",
|
||||
side_effect=BundledAdbError(message),
|
||||
), patch(
|
||||
"src.ui_main.QTimer.singleShot",
|
||||
side_effect=lambda _delay, callback: callback(),
|
||||
), patch("src.ui_main._show_adb_missing_dialog") as show_dialog:
|
||||
result = ui_main()
|
||||
|
||||
self.assertEqual(result, 0)
|
||||
show_dialog.assert_called_once_with(window, message)
|
||||
|
||||
def test_main_window_marks_and_clears_update_navigation(self):
|
||||
window = MainWindow(
|
||||
task_repository=self.repository,
|
||||
|
||||
Reference in New Issue
Block a user