Skip to content

Commit 3f2b9e3

Browse files
committed
added tests for autoconversion
1 parent 830b1df commit 3f2b9e3

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

tests/PythonQtTests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ void PythonQtTestSlotCalling::testInheritance() {
125125

126126
}
127127

128+
void PythonQtTestSlotCalling::testAutoConversion() {
129+
QVERIFY(_helper->runScript("if obj.setAutoConvertColor(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red): obj.setPassed();\n"));
130+
QVERIFY(_helper->runScript("if obj.setAutoConvertBrush(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QBrush(PythonQt.QtCore.Qt.red): obj.setPassed();\n"));
131+
QVERIFY(_helper->runScript("if obj.setAutoConvertPen(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): obj.setPassed();\n"));
132+
QVERIFY(_helper->runScript("if obj.setAutoConvertBrush(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QBrush(PythonQt.QtCore.Qt.red): obj.setPassed();\n"));
133+
QVERIFY(_helper->runScript("if obj.setAutoConvertPen(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): obj.setPassed();\n"));
134+
QVERIFY(_helper->runScript("if obj.setAutoConvertCursor(PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor)).shape()==PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape(): obj.setPassed();\n"));
135+
QVERIFY(_helper->runScript("if obj.setAutoConvertCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape()==PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape(): obj.setPassed();\n"));
136+
}
137+
128138
void PythonQtTestSlotCalling::testNoArgSlotCall()
129139
{
130140
QVERIFY(_helper->runScript("obj.testNoArg(); obj.setPassed();\n"));
@@ -436,6 +446,12 @@ void PythonQtTestApi::testQtNamespace()
436446
QVERIFY(PythonQtObjectPtr(_main.getVariable("PythonQt.QtCore.Qt.Alignment")));
437447
}
438448

449+
void PythonQtTestApi::testConnects()
450+
{
451+
// QVERIFY(qVariantValue<QColor>(_main.evalScript("PythonQt.Qt.QColor(PythonQt.Qt.Qt.red)" ,Py_eval_input)) == QColor(Qt::red));
452+
//TODO: add signal/slot connect both with QObject.connect and connect
453+
}
454+
439455
void PythonQtTestApi::testQColorDecorators()
440456
{
441457
PythonQtObjectPtr colorClass = _main.getVariable("PythonQt.QtGui.QColor");

tests/PythonQtTests.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
#include "PythonQtImportFileInterface.h"
4949
#include "PythonQtCppWrapperFactory.h"
5050

51+
#include <QPen>
52+
#include <QColor>
53+
#include <QBrush>
54+
#include <QCursor>
55+
5156
class PythonQtTestSlotCallingHelper;
5257
class PythonQtTestApiHelper;
5358
class QWidget;
@@ -65,6 +70,7 @@ private slots:
6570
void testImporter();
6671
void testQColorDecorators();
6772
void testQtNamespace();
73+
void testConnects();
6874

6975
private:
7076
PythonQtTestApiHelper* _helper;
@@ -314,6 +320,7 @@ private slots:
314320
void testOverloadedCall();
315321
void testCppFactory();
316322
void testInheritance();
323+
void testAutoConversion();
317324

318325
private:
319326
PythonQtTestSlotCallingHelper* _helper;
@@ -427,6 +434,11 @@ public slots:
427434
ClassA* createClassDAsA() { _called = true; return new ClassD; }
428435
ClassB* createClassDAsB() { _called = true; return new ClassD; }
429436

437+
QColor setAutoConvertColor(const QColor& color) { _called = true; return color; };
438+
QBrush setAutoConvertBrush(const QBrush& brush) { _called = true; return brush; };
439+
QPen setAutoConvertPen(const QPen& pen) { _called = true; return pen; };
440+
QCursor setAutoConvertCursor(const QCursor& cursor) { _called = true; return cursor; };
441+
430442
private:
431443
bool _passed;
432444
bool _called;

0 commit comments

Comments
 (0)