-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4188378
commit db5543c
Showing
1 changed file
with
15 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,23 @@ | ||
import unittest | ||
from printdialog import PrintDialog | ||
from modules.gui.printdialog import DlgPrint | ||
|
||
|
||
class TestPrintDialog(unittest.TestCase): | ||
def test_handle_print(qtbot): | ||
dialog = DlgPrint() | ||
qtbot.addWidget(dialog) | ||
editor = dialog.editor | ||
editor.setText('This is a test') | ||
dialog.handle_print() | ||
assert dialog.buttonPrint.isEnabled() | ||
|
||
def test_print_dialog(self): | ||
# Create a new PrintDialog object | ||
dialog = PrintDialog() | ||
|
||
# Check that the dialog is created successfully | ||
self.assertIsInstance(dialog, PrintDialog) | ||
|
||
# Check that the dialog has the correct title | ||
self.assertEqual(dialog.windowTitle(), "Print Dialog") | ||
|
||
# Check that the dialog has the correct layout | ||
self.assertEqual(dialog.layout().count(), 3) | ||
|
||
# Check that the first row in the layout contains the correct widgets | ||
self.assertEqual(dialog.layout().itemAt(0).widget(), dialog.label_archer) | ||
self.assertEqual(dialog.layout().itemAt(1).widget(), dialog.combo_archer) | ||
self.assertEqual(dialog.layout().itemAt(2).widget(), dialog.button_ok) | ||
|
||
# Check that the second row in the layout contains the correct widgets | ||
self.assertEqual(dialog.layout().itemAt(3).widget(), dialog.label_arrow) | ||
self.assertEqual(dialog.layout().itemAt(4).widget(), dialog.combo_arrow) | ||
self.assertEqual(dialog.layout().itemAt(5).widget(), dialog.button_cancel) | ||
|
||
# Check that the dialog's `show()` method works correctly | ||
dialog.show() | ||
self.assertIsTrue(dialog.isVisible()) | ||
|
||
# Check that the dialog's `hide()` method works correctly | ||
dialog.hide() | ||
self.assertIsFalse(dialog.isVisible()) | ||
|
||
# Check that the dialog's `exec_()` method works correctly | ||
dialog.exec_() | ||
self.assertIsFalse(dialog.isVisible()) | ||
|
||
def test_handle_preview(qtbot): | ||
dialog = DlgPrint() | ||
qtbot.addWidget(dialog) | ||
editor = dialog.editor | ||
editor.setText('This is a test') | ||
dialog.handle_preview() | ||
assert dialog.buttonPreview.isEnabled() | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |