diff --git a/src/testium/interpreter/test_items/dialog_choices_files/choices_dialog.py b/src/testium/interpreter/test_items/dialog_choices_files/choices_dialog.py index 2b1e676..c37be62 100644 --- a/src/testium/interpreter/test_items/dialog_choices_files/choices_dialog.py +++ b/src/testium/interpreter/test_items/dialog_choices_files/choices_dialog.py @@ -5,7 +5,7 @@ from itertools import chain from PySide6.QtGui import QIcon, QPixmap from PySide6.QtWidgets import QApplication, QDialog, QDialogButtonBox -from PySide6.QtCore import Qt, QSettings, QSize +from PySide6.QtCore import Qt, QSettings, QTimer, QSize from PySide6.QtGui import QFont, QFontInfo from PySide6.QtWidgets import QTreeWidgetItem @@ -207,6 +207,9 @@ def main(args, conn=None): d.connect_checked() d.choicesView.setFocus() + auto_result = args[4] if len(args) > 4 else None + if auto_result is not None: + QTimer.singleShot(2000, lambda: d.accept() if auto_result.lower() == 'ok' else d.reject()) dres = d.exec() if dres == QDialog.Rejected: diff --git a/src/testium/interpreter/test_items/dialog_image_files/dialog_image.py b/src/testium/interpreter/test_items/dialog_image_files/dialog_image.py index 2b928d5..98cc99f 100644 --- a/src/testium/interpreter/test_items/dialog_image_files/dialog_image.py +++ b/src/testium/interpreter/test_items/dialog_image_files/dialog_image.py @@ -1,6 +1,6 @@ import sys -from PySide6.QtCore import (Qt) +from PySide6.QtCore import Qt, QTimer from PySide6.QtWidgets import (QApplication, QDialog) from PySide6 import (QtGui) @@ -38,6 +38,10 @@ def main(args, conn): d.labelImage.setPixmap(QtGui.QPixmap.fromImage(image2)) + auto_result = args[3] if len(args) > 3 else None + if auto_result is not None: + QTimer.singleShot(2000, lambda: d.accept() if auto_result.lower() == 'ok' else d.reject()) + dres = d.exec() if dres == QDialog.Rejected: diff --git a/src/testium/interpreter/test_items/dialog_msg_files/msg_dialog.py b/src/testium/interpreter/test_items/dialog_msg_files/msg_dialog.py index 7f0176d..1300968 100644 --- a/src/testium/interpreter/test_items/dialog_msg_files/msg_dialog.py +++ b/src/testium/interpreter/test_items/dialog_msg_files/msg_dialog.py @@ -2,7 +2,7 @@ import sys from multiprocessing import freeze_support from PySide6.QtWidgets import (QApplication, QMessageBox) -from PySide6.QtCore import Qt +from PySide6.QtCore import Qt, QTimer def main(args): @@ -15,6 +15,8 @@ def main(args): msg.setText(args[1]) msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) + if len(args) > 2: + QTimer.singleShot(2000, lambda: msg.button(QMessageBox.Ok).click()) msg.exec() if hasattr(sys, "frozen"): diff --git a/src/testium/interpreter/test_items/dialog_note_files/test_dialog.py b/src/testium/interpreter/test_items/dialog_note_files/test_dialog.py index 881c98f..5fde02a 100644 --- a/src/testium/interpreter/test_items/dialog_note_files/test_dialog.py +++ b/src/testium/interpreter/test_items/dialog_note_files/test_dialog.py @@ -2,7 +2,7 @@ import sys import os from PySide6.QtWidgets import (QApplication, QDialog) -from PySide6.QtCore import (Qt) +from PySide6.QtCore import Qt, QTimer from interpreter.test_items.dialog_note_files import dialog_note_win from multiprocessing import freeze_support @@ -23,6 +23,14 @@ def main(args, conn=None): d.setWindowTitle(args[0]) d.labelDialog.setText(args[1]) d.textEdit.setFocus() + auto_result = args[2] if len(args) > 2 else None + if auto_result is not None: + auto_value = args[3] if len(args) > 3 else None + def _auto_close(): + if auto_value is not None: + d.textEdit.setPlainText(auto_value) + d.accept() if auto_result.lower() == 'ok' else d.reject() + QTimer.singleShot(2000, _auto_close) dres = d.exec() if dres == QDialog.Rejected: diff --git a/src/testium/interpreter/test_items/dialog_question_files/question_dialog.py b/src/testium/interpreter/test_items/dialog_question_files/question_dialog.py index 824354e..7a12ccf 100644 --- a/src/testium/interpreter/test_items/dialog_question_files/question_dialog.py +++ b/src/testium/interpreter/test_items/dialog_question_files/question_dialog.py @@ -2,7 +2,7 @@ import sys from multiprocessing import freeze_support from PySide6.QtWidgets import (QApplication, QMessageBox) -from PySide6.QtCore import Qt +from PySide6.QtCore import Qt, QTimer def main(args, conn): @@ -16,6 +16,10 @@ def main(args, conn): msg.setText(args[1]) msg.setIcon(QMessageBox.Question) msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + auto_result = args[2] if len(args) > 2 else None + if auto_result is not None: + btn = QMessageBox.Yes if auto_result.lower() == 'yes' else QMessageBox.No + QTimer.singleShot(2000, lambda: msg.button(btn).click()) reply = msg.exec() conn.send(reply) except Exception as e: diff --git a/src/testium/interpreter/test_items/dialog_value_files/test_dialog.py b/src/testium/interpreter/test_items/dialog_value_files/test_dialog.py index f8fcdf7..caa9647 100644 --- a/src/testium/interpreter/test_items/dialog_value_files/test_dialog.py +++ b/src/testium/interpreter/test_items/dialog_value_files/test_dialog.py @@ -2,7 +2,7 @@ import sys import os from PySide6.QtWidgets import (QApplication, QDialog) -from PySide6.QtCore import (Qt) +from PySide6.QtCore import Qt, QTimer from interpreter.test_items.dialog_value_files import dialog_value_win from multiprocessing import freeze_support @@ -25,6 +25,14 @@ def main(args, conn=None): d.labelDialog.setText(args[1]) d.lineEdit.setText(args[2]) d.lineEdit.setFocus() + auto_result = args[3] if len(args) > 3 else None + if auto_result is not None: + auto_value = args[4] if len(args) > 4 else None + def _auto_close(): + if auto_value is not None: + d.lineEdit.setText(auto_value) + d.accept() if auto_result.lower() == 'ok' else d.reject() + QTimer.singleShot(2000, _auto_close) dres = d.exec() if dres == QDialog.Rejected: diff --git a/src/testium/interpreter/test_items/test_item_choices_dialog.py b/src/testium/interpreter/test_items/test_item_choices_dialog.py index 30d208c..e8a4f50 100644 --- a/src/testium/interpreter/test_items/test_item_choices_dialog.py +++ b/src/testium/interpreter/test_items/test_item_choices_dialog.py @@ -17,13 +17,16 @@ class TestItemChoicesDialog(TestItemDialogBase): self._question = self._prms.getParam("question", required=True) self._choices = self._prms.getParam("choices", required=True) self._default_icon = self._prms.getParam("icon", required=False, default=None) + self._auto_result = self._prms.getParam("auto_result", required=False, default=None) @test_run def execute(self): q = self._prms.expanse(self._question) choices = self._prms.expanse(self._choices) icon = self._prms.expanse(self._default_icon) - result = self._run_dialog_with_result(choices_dialog.main, [self.name(), q, choices, icon]) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + args = [self.name(), q, choices, icon] + ([ar] if ar is not None else []) + result = self._run_dialog_with_result(choices_dialog.main, args) if result is None: self.result.set(TestValue.FAILURE, "Dialog subprocess exited without returning a result") return diff --git a/src/testium/interpreter/test_items/test_item_image_dialog.py b/src/testium/interpreter/test_items/test_item_image_dialog.py index f244687..8b34c73 100644 --- a/src/testium/interpreter/test_items/test_item_image_dialog.py +++ b/src/testium/interpreter/test_items/test_item_image_dialog.py @@ -21,6 +21,7 @@ class TestItemImageDialog(TestItemDialogBase): with item_load_context(self.cmd(), self.name(), self.seqFilename()): self._question = self._prms.getParam("question", required=True) self._filename = self._prms.getParam("filename", required=True) + self._auto_result = self._prms.getParam("auto_result", required=False, default=None) @test_run def execute(self): @@ -31,7 +32,9 @@ class TestItemImageDialog(TestItemDialogBase): image_path = os.path.normpath( os.path.join(tm.gd("test_directory"), image_path) ) - succ = self._run_dialog_with_result(dialog_image.main, [self.name(), q, image_path]) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + args = [self.name(), q, image_path] + ([ar] if ar is not None else []) + succ = self._run_dialog_with_result(dialog_image.main, args) if succ is None: self.result.set(TestValue.FAILURE, "Dialog subprocess exited without returning a result") elif succ: diff --git a/src/testium/interpreter/test_items/test_item_msg_dialog.py b/src/testium/interpreter/test_items/test_item_msg_dialog.py index 280a5fb..38c71aa 100644 --- a/src/testium/interpreter/test_items/test_item_msg_dialog.py +++ b/src/testium/interpreter/test_items/test_item_msg_dialog.py @@ -20,12 +20,15 @@ class TestItemMsgDialog(TestItemDialogBase): self.is_container = False with item_load_context(self.cmd(), self.name(), self.seqFilename()): self._question = self._prms.getParam('question', required=True) + self._auto_result = self._prms.getParam('auto_result', required=False, default=None) @test_run def execute(self): q = self._prms.expanse(self._question) print("Message Displayed:\n" + q) - exitcode = self._run_dialog(msg_dialog.main, [self.name(), q]) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + args = [self.name(), q] + ([ar] if ar is not None else []) + exitcode = self._run_dialog(msg_dialog.main, args) if exitcode == 0: self.result.set(TestValue.SUCCESS) else: diff --git a/src/testium/interpreter/test_items/test_item_note_dialog.py b/src/testium/interpreter/test_items/test_item_note_dialog.py index b890074..eab04c3 100644 --- a/src/testium/interpreter/test_items/test_item_note_dialog.py +++ b/src/testium/interpreter/test_items/test_item_note_dialog.py @@ -15,12 +15,17 @@ class TestItemNoteDialog(TestItemDialogBase): self.is_container = False with item_load_context(self.cmd(), self.name(), self.seqFilename()): self._question = self._prms.getParam('question', required=True) + self._auto_result = self._prms.getParam('auto_result', required=False, default=None) + self._auto_value = self._prms.getParam('auto_value', required=False, default=None) @test_run def execute(self): q = self._prms.expanse(self._question) print("Question:\n" + q) - result = self._run_dialog_with_result(test_dialog.main, [self.name(), q]) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + av = self._prms.expanse(self._auto_value) if self._auto_value is not None else None + args = [self.name(), q] + ([ar, av] if ar is not None else []) + result = self._run_dialog_with_result(test_dialog.main, args) if result is None: self.result.set(TestValue.FAILURE, "Dialog subprocess exited without returning a result") return diff --git a/src/testium/interpreter/test_items/test_item_question_dialog.py b/src/testium/interpreter/test_items/test_item_question_dialog.py index ed1159f..88db0c3 100644 --- a/src/testium/interpreter/test_items/test_item_question_dialog.py +++ b/src/testium/interpreter/test_items/test_item_question_dialog.py @@ -19,12 +19,15 @@ class TestItemQuestionDialog(TestItemDialogBase): self.is_container = False with item_load_context(self.cmd(), self.name(), self.seqFilename()): self._question = self._prms.getParam('question', required=True) + self._auto_result = self._prms.getParam('auto_result', required=False, default=None) @test_run def execute(self): q = self._prms.expanse(self._question) print('Question asked:\n' + q + '\n') - succ = self._run_dialog_with_result(question_dialog.main, [self.name(), q]) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + args = [self.name(), q] + ([ar] if ar is not None else []) + succ = self._run_dialog_with_result(question_dialog.main, args) if succ is None: self.result.set(TestValue.FAILURE, "Dialog subprocess exited without returning a result") return diff --git a/src/testium/interpreter/test_items/test_item_tested_references.py b/src/testium/interpreter/test_items/test_item_tested_references.py index 9c14b22..c3ecf92 100644 --- a/src/testium/interpreter/test_items/test_item_tested_references.py +++ b/src/testium/interpreter/test_items/test_item_tested_references.py @@ -16,12 +16,15 @@ class TestItemTestedRefsDialog(TestItemDialogBase): with item_load_context(self.cmd(), self.name(), self.seqFilename()): self._question = self._prms.getParam('question', required=True) self._init_values = self._prms.getParamAll('reference', required=False, processed=True) + self._auto_result = self._prms.getParam('auto_result', required=False, default=None) @test_run def execute(self): q = self._prms.expanse(self._question) init_values = ','.join(self._init_values) - result = self._run_dialog_with_result(tested_refs_dialog.main, [self.name(), q, init_values]) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + args = [self.name(), q, init_values] + ([ar] if ar is not None else []) + result = self._run_dialog_with_result(tested_refs_dialog.main, args) if result is None: self.result.set(TestValue.FAILURE, "Dialog subprocess exited without returning a result") return diff --git a/src/testium/interpreter/test_items/test_item_value_dialog.py b/src/testium/interpreter/test_items/test_item_value_dialog.py index c589598..64ad25a 100644 --- a/src/testium/interpreter/test_items/test_item_value_dialog.py +++ b/src/testium/interpreter/test_items/test_item_value_dialog.py @@ -19,13 +19,18 @@ class TestItemValueDialog(TestItemDialogBase): with item_load_context(self.cmd(), self.name(), self.seqFilename()): self._question = self._prms.getParam('question', required=True) self._default = self._prms.getParam('default', '') + self._auto_result = self._prms.getParam('auto_result', required=False, default=None) + self._auto_value = self._prms.getParam('auto_value', required=False, default=None) @test_run def execute(self): q = self._prms.expanse(self._question) d = self._prms.expanse(self._default) print("Question:\n" + q) - result = self._run_dialog_with_result(test_dialog.main, [self.name(), q, d]) + ar = self._prms.expanse(self._auto_result) if self._auto_result is not None else None + av = self._prms.expanse(self._auto_value) if self._auto_value is not None else None + args = [self.name(), q, d] + ([ar, av] if ar is not None else []) + result = self._run_dialog_with_result(test_dialog.main, args) if result is None: self.result.set(TestValue.FAILURE, "Dialog subprocess exited without returning a result") return diff --git a/src/testium/interpreter/test_items/tested_references_files/tested_refs_dialog.py b/src/testium/interpreter/test_items/tested_references_files/tested_refs_dialog.py index 5789356..d1695e8 100644 --- a/src/testium/interpreter/test_items/tested_references_files/tested_refs_dialog.py +++ b/src/testium/interpreter/test_items/tested_references_files/tested_refs_dialog.py @@ -2,7 +2,7 @@ import sys from multiprocessing import freeze_support from PySide6.QtWidgets import (QApplication, QDialog, QTableWidgetItem) -from PySide6.QtCore import (Qt, QSettings) +from PySide6.QtCore import Qt, QSettings, QTimer try: from interpreter.test_items.tested_references_files import tested_refs_win @@ -52,6 +52,9 @@ def main(args, conn=None): i += 1 d.tableReferences.setFocus() + auto_result = args[3] if len(args) > 3 else None + if auto_result is not None: + QTimer.singleShot(2000, lambda: d.accept() if auto_result.lower() == 'ok' else d.reject()) dres = d.exec() if dres == QDialog.Rejected: diff --git a/test/validation/items/dialogs/test.tum b/test/validation/items/dialogs/test.tum index 062374e..abfbb18 100644 --- a/test/validation/items/dialogs/test.tum +++ b/test/validation/items/dialogs/test.tum @@ -2,6 +2,7 @@ name: dialog image PASS condition: $(validation_dialogs) question: click ok if you see the image + auto_result: "ok" key: $(test)_PASS filename: $(test_path)$(psep)IMG_20140213_171455.jpg @@ -9,6 +10,7 @@ name: dialog image FAIL condition: $(validation_dialogs) question: click cancel + auto_result: "cancel" key: $(test)_FAIL filename: $(test_path)$(psep)IMG_20140213_171455.jpg @@ -17,45 +19,54 @@ condition: $(validation_dialogs) key: $(test)_PASS question: click ok + auto_result: "ok" - dialog_references: name: dialog_reference FAIL condition: $(validation_dialogs) key: $(test)_FAIL question: click cancel + auto_result: "cancel" - dialog_value: name: dialog_value PASS condition: $(validation_dialogs) key: $(test)_PASS question: enter 123 and click ok + auto_result: "ok" + auto_value: "123" - dialog_value: name: dialog_value empty FAIL condition: $(validation_dialogs) key: $(test)_FAIL question: enter nothing and click ok + auto_result: "ok" - dialog_value: name: dialog_value canceled FAIL condition: $(validation_dialogs) key: $(test)_FAIL question: enter nothing and click cancel + auto_result: "cancel" - dialog_message: name: dialog_message PASS condition: $(validation_dialogs) key: $(test)_PASS question: click ok + auto_result: "ok" - dialog_question: name: dialog_question PASS condition: $(validation_dialogs) key: $(test)_PASS question: click yes + auto_result: "yes" - dialog_question: name: dialog_question FAIL condition: $(validation_dialogs) key: $(test)_FAIL question: click no + auto_result: "no" diff --git a/test/validation/items/plot/test.tum b/test/validation/items/plot/test.tum index aef9792..1897780 100644 --- a/test/validation/items/plot/test.tum +++ b/test/validation/items/plot/test.tum @@ -71,4 +71,4 @@ steps: - close: wait_dialog_exit: True - timeout: 60 + timeout: 2