diff --git a/tests/PythonQtTests.cpp b/tests/PythonQtTests.cpp index ddac5a4..363b7f7 100644 --- a/tests/PythonQtTests.cpp +++ b/tests/PythonQtTests.cpp @@ -125,6 +125,16 @@ void PythonQtTestSlotCalling::testInheritance() { } +void PythonQtTestSlotCalling::testAutoConversion() { + QVERIFY(_helper->runScript("if obj.setAutoConvertColor(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.setAutoConvertBrush(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QBrush(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.setAutoConvertPen(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.setAutoConvertBrush(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QBrush(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.setAutoConvertPen(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); + 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")); + QVERIFY(_helper->runScript("if obj.setAutoConvertCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape()==PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape(): obj.setPassed();\n")); +} + void PythonQtTestSlotCalling::testNoArgSlotCall() { QVERIFY(_helper->runScript("obj.testNoArg(); obj.setPassed();\n")); @@ -436,6 +446,12 @@ void PythonQtTestApi::testQtNamespace() QVERIFY(PythonQtObjectPtr(_main.getVariable("PythonQt.QtCore.Qt.Alignment"))); } +void PythonQtTestApi::testConnects() +{ +// QVERIFY(qVariantValue(_main.evalScript("PythonQt.Qt.QColor(PythonQt.Qt.Qt.red)" ,Py_eval_input)) == QColor(Qt::red)); + //TODO: add signal/slot connect both with QObject.connect and connect +} + void PythonQtTestApi::testQColorDecorators() { PythonQtObjectPtr colorClass = _main.getVariable("PythonQt.QtGui.QColor"); diff --git a/tests/PythonQtTests.h b/tests/PythonQtTests.h index dc0b4ce..a2e006f 100644 --- a/tests/PythonQtTests.h +++ b/tests/PythonQtTests.h @@ -48,6 +48,11 @@ #include "PythonQtImportFileInterface.h" #include "PythonQtCppWrapperFactory.h" +#include +#include +#include +#include + class PythonQtTestSlotCallingHelper; class PythonQtTestApiHelper; class QWidget; @@ -65,6 +70,7 @@ private slots: void testImporter(); void testQColorDecorators(); void testQtNamespace(); + void testConnects(); private: PythonQtTestApiHelper* _helper; @@ -314,6 +320,7 @@ private slots: void testOverloadedCall(); void testCppFactory(); void testInheritance(); + void testAutoConversion(); private: PythonQtTestSlotCallingHelper* _helper; @@ -427,6 +434,11 @@ public slots: ClassA* createClassDAsA() { _called = true; return new ClassD; } ClassB* createClassDAsB() { _called = true; return new ClassD; } + QColor setAutoConvertColor(const QColor& color) { _called = true; return color; }; + QBrush setAutoConvertBrush(const QBrush& brush) { _called = true; return brush; }; + QPen setAutoConvertPen(const QPen& pen) { _called = true; return pen; }; + QCursor setAutoConvertCursor(const QCursor& cursor) { _called = true; return cursor; }; + private: bool _passed; bool _called;