diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-03-15 10:17:12 -0400 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-03-19 15:59:34 -0300 |
commit | 1356f832ae7a51435e904218014261072099d3c2 (patch) | |
tree | b92f9ac7a1d360595d9d9e7959d91d863b64b39b | |
parent | ff3f3a9cf2efc3e51de83831ffba355abe61e701 (diff) |
Fixes QPixmap.loadFromData method and extends QPixmap test cases.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Bruno Araújo <bruno.araujo@openbossa.org>
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 15 | ||||
-rw-r--r-- | tests/qtgui/qpixmap_test.py | 16 | ||||
-rw-r--r-- | tests/qtgui/sample.png | bin | 0 -> 55944 bytes |
3 files changed, 29 insertions, 2 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 8da8b3a4a..802e7ab42 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -666,7 +666,20 @@ <modify-function signature="QPixmap(const char **)" remove="all"/> <modify-function signature="serialNumber()const" remove="all"/> <!--### Obsolete in 4.3--> - <modify-function signature="loadFromData(const uchar *,uint,const char *,QFlags<Qt::ImageConversionFlag>)" remove="all"/> + <modify-function signature="loadFromData(const uchar*,uint,const char*,QFlags<Qt::ImageConversionFlag>)"> + <modify-argument index="1"> + <replace-type modified-type="const char*"/> + <conversion-rule class="native"> + const uchar* %out = reinterpret_cast<const uchar*>(PyString_AS_STRING(%PYARG_1)); + </conversion-rule> + </modify-argument> + <modify-argument index="2"> + <remove-argument/> + <conversion-rule class="native"> + uint %out = static_cast<uint>(PyString_GET_SIZE(%PYARG_1)); + </conversion-rule> + </modify-argument> + </modify-function> </value-type> <value-type name="QTextCursor" > <extra-includes> diff --git a/tests/qtgui/qpixmap_test.py b/tests/qtgui/qpixmap_test.py index bc287f369..64264109b 100644 --- a/tests/qtgui/qpixmap_test.py +++ b/tests/qtgui/qpixmap_test.py @@ -1,5 +1,6 @@ import unittest +import os from helper import UsesQApplication from PySide.QtGui import * from PySide.QtCore import * @@ -17,12 +18,25 @@ class QPixmapTest(UsesQApplication): def testQStringConstructor(self): pixmap = QPixmap(QString("Testing!")) - def testQVariantConstructor(self): + def testQVariantConstructor2(self): v = QVariant(QPixmap()) pixmap2 = QPixmap(v) v = QVariant(QImage()) pixmap2 = QPixmap(v) + def testQPixmapLoadFromDataWithQFile(self): + f = QFile(os.path.join(os.path.dirname(__file__), 'sample.png')) + self.assert_(f.open(QIODevice.ReadOnly)) + data = f.read(f.size()) + f.close() + pixmap = QPixmap() + self.assert_(pixmap.loadFromData(data)) + + def testQPixmapLoadFromDataWithPython(self): + data = open(os.path.join(os.path.dirname(__file__),'sample.png'),'rb').read() + pixmap = QPixmap() + self.assert_(pixmap.loadFromData(data)) + if __name__ == '__main__': unittest.main() diff --git a/tests/qtgui/sample.png b/tests/qtgui/sample.png Binary files differnew file mode 100644 index 000000000..60450f0dc --- /dev/null +++ b/tests/qtgui/sample.png |