Addon Manager: Fix macro installer bug

Also some minor tweaks to the GUI unit testing.
This commit is contained in:
Chris Hennes
2023-01-03 20:19:30 -06:00
parent 0e402ae075
commit 2575629e92
4 changed files with 22 additions and 1 deletions

View File

@@ -62,6 +62,21 @@ class DialogWatcher(QtCore.QObject):
self.click_button(widget)
self.dialog_found = True
self.timer.stop()
if not self.dialog_found:
# OK, it wasn't the active modal widget... was it some other window, and never became
# active? That's an error, but we should get it closed anyway.
windows = QtWidgets.QApplication.topLevelWidgets()
for widget in windows:
if (
hasattr(widget, "windowTitle")
and callable(widget.windowTitle)
and widget.windowTitle() == self.dialog_to_watch_for
):
self.click_button(widget)
self.timer.stop()
print("Found a window with the expected title, but it was not the active modal dialog.")
self.has_run = True
self.execution_counter += 1
if self.execution_counter > 100:

View File

@@ -434,6 +434,10 @@ class TestMacroInstallerGui(unittest.TestCase):
def tearDown(self):
pass
def test_class_is_initialized(self):
"""Connecting to a signal does not throw"""
self.installer.finished.connect(lambda: None)
def test_ask_for_toolbar_no_dialog_default_exists(self):
self.installer.addon_params.set("alwaysAskForToolbar", False)
self.installer.addon_params.set("CustomToolbarName", "UnitTestCustomToolbar")

View File

@@ -107,7 +107,7 @@ class TestUninstallerGUI(unittest.TestCase):
translate("AddonsInstaller", "Removing Addon"),
QtWidgets.QDialogButtonBox.Cancel,
)
QtCore.QTimer.singleShot(20, worker.stop)
QtCore.QTimer.singleShot(1000, worker.stop) # If the test fails, this kills the "worker"
self.uninstaller_gui._confirm_uninstallation = lambda: True
self.uninstaller_gui._run_uninstaller = worker.work
self.uninstaller_gui._finalize = lambda: None
@@ -121,6 +121,7 @@ class TestUninstallerGUI(unittest.TestCase):
self.assertTrue(
dialog_watcher.button_found, "Failed to find the expected button"
)
worker.stop()
def test_success_dialog(self):
dialog_watcher = DialogWatcher(