[Kde-bindings] KDE/kdebindings
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Nov 3 11:48:59 UTC 2008
SVN commit 879478 by rdale:
* Added a smoke library, with corresponding Ruby and C# bindings for the QtTest module
CCMAIL: kde-bindings at kde.org
CCMAIL: divided.mind at gmail.com
M +7 -0 csharp/CMakeLists.txt
A csharp/qttest (directory)
A csharp/qttest/CMakeLists.txt
A csharp/qttest/qttest (directory)
A csharp/qttest/qttest/QSignalSpy.cs
A csharp/qttest/qttest/QTest.cs
A csharp/qttest/qttest/QTestAccessibility.cs
A csharp/qttest/qttest/QTestAccessibilityEvent.cs
A csharp/qttest/qttest/QTestData.cs
A csharp/qttest/qttest/QTestDelayEvent.cs
A csharp/qttest/qttest/QTestEvent.cs
A csharp/qttest/qttest/QTestEventList.cs
A csharp/qttest/qttest/QTestEventLoop.cs
A csharp/qttest/qttest/QTestKeyClicksEvent.cs
A csharp/qttest/qttest/QTestKeyEvent.cs
A csharp/qttest/qttest/QTestMouseEvent.cs
A csharp/qttest/src (directory)
A csharp/qttest/src/AssemblyInfo.cs
A csharp/qttest/src/QtTest.cs
A csharp/qttest/src/qttest.cpp [License: GPL (v2+)]
A csharp/qttest/src/qttesthandlers.cpp [License: GPL (v2+)]
M +9 -6 ruby/qttest/CMakeLists.txt
M +50 -103 ruby/qttest/qttest.cpp
A ruby/qttest/qttest.rb
A ruby/qttest/qttesthandlers.cpp [License: GPL]
M +7 -1 smoke/CMakeLists.txt
A smoke/qttest (directory)
A smoke/qttest/CMakeLists.txt
A smoke/qttest/classlist
A smoke/qttest/generate.pl.cmake
A smoke/qttest/header_list
A smoke/qttest/hint_header_list.pl
A smoke/qttest/qttest_header_list
A smoke/qttest_smoke.h [License: UNKNOWN]
--- trunk/KDE/kdebindings/csharp/CMakeLists.txt #879477:879478
@@ -1,5 +1,6 @@
OPTION(ENABLE_QYOTO "build Qyoto" ON)
OPTION(ENABLE_QTSCRIPT_SHARP "build QtScript" ON)
+OPTION(ENABLE_QTTEST "build QtTest" ON)
OPTION(ENABLE_QTUITOOLS_SHARP "build QtUiTools" ON)
OPTION(ENABLE_QTWEBKIT_SHARP "build QtWebKit" ON)
OPTION(ENABLE_QSCINTILLA_SHARP "build QScintillaSharp" OFF)
@@ -9,6 +10,7 @@
SET(QYOTO_ENABLED "no")
SET(QTSCRIPT_ENABLED "no")
+set(QTTEST_ENABLED "no")
SET(QTWEBKIT_ENABLED "no")
SET(QTUITOOLS_ENABLED "no")
SET(QTWEBKIT_ENABLED "no")
@@ -59,6 +61,11 @@
ADD_SUBDIRECTORY(qtscript)
ENDIF(ENABLE_QTSCRIPT_SHARP)
+ IF(ENABLE_QTTEST)
+ SET(QTTEST_ENABLED "yes")
+ ADD_SUBDIRECTORY( qttest )
+ ENDIF(ENABLE_QTTEST)
+
IF(ENABLE_QTUITOOLS_SHARP)
SET(QTUITOOLS_SHARP_ENABLED "yes")
ADD_SUBDIRECTORY(qtuitools)
--- trunk/KDE/kdebindings/ruby/qttest/CMakeLists.txt #879477:879478
@@ -1,7 +1,10 @@
-include_directories(${RUBY_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/ruby/qtruby/src)
+include_directories( ${CMAKE_SOURCE_DIR}/smoke ${RUBY_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/ruby/qtruby/src)
+INCLUDE_DIRECTORIES (${QT_INCLUDES} ${KDE4_INCLUDE_DIR})
-set(rubyqttest_LIBRARY_SRC qttest.cpp)
-add_library(rubyqttest MODULE ${rubyqttest_LIBRARY_SRC})
-target_link_libraries(rubyqttest ${RUBY_LIBRARY} qtruby4shared QtTest)
-set_target_properties(rubyqttest PROPERTIES PREFIX "" OUTPUT_NAME qttest)
-install(TARGETS rubyqttest DESTINATION ${CUSTOM_RUBY_SITE_ARCH_DIR})
+set(qttest_LIBRARY_SRC qttest.cpp qttesthandlers.cpp)
+
+add_library(qttest MODULE ${qttest_LIBRARY_SRC})
+target_link_libraries(qttest ${QT_QTCORE_LIBRARY} ${RUBY_LIBRARY} smokeqt smokekde smokeqttest qtruby4shared)
+set_target_properties(qttest PROPERTIES PREFIX "")
+install(TARGETS qttest DESTINATION ${CUSTOM_RUBY_SITE_ARCH_DIR})
+install(FILES qttest.rb DESTINATION ${CUSTOM_RUBY_SITE_LIB_DIR}/qttest)
--- trunk/KDE/kdebindings/ruby/qttest/qttest.cpp #879477:879478
@@ -1,131 +1,78 @@
-/*
- qttest.rb - Ruby bindings for the QtTest library
- Copyright (C) 2008 Rafał Rzepecki
+/***************************************************************************
+ qttest.cpp - QtTest ruby extension
+ -------------------
+ begin : 29-10-2008
+ copyright : (C) 2008 by Richard Dale
+ email : richard.j.dale at gmail.com
+ ***************************************************************************/
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+#include <ruby.h>
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+#include <QHash>
+#include <QList>
+#include <QtDebug>
-#include <ruby.h>
-#include <QtTest/qtestkeyboard.h>
+#include <smoke/qttest_smoke.h>
+
#include <qtruby.h>
-#include <marshall_types.h>
+#include <iostream>
-template <typename T>
-static T value2enum(VALUE v)
+static VALUE getClassList(VALUE /*self*/)
{
- long res;
- if (v == Qnil) {
- res = 0;
- } else if (TYPE(v) == T_OBJECT) {
- // Both Qt::Enum and Qt::Integer have a value() method, so 'get_qinteger()' can be called ok
- VALUE temp = rb_funcall(qt_internal_module, rb_intern("get_qinteger"), 1, v);
- res = (long) NUM2LONG(temp);
- } else {
- res = (long) NUM2LONG(v);
+ VALUE classList = rb_ary_new();
+ for (int i = 1; i < qttest_Smoke->numClasses; i++) {
+ if (qttest_Smoke->classes[i].className && !qttest_Smoke->classes[i].external)
+ rb_ary_push(classList, rb_str_new2(qttest_Smoke->classes[i].className));
}
-
- return static_cast<T>(res);
+ return classList;
}
-static VALUE qwidget_key_click(int argc, VALUE * argv, VALUE self)
+const char*
+resolve_classname_qttest(smokeruby_object * o)
{
- smokeruby_object *o = value_obj_info(self);
- QWidget * widget = qobject_cast<QWidget *>(static_cast<QObject *>(o->ptr));
- if (!widget)
- rb_call_super(argc, argv);
-
- if (argc < 1 || argc > 3) rb_raise(rb_eArgError, "Invalid argument list");
-
- char chKey;
- Qt::Key enKey;
- bool isChar = false;
- switch(TYPE(argv[0])) {
- case T_STRING:
- case T_FIXNUM:
- chKey = NUM2CHR(argv[0]);
- isChar = true;
- break;
- default:
- enKey = value2enum<Qt::Key>(argv[0]);
- }
-
- Qt::KeyboardModifiers modifier = Qt::NoModifier;
- if (argc > 1)
- modifier = value2enum<Qt::KeyboardModifiers>(argv[1]);
- int delay = -1;
- if (argc > 2)
- delay = NUM2INT(argv[2]);
-
- if (isChar)
- QTest::keyClick(widget, chKey, modifier, delay);
- else
- QTest::keyClick(widget, enKey, modifier, delay);
-
- return Qnil;
+ return qtruby_modules[o->smoke].binding->className(o->classId);
}
-static VALUE qwidget_key_clicks(int argc, VALUE * argv, VALUE self)
-{
- smokeruby_object *o = value_obj_info(self);
- QWidget * widget = qobject_cast<QWidget *>(static_cast<QObject *>(o->ptr));
- if (!widget)
- rb_call_super(argc, argv);
+extern TypeHandler QtTest_handlers[];
- if (argc < 1 || argc > 3) rb_raise(rb_eArgError, "Invalid argument list");
- char * sequence = StringValueCStr(argv[0]);
+extern "C" {
- Qt::KeyboardModifiers modifier = Qt::NoModifier;
- if (argc > 1)
- modifier = value2enum<Qt::KeyboardModifiers>(argv[1]);
- int delay = -1;
- if (argc > 2)
- delay = NUM2INT(argv[2]);
+VALUE qttest_module;
+VALUE qttest_internal_module;
- QTest::keyClicks(widget, sequence, modifier, delay);
+static QtRuby::Binding binding;
- return Qnil;
-}
-
-static VALUE qtest_qwait(VALUE /*self*/, VALUE ms_)
+Q_DECL_EXPORT void
+Init_qttest()
{
- int ms = NUM2INT(ms_);
+ init_qttest_Smoke();
- QTest::qWait(ms);
- return Qnil;
-}
+ binding = QtRuby::Binding(qttest_Smoke);
-extern TypeHandler qttest_handlers[];
+ smokeList << qttest_Smoke;
-extern "C" {
+ QtRubyModule module = { "QtTest", resolve_classname_qttest, 0, &binding };
+ qtruby_modules[qttest_Smoke] = module;
-Q_DECL_EXPORT void
-Init_qttest()
-{
- rb_require("Qt4");
+ install_handlers(QtTest_handlers);
- rb_define_method(qt_base_class, "key_click", (VALUE (*) (...)) qwidget_key_click, -1);
- rb_define_method(qt_base_class, "keyClick", (VALUE (*) (...)) qwidget_key_click, -1);
- rb_define_method(qt_base_class, "key_clicks", (VALUE (*) (...)) qwidget_key_clicks, -1);
- rb_define_method(qt_base_class, "keyClicks", (VALUE (*) (...)) qwidget_key_clicks, -1);
+ qttest_module = rb_define_module("QtTest");
+ qttest_internal_module = rb_define_module_under(qttest_module, "Internal");
- VALUE test_class = rb_define_class_under(qt_module, "Test", rb_cObject);
- rb_define_singleton_method(test_class, "qWait", (VALUE (*) (...)) qtest_qwait, 1);
- rb_define_singleton_method(test_class, "wait", (VALUE (*) (...)) qtest_qwait, 1);
-}
+ rb_define_singleton_method(qttest_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);
+ rb_require("qttest/qttest.rb");
+ rb_funcall(qttest_internal_module, rb_intern("init_all_classes"), 0);
}
-// kate: indent-width 4;
+}
--- trunk/KDE/kdebindings/smoke/CMakeLists.txt #879477:879478
@@ -2,7 +2,8 @@
OPTION(ENABLE_QTWEBKIT_SMOKE "build QtWebKitSmoke" ON)
OPTION(ENABLE_QTSCRIPT_SMOKE "build QtScriptSmoke" ON)
OPTION(ENABLE_QTUITOOLS_SMOKE "build QtUiToolsSmoke" ON)
-OPTION(ENABLE_PHONON_SMOKE "build PhononSmoke" OFF)
+OPTION(ENABLE_QTTEST_SMOKE "build QtTestSmoke" ON)
+OPTION(ENABLE_PHONON_SMOKE "build PhononSmoke" ON)
OPTION(ENABLE_QSCI_SMOKE "build QsciSmoke" ON)
OPTION(ENABLE_QWT_SMOKE "build QwtSmoke" OFF)
OPTION(ENABLE_KDE_SMOKE "build KDESmoke" ON)
@@ -31,6 +32,11 @@
set(SMOKE_ENABLED "${SMOKE_ENABLED}, QtUiTools")
endif(ENABLE_QTUITOOLS_SMOKE)
+ if(ENABLE_QTTEST_SMOKE)
+ add_subdirectory(qttest)
+ set(SMOKE_ENABLED "${SMOKE_ENABLED}, QtTest")
+ endif(ENABLE_QTTEST_SMOKE)
+
if(ENABLE_PHONON_SMOKE AND PHONON_FOUND)
add_subdirectory(phonon)
set(SMOKE_ENABLED "${SMOKE_ENABLED}, Phonon")
More information about the Kde-bindings
mailing list