aboutsummaryrefslogtreecommitdiffstats
path: root/test_upscale_qt.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_upscale_qt.py')
-rw-r--r--test_upscale_qt.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test_upscale_qt.py b/test_upscale_qt.py
index 66423e8..7175e92 100644
--- a/test_upscale_qt.py
+++ b/test_upscale_qt.py
@@ -114,6 +114,25 @@ def test_main_window():
assert not w.a_clear.isEnabled() and not w.a_up.isEnabled()
+def test_quit_asks_when_unsaved():
+ from PyQt6.QtWidgets import QMessageBox
+ w = uq.Main()
+ assert w.a_quit.shortcut().toString() == 'Ctrl+Q'
+ path = os.path.join(TMP, 'q.png')
+ QImage(4, 4, QImage.Format.Format_RGB32).save(path)
+ w.load(path)
+ w.jobs[0].result = QImage(16, 16, QImage.Format.Format_RGB32)
+ answers = []
+ real = QMessageBox.question
+ try:
+ QMessageBox.question = lambda *a: answers.append(a) or QMessageBox.StandardButton.No
+ assert not w.close() and len(answers) == 1 # declined, stays open
+ w.jobs[0].saved = True
+ assert w.close() and len(answers) == 1 # saved, no question
+ finally:
+ QMessageBox.question = real
+
+
if __name__ == '__main__':
for name, fn in list(globals().items()):
if name.startswith('test_'):