Skip to content

Commit

Permalink
added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
florianlink committed Sep 16, 2014
1 parent bc3057e commit 4b7e7b4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
17 changes: 17 additions & 0 deletions tests/PythonQtTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,23 @@ void PythonQtTestSlotCalling::testQVariantSlotCalls()
QVERIFY(_helper->runScript("if obj.getQVariant(obj)==obj: obj.setPassed();\n"));
}

void PythonQtTestSlotCalling::testQListSlotCalls()
{
QVERIFY(_helper->runScript("if obj.getQListInt()==(1,2,3): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListUnsignedInt()==(1,2,3): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListGLuint()==(1,2,3): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListGLuint64()==(1,2,3): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListqint64()==(1,2,3): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListquint64()==(1,2,3): obj.setPassed();\n"));

QVERIFY(_helper->runScript("if obj.getQListqreal()==(1.1,2.2,3.3): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListdouble()==(1.1,2.2,3.3): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListfloat()==(1,2,3): obj.setPassed();\n"));

QVERIFY(_helper->runScript("if obj.getQListQSize()==(PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)): obj.setPassed();\n"));
QVERIFY(_helper->runScript("if obj.getQListQSize((PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)))==(PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)): obj.setPassed();\n"));
}

void PythonQtTestSlotCalling::testObjectSlotCalls()
{
QVERIFY(_helper->runScript("if obj.getQObject(obj)==obj: obj.setPassed();\n"));
Expand Down
15 changes: 15 additions & 0 deletions tests/PythonQtTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <QColor>
#include <QBrush>
#include <QCursor>
#include <QGLWidget>

class PythonQtTestSlotCallingHelper;
class PythonQtTestApiHelper;
Expand Down Expand Up @@ -317,6 +318,7 @@ private Q_SLOTS:
void testPODSlotCalls();
void testCPPSlotCalls();
void testQVariantSlotCalls();
void testQListSlotCalls();
void testObjectSlotCalls();
void testMultiArgsSlotCall();
void testPyObjectSlotCall();
Expand Down Expand Up @@ -379,6 +381,19 @@ public Q_SLOTS:
QStringList getQStringList(const QStringList& l) { _called = true; return l; }
QVariant getQVariant(const QVariant& var) { _called = true; return var; }

QList<int> getQListInt() { _called = true; return QList<int>() << 1 << 2 << 3; }
QList<unsigned int> getQListUnsignedInt() { _called = true; return QList<unsigned int>() << 1 << 2 << 3; }
QList<qreal> getQListqreal() { _called = true; return QList<qreal>() << 1.1 << 2.2 << 3.3; }
QList<float> getQListfloat() { _called = true; return QList<float>() << 1 << 2 << 3; }
QList<double> getQListdouble() { _called = true; return QList<double>() << 1.1 << 2.2 << 3.3; }
QList<quint64> getQListquint64() { _called = true; return QList<quint64>() << 1 << 2 << 3; }
QList<qint64> getQListqint64() { _called = true; return QList<qint64>() << 1 << 2 << 3; }
QList<GLuint64> getQListGLuint64() { _called = true; return QList<GLuint64>() << 1 << 2 << 3; }
QList<GLuint> getQListGLuint() { _called = true; return QList<GLuint>() << 1 << 2 << 3; }

QList<QSize> getQListQSize() { _called = true; return QList<QSize>() << QSize(1,2) << QSize(3,4); }
QList<QSize> getQListQSize(const QList<QSize>& list) { _called = true; return list; }

// QColor as representative for C++ value classes
QColor getQColor1(const QColor& var) { _called = true; return var; }
QColor getQColor2(QColor& var) { _called = true; return var; }
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TEMPLATE = app

DESTDIR = ../lib

QT += testlib
QT += testlib opengl

contains(QT_MAJOR_VERSION, 5) {
QT += widgets
Expand Down

0 comments on commit 4b7e7b4

Please sign in to comment.