diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-25 14:06:43 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-25 14:06:43 -0300 |
commit | b4942f58314130fbe6aa9ce8a307b3d21fc633c4 (patch) | |
tree | 69e1051ccc53ec0cffd1bfc47a5d5a532cb314a6 /tests | |
parent | b0112feddd5dbcdc602fe4836591313c04c8d934 (diff) |
Adds a QStyle test.
The new test creates and sets a QStyle for all widgets in an UI
hierarchy. One of the widgets, a QFontComboBox, contains a QLineEdit
originated in C++, calling setStyle in it must not steal the ownership
of the QStyle or else things will break.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/qtgui/qstyle_test.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/qtgui/qstyle_test.py b/tests/qtgui/qstyle_test.py new file mode 100755 index 000000000..da467e871 --- /dev/null +++ b/tests/qtgui/qstyle_test.py @@ -0,0 +1,32 @@ + +import unittest +from helper import UsesQApplication + +from PySide.QtGui import QWidget, QLabel, QFontComboBox, QStyleFactory + +class SetStyleTest(UsesQApplication): + '''Tests setting the same QStyle for all objects in a UI hierarchy.''' + + def testSetStyle(self): + '''All this test have to do is not break with some invalid Python wrapper.''' + + def setStyleHelper(widget, style): + widget.setStyle(style) + widget.setPalette(style.standardPalette()) + for child in widget.children(): + if isinstance(child, QWidget): + setStyleHelper(child, style) + + container = QWidget() + # QFontComboBox is used because it has an QLineEdit created in C++ inside it, + # and if the QWidget.setStyle(style) steals the ownership of the style + # for the C++ originated widget everything will break. + fontComboBox = QFontComboBox(container) + label = QLabel(container) + label.setText('Label') + style = QStyleFactory.create(QStyleFactory.keys()[0]) + setStyleHelper(container, style) + +if __name__ == '__main__': + unittest.main() + |