[Kde-bindings] KDE/kdebindings/php/phpqt/src
Thomas Moenicke
tm at php-qt.org
Sun Oct 26 00:28:07 UTC 2008
SVN commit 875931 by moenicke:
* added unittest for invoking custom signals and slots
CCMAIL: kde-bindings at kde.org
M +33 -9 unittests.cpp
M +1 -0 unittests.h
--- trunk/KDE/kdebindings/php/phpqt/src/unittests.cpp #875930:875931
@@ -5,8 +5,9 @@
#include <QtTest/QtTest>
#include <QPaintEvent>
-#include <QWidget>
+#include <QSlider>
#include <iostream>
+#include <zend.h>
extern Smoke* qt_Smoke;
@@ -23,14 +24,15 @@
/*
* test case for invoking virtual methods
* QWidget::paintEvent( QPaintEvent* x1 );
-
- smoke code:
- virtual void paintEvent(QPaintEvent* x1) {
- Smoke::StackItem x[2];
- x[1].s_class = (void*)x1;
- if(this->_binding->callMethod(18732, (void*)this, x)) return;
- this->QWidget::paintEvent(x1);
- }
+ *
+ * smoke code:
+ * virtual void paintEvent(QPaintEvent* x1)
+ * {
+ * Smoke::StackItem x[2];
+ * x[1].s_class = (void*)x1;
+ * if(this->_binding->callMethod(18732, (void*)this, x)) return;
+ * this->QWidget::paintEvent(x1);
+ * }
*/
void TestPHPQt::InvokeVirtualMethod()
@@ -49,3 +51,25 @@
}
std::cout << std::endl;
}
+
+void TestPHPQt::InvokeSlot()
+{
+ QSlider* slider = static_cast< QSlider* > ( PHPQt::getQtObjectFromZval( _z ) );
+
+ zval* arg;
+ MAKE_STD_ZVAL( arg );
+ ZVAL_LONG( arg, 7 );
+ zval** args = (zval**) safe_emalloc( sizeof( zval* ), 1, 0 );
+ args[0] = arg;
+
+ // last argument is just a dummy here
+ PHPQt::callPHPMethod( _z, QString("setupConnections").toLatin1().constData(), 0, args );
+
+ for(int i = 0; i < 80; i++ )
+ {
+ PHPQt::callPHPMethod( _z, QString("invokeSetValue").toLatin1().constData(), 1, args );
+ }
+ std::cout << std::endl;
+ FREE_ZVAL( arg );
+ efree( args );
+}
--- trunk/KDE/kdebindings/php/phpqt/src/unittests.h #875930:875931
@@ -17,6 +17,7 @@
private slots:
void initTestCase(){}
void InvokeVirtualMethod();
+ void InvokeSlot();
private:
SmokeBinding* _binding;
zval* _z;
More information about the Kde-bindings
mailing list