forked from openlp/openlp
Test
This commit is contained in:
parent
a4829c62ba
commit
bf32fe164a
@ -74,11 +74,13 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
|
|||||||
:param name: A string which is set as object name.
|
:param name: A string which is set as object name.
|
||||||
:param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``,
|
:param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``,
|
||||||
``close``, and ``defaults``.
|
``close``, and ``defaults``.
|
||||||
:param custom_buttons: A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added
|
:param custom_buttons: A list of additional buttons. If an item is an instance of QtGui.QAbstractButton it is added
|
||||||
with QDialogButtonBox.ActionRole. Other wise the item has to be a tuple of a button and a ButtonRole.
|
with QDialogButtonBox.ActionRole. Otherwise the item has to be a tuple of a Button and a ButtonRole.
|
||||||
"""
|
"""
|
||||||
if custom_buttons is None:
|
if custom_buttons is None:
|
||||||
custom_buttons = []
|
custom_buttons = []
|
||||||
|
if standard_buttons is None:
|
||||||
|
standard_buttons = []
|
||||||
buttons = QtGui.QDialogButtonBox.NoButton
|
buttons = QtGui.QDialogButtonBox.NoButton
|
||||||
if 'ok' in standard_buttons:
|
if 'ok' in standard_buttons:
|
||||||
buttons |= QtGui.QDialogButtonBox.Ok
|
buttons |= QtGui.QDialogButtonBox.Ok
|
||||||
|
@ -53,3 +53,31 @@ class TestUi(TestCase):
|
|||||||
# THEN: The wizard should have one page with a pixmap.
|
# THEN: The wizard should have one page with a pixmap.
|
||||||
self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
|
self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
|
||||||
self.assertIsInstance(wizard.page(0).pixmap(QtGui.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
self.assertIsInstance(wizard.page(0).pixmap(QtGui.QWizard.WatermarkPixmap), QtGui.QPixmap)
|
||||||
|
|
||||||
|
def test_create_button_box(self):
|
||||||
|
"""
|
||||||
|
Test creating a button box for a dialog
|
||||||
|
"""
|
||||||
|
# GIVEN: A dialog
|
||||||
|
dialog = QtGui.QDialog()
|
||||||
|
|
||||||
|
# WHEN: We create the button box with five buttons
|
||||||
|
btnbox = create_button_box(dialog, 'my_btns', ['ok', 'save', 'cancel', 'close', 'defaults'])
|
||||||
|
|
||||||
|
# THEN: We should get a QDialogButtonBox with five buttons
|
||||||
|
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
||||||
|
self.assertEqual(5, len(btnbox.buttons()))
|
||||||
|
|
||||||
|
# WHEN: We create the button box with a custom button
|
||||||
|
btnbox = create_button_box(dialog, 'my_btns', None, [QtGui.QPushButton('Custom')])
|
||||||
|
# THEN: We should get a QDialogButtonBox with one button
|
||||||
|
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
||||||
|
self.assertEqual(1, len(btnbox.buttons()))
|
||||||
|
|
||||||
|
# WHEN: We create the button box with a custom button and a custom role
|
||||||
|
btnbox = create_button_box(dialog, 'my_btns', None,
|
||||||
|
[(QtGui.QPushButton('Help'), QtGui.QDialogButtonBox.HelpRole)])
|
||||||
|
# THEN: We should get a QDialogButtonBox with one button with a certain role
|
||||||
|
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
||||||
|
self.assertEqual(1, len(btnbox.buttons()))
|
||||||
|
self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
|
||||||
|
Loading…
Reference in New Issue
Block a user