From ab918abc1e103e0ca86939f7d057e8a44ac8a4ef Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 7 Jun 2010 14:43:45 -0300 Subject: Created new unittest model. Separete unittest for module. Only run unittest for compiled modules. Reviewer: Marcelo Lira , Luciano Wolf --- tests/CMakeLists.txt | 60 ++-- tests/QtCore/CMakeLists.txt | 71 +++++ tests/QtCore/blocking_signals_test.py | 107 +++++++ tests/QtCore/buffer_test.py | 13 + tests/QtCore/child_event_test.py | 55 ++++ tests/QtCore/deletelater_test.py | 22 ++ tests/QtCore/duck_punching_test.py | 56 ++++ tests/QtCore/missing_symbols_test.py | 16 + tests/QtCore/qabs_test.py | 20 ++ tests/QtCore/qabstracttransition_test.py | 156 ++++++++++ tests/QtCore/qanimationgroup_test.py | 24 ++ tests/QtCore/qbitarray_test.py | 119 ++++++++ tests/QtCore/qbytearray_buffer_protocol_test.py | 20 ++ .../qbytearray_concatenation_operator_test.py | 46 +++ tests/QtCore/qbytearray_operator_iadd_test.py | 73 +++++ tests/QtCore/qbytearray_operator_test.py | 82 +++++ tests/QtCore/qbytearray_test.py | 98 ++++++ tests/QtCore/qchar_test.py | 59 ++++ tests/QtCore/qcoreapplication_instance_test.py | 20 ++ tests/QtCore/qdatastream_test.py | 330 +++++++++++++++++++++ tests/QtCore/qdate_test.py | 28 ++ tests/QtCore/qenum_test.py | 45 +++ tests/QtCore/qevent_test.py | 24 ++ tests/QtCore/qfile_test.py | 31 ++ tests/QtCore/qfileinfo_test.py | 17 ++ tests/QtCore/qflags_test.py | 56 ++++ tests/QtCore/qhandle_test.py | 16 + tests/QtCore/qlatin1string_test.py | 21 ++ tests/QtCore/qlinef_test.py | 20 ++ tests/QtCore/qlocale_test.py | 40 +++ tests/QtCore/qmetaobject_test.py | 51 ++++ tests/QtCore/qmodelindex_internalpointer_test.py | 50 ++++ tests/QtCore/qobject_children_segfault_test.py | 29 ++ tests/QtCore/qobject_connect_notify_test.py | 70 +++++ tests/QtCore/qobject_event_filter_test.py | 80 +++++ tests/QtCore/qobject_inherits_test.py | 43 +++ tests/QtCore/qobject_parent_test.py | 234 +++++++++++++++ tests/QtCore/qobject_property_test.py | 71 +++++ tests/QtCore/qobject_protected_methods_test.py | 38 +++ tests/QtCore/qobject_test.py | 43 +++ tests/QtCore/qobject_timer_event_test.py | 44 +++ tests/QtCore/qobject_tr_as_instance_test.py | 55 ++++ tests/QtCore/qpoint_test.py | 21 ++ tests/QtCore/qprocess_test.py | 16 + tests/QtCore/qrect_test.py | 102 +++++++ tests/QtCore/qresource_test.py | 31 ++ tests/QtCore/qsize_test.py | 26 ++ tests/QtCore/qslot_object_test.py | 47 +++ tests/QtCore/qsrand_test.py | 16 + tests/QtCore/qstate_test.py | 35 +++ tests/QtCore/qstatemachine_test.py | 68 +++++ tests/QtCore/qstring_buffer_protocol_test.py | 20 ++ tests/QtCore/qstring_operator_test.py | 161 ++++++++++ tests/QtCore/qstring_test.py | 192 ++++++++++++ tests/QtCore/qstringlist_test.py | 171 +++++++++++ tests/QtCore/qtext_codec_test.py | 20 ++ tests/QtCore/qtextstream_test.py | 95 ++++++ tests/QtCore/qthread_prod_cons_test.py | 107 +++++++ tests/QtCore/qthread_signal_test.py | 64 ++++ tests/QtCore/qthread_test.py | 76 +++++ tests/QtCore/qtimer_singleshot_test.py | 49 +++ tests/QtCore/qtimer_timeout_test.py | 57 ++++ tests/QtCore/qtnamespace_test.py | 19 ++ tests/QtCore/quoteEnUS.txt | 1 + tests/QtCore/qurl_test.py | 91 ++++++ tests/QtCore/qvariant_pyobject_test.py | 71 +++++ tests/QtCore/qvariant_test.py | 141 +++++++++ tests/QtCore/resources.qrc | 6 + tests/QtCore/resources_mc.py | 39 +++ tests/QtCore/static_method_test.py | 55 ++++ tests/QtCore/static_protected_methods_test.py | 30 ++ tests/QtCore/thread_signals.py | 33 +++ tests/QtCore/translation_test.py | 62 ++++ tests/QtCore/translations/trans_latin.ts | 11 + tests/QtCore/translations/trans_russian.ts | 11 + tests/QtCore/unaryoperator_test.py | 38 +++ tests/QtCore/unicode_test.py | 33 +++ tests/QtDeclarative/CMakeLists.txt | 2 + tests/QtDeclarative/network.qml | 47 +++ tests/QtDeclarative/qdeclarativenetwork_test.py | 35 +++ tests/QtDeclarative/qdeclarativeview_test.py | 31 ++ tests/QtDeclarative/view.qml | 55 ++++ tests/QtGui/CMakeLists.txt | 58 ++++ tests/QtGui/add_action_test.py | 44 +++ tests/QtGui/customproxywidget_test.py | 33 +++ .../QtGui/float_to_int_implicit_conversion_test.py | 32 ++ tests/QtGui/grandparent_method_test.py | 23 ++ tests/QtGui/hashabletype_test.py | 18 ++ tests/QtGui/keep_reference_test.py | 75 +++++ tests/QtGui/missing_symbols_test.py | 29 ++ tests/QtGui/paint_event_test.py | 71 +++++ tests/QtGui/parent_method_test.py | 25 ++ tests/QtGui/python_properties_test.py | 15 + tests/QtGui/qapp_test.py | 17 ++ tests/QtGui/qapplication_exit_segfault_test.py | 17 ++ tests/QtGui/qapplication_singleton_test.py | 12 + tests/QtGui/qbrush_test.py | 24 ++ tests/QtGui/qcolor_test.py | 68 +++++ tests/QtGui/qdatastream_gui_operators_test.py | 35 +++ tests/QtGui/qfontdialog_test.py | 22 ++ tests/QtGui/qfontmetrics_test.py | 189 ++++++++++++ tests/QtGui/qgraphicsitem_isblocked_test.py | 29 ++ tests/QtGui/qgraphicsitem_test.py | 35 +++ tests/QtGui/qgraphicsproxywidget_test.py | 29 ++ tests/QtGui/qgraphicsscene_test.py | 152 ++++++++++ tests/QtGui/qinputdialog_get_test.py | 27 ++ tests/QtGui/qitemselection_test.py | 18 ++ tests/QtGui/qlayout_ref_test.py | 112 +++++++ tests/QtGui/qlayout_test.py | 52 ++++ tests/QtGui/qlcdnumber_test.py | 16 + tests/QtGui/qlistwidgetitem_test.py | 25 ++ tests/QtGui/qmainwindow_test.py | 32 ++ tests/QtGui/qmatrix_test.py | 49 +++ tests/QtGui/qmenu_test.py | 58 ++++ tests/QtGui/qmenuadd_test.py | 25 ++ tests/QtGui/qobject_mi_test.py | 37 +++ tests/QtGui/qpainter_test.py | 49 +++ tests/QtGui/qpen_test.py | 20 ++ tests/QtGui/qpixmap_test.py | 62 ++++ tests/QtGui/qpushbutton_test.py | 30 ++ tests/QtGui/qradialgradient_test.py | 29 ++ tests/QtGui/qregion_test.py | 21 ++ tests/QtGui/qshortcut_test.py | 48 +++ tests/QtGui/qstandarditemmodel_test.py | 26 ++ tests/QtGui/qstring_qkeysequence_test.py | 40 +++ tests/QtGui/qstyle_test.py | 32 ++ tests/QtGui/qtableview_test.py | 17 ++ tests/QtGui/qtabwidget_test.py | 21 ++ tests/QtGui/qtextedit_test.py | 32 ++ tests/QtGui/qtoolbar_test.py | 35 +++ tests/QtGui/qtoolbox_test.py | 31 ++ tests/QtGui/qvariant_test.py | 85 ++++++ tests/QtGui/qwidget_setlayout_test.py | 33 +++ tests/QtGui/qwidget_test.py | 30 ++ tests/QtGui/reference_count_test.py | 71 +++++ tests/QtGui/sample.png | Bin 0 -> 55944 bytes tests/QtGui/standardpixmap_test.py | 15 + tests/QtGui/timed_app_test.py | 14 + tests/QtGui/virtual_protected_inheritance_test.py | 70 +++++ tests/QtGui/virtual_pure_override.py | 48 +++ tests/QtGui/wrong_return_test.py | 23 ++ tests/QtGui/x11_symbols.py | 17 ++ tests/QtHelp/CMakeLists.txt | 1 + tests/QtHelp/help_test.py | 14 + tests/QtMaemo5/CMakeLists.txt | 2 + tests/QtMaemo5/pickselector_test.py | 17 ++ tests/QtMaemo5/qmaemo5import_test.py | 19 ++ tests/QtMultimedia/CMakeLists.txt | 1 + tests/QtMultimedia/audio_test.py | 32 ++ tests/QtNetwork/CMakeLists.txt | 4 + tests/QtNetwork/accessManager_test.py | 23 ++ tests/QtNetwork/http_test.py | 67 +++++ tests/QtNetwork/tcpserver_test.py | 25 ++ tests/QtNetwork/udpsocket_test.py | 54 ++++ tests/QtOpenGL/CMakeLists.txt | 3 + tests/QtOpenGL/qglbuffer_test.py | 49 +++ tests/QtScript/CMakeLists.txt | 3 + tests/QtScript/base_test.py | 4 + tests/QtScript/engine_test.py | 13 + tests/QtScript/test_base.py | 4 + tests/QtScriptTools/CMakeLists.txt | 1 + tests/QtScriptTools/debugger_test.py | 41 +++ tests/QtSql/CMakeLists.txt | 1 + tests/QtSql/qsqldatabaseandqueries_test.py | 56 ++++ tests/QtSvg/CMakeLists.txt | 1 + tests/QtSvg/qsvggenerator_test.py | 34 +++ tests/QtTest/CMakeLists.txt | 2 + tests/QtTest/click_test.py | 28 ++ tests/QtTest/eventfilter_test.py | 47 +++ tests/QtUiTools/CMakeLists.txt | 2 + tests/QtUiTools/test.ui | 48 +++ tests/QtUiTools/ui_test.py | 14 + tests/QtUiTools/uiloader_test.py | 30 ++ tests/QtWebKit/CMakeLists.txt | 2 + tests/QtWebKit/fox.html | 6 + tests/QtWebKit/webpage_test.py | 61 ++++ tests/QtWebKit/webview_test.py | 43 +++ tests/QtXml/CMakeLists.txt | 2 + tests/QtXml/qdomdocument_test.py | 67 +++++ tests/QtXml/qxmlsimplereader_test.py | 34 +++ tests/QtXmlPatterns/CMakeLists.txt | 1 + tests/QtXmlPatterns/import_test.py | 30 ++ tests/phonon/CMakeLists.txt | 2 + tests/qtcore/blocking_signals_test.py | 107 ------- tests/qtcore/buffer_test.py | 13 - tests/qtcore/child_event_test.py | 55 ---- tests/qtcore/deletelater_test.py | 22 -- tests/qtcore/duck_punching_test.py | 56 ---- tests/qtcore/missing_symbols_test.py | 16 - tests/qtcore/qabs_test.py | 20 -- tests/qtcore/qabstracttransition_test.py | 156 ---------- tests/qtcore/qanimationgroup_test.py | 24 -- tests/qtcore/qbitarray_test.py | 119 -------- tests/qtcore/qbytearray_buffer_protocol_test.py | 20 -- .../qbytearray_concatenation_operator_test.py | 46 --- tests/qtcore/qbytearray_operator_iadd_test.py | 73 ----- tests/qtcore/qbytearray_operator_test.py | 82 ----- tests/qtcore/qbytearray_test.py | 98 ------ tests/qtcore/qchar_test.py | 59 ---- tests/qtcore/qcoreapplication_instance_test.py | 20 -- tests/qtcore/qdatastream_test.py | 330 --------------------- tests/qtcore/qdate_test.py | 28 -- tests/qtcore/qenum_test.py | 45 --- tests/qtcore/qevent_test.py | 24 -- tests/qtcore/qfile_test.py | 31 -- tests/qtcore/qfileinfo_test.py | 17 -- tests/qtcore/qflags_test.py | 56 ---- tests/qtcore/qhandle_test.py | 16 - tests/qtcore/qlatin1string_test.py | 21 -- tests/qtcore/qlinef_test.py | 20 -- tests/qtcore/qlocale_test.py | 40 --- tests/qtcore/qmetaobject_test.py | 51 ---- tests/qtcore/qmodelindex_internalpointer_test.py | 50 ---- tests/qtcore/qobject_children_segfault_test.py | 29 -- tests/qtcore/qobject_connect_notify_test.py | 70 ----- tests/qtcore/qobject_event_filter_test.py | 80 ----- tests/qtcore/qobject_inherits_test.py | 43 --- tests/qtcore/qobject_parent_test.py | 234 --------------- tests/qtcore/qobject_property_test.py | 71 ----- tests/qtcore/qobject_protected_methods_test.py | 38 --- tests/qtcore/qobject_test.py | 43 --- tests/qtcore/qobject_timer_event_test.py | 44 --- tests/qtcore/qobject_tr_as_instance_test.py | 55 ---- tests/qtcore/qpoint_test.py | 21 -- tests/qtcore/qprocess_test.py | 16 - tests/qtcore/qrect_test.py | 102 ------- tests/qtcore/qresource_test.py | 31 -- tests/qtcore/qsize_test.py | 26 -- tests/qtcore/qslot_object_test.py | 47 --- tests/qtcore/qsrand_test.py | 16 - tests/qtcore/qstate_test.py | 35 --- tests/qtcore/qstatemachine_test.py | 68 ----- tests/qtcore/qstring_buffer_protocol_test.py | 20 -- tests/qtcore/qstring_operator_test.py | 161 ---------- tests/qtcore/qstring_test.py | 192 ------------ tests/qtcore/qstringlist_test.py | 171 ----------- tests/qtcore/qtext_codec_test.py | 20 -- tests/qtcore/qtextstream_test.py | 95 ------ tests/qtcore/qthread_prod_cons_test.py | 107 ------- tests/qtcore/qthread_signal_test.py | 64 ---- tests/qtcore/qthread_test.py | 76 ----- tests/qtcore/qtimer_singleshot_test.py | 49 --- tests/qtcore/qtimer_timeout_test.py | 57 ---- tests/qtcore/qtnamespace_test.py | 19 -- tests/qtcore/quoteEnUS.txt | 1 - tests/qtcore/qurl_test.py | 91 ------ tests/qtcore/qvariant_pyobject_test.py | 71 ----- tests/qtcore/qvariant_test.py | 141 --------- tests/qtcore/resources.qrc | 6 - tests/qtcore/resources_mc.py | 39 --- tests/qtcore/static_method_test.py | 55 ---- tests/qtcore/static_protected_methods_test.py | 30 -- tests/qtcore/thread_signals.py | 39 --- tests/qtcore/translation_test.py | 62 ---- tests/qtcore/translations/trans_latin.ts | 11 - tests/qtcore/translations/trans_russian.ts | 11 - tests/qtcore/unaryoperator_test.py | 38 --- tests/qtcore/unicode_test.py | 33 --- tests/qtdeclarative/network.qml | 47 --- tests/qtdeclarative/qdeclarativenetwork_test.py | 35 --- tests/qtdeclarative/qdeclarativeview_test.py | 31 -- tests/qtdeclarative/view.qml | 55 ---- tests/qtgui/add_action_test.py | 44 --- tests/qtgui/customproxywidget_test.py | 33 --- .../qtgui/float_to_int_implicit_conversion_test.py | 32 -- tests/qtgui/grandparent_method_test.py | 23 -- tests/qtgui/hashabletype_test.py | 18 -- tests/qtgui/keep_reference_test.py | 75 ----- tests/qtgui/missing_symbols_test.py | 29 -- tests/qtgui/paint_event_test.py | 71 ----- tests/qtgui/parent_method_test.py | 25 -- tests/qtgui/python_properties_test.py | 15 - tests/qtgui/qapp_test.py | 17 -- tests/qtgui/qapplication_exit_segfault_test.py | 17 -- tests/qtgui/qapplication_singleton_test.py | 12 - tests/qtgui/qbrush_test.py | 24 -- tests/qtgui/qcolor_test.py | 68 ----- tests/qtgui/qdatastream_gui_operators_test.py | 35 --- tests/qtgui/qfontdialog_test.py | 22 -- tests/qtgui/qfontmetrics_test.py | 189 ------------ tests/qtgui/qgraphicsitem_isblocked_test.py | 29 -- tests/qtgui/qgraphicsitem_test.py | 35 --- tests/qtgui/qgraphicsproxywidget_test.py | 29 -- tests/qtgui/qgraphicsscene_test.py | 152 ---------- tests/qtgui/qinputdialog_get_test.py | 27 -- tests/qtgui/qitemselection_test.py | 18 -- tests/qtgui/qlabel_pixmap_refcount.py | 46 --- tests/qtgui/qlayout_ref_test.py | 112 ------- tests/qtgui/qlayout_test.py | 52 ---- tests/qtgui/qlcdnumber_test.py | 16 - tests/qtgui/qlistwidgetitem_test.py | 25 -- tests/qtgui/qmainwindow_test.py | 32 -- tests/qtgui/qmatrix_test.py | 49 --- tests/qtgui/qmenu_test.py | 58 ---- tests/qtgui/qmenuadd_test.py | 25 -- tests/qtgui/qobject_mi_test.py | 37 --- tests/qtgui/qpainter_test.py | 49 --- tests/qtgui/qpen_test.py | 20 -- tests/qtgui/qpixmap_test.py | 62 ---- tests/qtgui/qpushbutton_test.py | 30 -- tests/qtgui/qradialgradient_test.py | 29 -- tests/qtgui/qregion_test.py | 21 -- tests/qtgui/qshortcut_test.py | 48 --- tests/qtgui/qstandarditemmodel_test.py | 26 -- tests/qtgui/qstring_qkeysequence_test.py | 40 --- tests/qtgui/qstyle_test.py | 32 -- tests/qtgui/qtableview_test.py | 17 -- tests/qtgui/qtabwidget_test.py | 21 -- tests/qtgui/qtextedit_test.py | 32 -- tests/qtgui/qtoolbar_test.py | 35 --- tests/qtgui/qtoolbox_test.py | 31 -- tests/qtgui/qvariant_test.py | 85 ------ tests/qtgui/qwidget_setlayout_test.py | 33 --- tests/qtgui/qwidget_test.py | 30 -- tests/qtgui/reference_count_test.py | 71 ----- tests/qtgui/sample.png | Bin 55944 -> 0 bytes tests/qtgui/standardpixmap_test.py | 15 - tests/qtgui/timed_app_test.py | 14 - tests/qtgui/virtual_protected_inheritance_test.py | 70 ----- tests/qtgui/virtual_pure_override.py | 48 --- tests/qtgui/wrong_return_test.py | 23 -- tests/qtgui/x11_symbols.py | 17 -- tests/qthelp/help_test.py | 14 - tests/qtmaemo5/pickselector_test.py | 17 -- tests/qtmaemo5/qmaemo5import_test.py | 19 -- tests/qtmultimedia/audio_test.py | 32 -- tests/qtnetwork/accessManager_test.py | 23 -- tests/qtnetwork/http_test.py | 67 ----- tests/qtnetwork/tcpserver_test.py | 25 -- tests/qtnetwork/udpsocket_test.py | 54 ---- tests/qtopengl/qglbuffer_test.py | 49 --- tests/qtscript/base_test.py | 4 - tests/qtscript/engine_test.py | 13 - tests/qtscript/test_base.py | 4 - tests/qtscripttools/debugger_test.py | 41 --- tests/qtsql/qsqldatabaseandqueries_test.py | 56 ---- tests/qtsvg/qsvggenerator_test.py | 34 --- tests/qttest/click_test.py | 28 -- tests/qttest/eventfilter_test.py | 47 --- tests/qtuitools/test.ui | 48 --- tests/qtuitools/ui_test.py | 14 - tests/qtuitools/uiloader_test.py | 30 -- tests/qtwebkit/fox.html | 6 - tests/qtwebkit/webpage_test.py | 61 ---- tests/qtwebkit/webview_test.py | 43 --- tests/qtxml/qdomdocument_test.py | 67 ----- tests/qtxml/qxmlsimplereader_test.py | 34 --- tests/qtxmlpatterns/import_test.py | 30 -- tests/run_test.sh | 8 +- tests/signals/CMakeLists.txt | 32 ++ tests/signals/args_dont_match_test.py | 1 + tests/signals/decorators_test.py | 0 tests/signals/invalid_callback_test.py | 0 tests/signals/lambda_gui_test.py | 0 tests/signals/lambda_test.py | 0 tests/signals/multiple_connections_gui_test.py | 0 tests/signals/multiple_connections_test.py | 0 tests/signals/pysignal_test.py | 0 tests/signals/qobject_destroyed_test.py | 0 tests/signals/qobject_receivers_test.py | 0 tests/signals/segfault_proxyparent_test.py | 0 tests/signals/self_connect_test.py | 0 tests/signals/short_circuit_test.py | 0 tests/signals/signal2signal_connect_test.py | 0 tests/signals/signal_autoconnect_test.py | 0 tests/signals/signal_connectiontype_support.py | 0 tests/signals/signal_emission_gui_test.py | 0 tests/signals/signal_emission_test.py | 0 tests/signals/signal_func_test.py | 0 tests/signals/signal_manager_refcount_test.py | 0 tests/signals/signal_object_test.py | 0 tests/signals/signal_with_primitive_type_test.py | 0 tests/signals/slot_reference_count_test.py | 0 tests/signals/static_metaobject_test.py | 0 tests/signals/upstream_segfault_test.py | 0 375 files changed, 8046 insertions(+), 7884 deletions(-) create mode 100644 tests/QtCore/CMakeLists.txt create mode 100644 tests/QtCore/blocking_signals_test.py create mode 100644 tests/QtCore/buffer_test.py create mode 100644 tests/QtCore/child_event_test.py create mode 100644 tests/QtCore/deletelater_test.py create mode 100644 tests/QtCore/duck_punching_test.py create mode 100644 tests/QtCore/missing_symbols_test.py create mode 100644 tests/QtCore/qabs_test.py create mode 100644 tests/QtCore/qabstracttransition_test.py create mode 100644 tests/QtCore/qanimationgroup_test.py create mode 100755 tests/QtCore/qbitarray_test.py create mode 100755 tests/QtCore/qbytearray_buffer_protocol_test.py create mode 100755 tests/QtCore/qbytearray_concatenation_operator_test.py create mode 100644 tests/QtCore/qbytearray_operator_iadd_test.py create mode 100644 tests/QtCore/qbytearray_operator_test.py create mode 100644 tests/QtCore/qbytearray_test.py create mode 100644 tests/QtCore/qchar_test.py create mode 100755 tests/QtCore/qcoreapplication_instance_test.py create mode 100644 tests/QtCore/qdatastream_test.py create mode 100644 tests/QtCore/qdate_test.py create mode 100644 tests/QtCore/qenum_test.py create mode 100644 tests/QtCore/qevent_test.py create mode 100644 tests/QtCore/qfile_test.py create mode 100644 tests/QtCore/qfileinfo_test.py create mode 100644 tests/QtCore/qflags_test.py create mode 100644 tests/QtCore/qhandle_test.py create mode 100644 tests/QtCore/qlatin1string_test.py create mode 100644 tests/QtCore/qlinef_test.py create mode 100644 tests/QtCore/qlocale_test.py create mode 100644 tests/QtCore/qmetaobject_test.py create mode 100644 tests/QtCore/qmodelindex_internalpointer_test.py create mode 100644 tests/QtCore/qobject_children_segfault_test.py create mode 100644 tests/QtCore/qobject_connect_notify_test.py create mode 100644 tests/QtCore/qobject_event_filter_test.py create mode 100644 tests/QtCore/qobject_inherits_test.py create mode 100644 tests/QtCore/qobject_parent_test.py create mode 100644 tests/QtCore/qobject_property_test.py create mode 100644 tests/QtCore/qobject_protected_methods_test.py create mode 100644 tests/QtCore/qobject_test.py create mode 100644 tests/QtCore/qobject_timer_event_test.py create mode 100644 tests/QtCore/qobject_tr_as_instance_test.py create mode 100644 tests/QtCore/qpoint_test.py create mode 100644 tests/QtCore/qprocess_test.py create mode 100644 tests/QtCore/qrect_test.py create mode 100644 tests/QtCore/qresource_test.py create mode 100644 tests/QtCore/qsize_test.py create mode 100644 tests/QtCore/qslot_object_test.py create mode 100644 tests/QtCore/qsrand_test.py create mode 100644 tests/QtCore/qstate_test.py create mode 100644 tests/QtCore/qstatemachine_test.py create mode 100755 tests/QtCore/qstring_buffer_protocol_test.py create mode 100644 tests/QtCore/qstring_operator_test.py create mode 100644 tests/QtCore/qstring_test.py create mode 100644 tests/QtCore/qstringlist_test.py create mode 100644 tests/QtCore/qtext_codec_test.py create mode 100644 tests/QtCore/qtextstream_test.py create mode 100644 tests/QtCore/qthread_prod_cons_test.py create mode 100755 tests/QtCore/qthread_signal_test.py create mode 100644 tests/QtCore/qthread_test.py create mode 100644 tests/QtCore/qtimer_singleshot_test.py create mode 100644 tests/QtCore/qtimer_timeout_test.py create mode 100644 tests/QtCore/qtnamespace_test.py create mode 100644 tests/QtCore/quoteEnUS.txt create mode 100644 tests/QtCore/qurl_test.py create mode 100644 tests/QtCore/qvariant_pyobject_test.py create mode 100644 tests/QtCore/qvariant_test.py create mode 100644 tests/QtCore/resources.qrc create mode 100644 tests/QtCore/resources_mc.py create mode 100755 tests/QtCore/static_method_test.py create mode 100644 tests/QtCore/static_protected_methods_test.py create mode 100644 tests/QtCore/thread_signals.py create mode 100644 tests/QtCore/translation_test.py create mode 100644 tests/QtCore/translations/trans_latin.ts create mode 100644 tests/QtCore/translations/trans_russian.ts create mode 100755 tests/QtCore/unaryoperator_test.py create mode 100644 tests/QtCore/unicode_test.py create mode 100644 tests/QtDeclarative/CMakeLists.txt create mode 100644 tests/QtDeclarative/network.qml create mode 100644 tests/QtDeclarative/qdeclarativenetwork_test.py create mode 100644 tests/QtDeclarative/qdeclarativeview_test.py create mode 100644 tests/QtDeclarative/view.qml create mode 100644 tests/QtGui/CMakeLists.txt create mode 100644 tests/QtGui/add_action_test.py create mode 100755 tests/QtGui/customproxywidget_test.py create mode 100644 tests/QtGui/float_to_int_implicit_conversion_test.py create mode 100644 tests/QtGui/grandparent_method_test.py create mode 100644 tests/QtGui/hashabletype_test.py create mode 100755 tests/QtGui/keep_reference_test.py create mode 100644 tests/QtGui/missing_symbols_test.py create mode 100644 tests/QtGui/paint_event_test.py create mode 100644 tests/QtGui/parent_method_test.py create mode 100644 tests/QtGui/python_properties_test.py create mode 100644 tests/QtGui/qapp_test.py create mode 100644 tests/QtGui/qapplication_exit_segfault_test.py create mode 100644 tests/QtGui/qapplication_singleton_test.py create mode 100644 tests/QtGui/qbrush_test.py create mode 100644 tests/QtGui/qcolor_test.py create mode 100644 tests/QtGui/qdatastream_gui_operators_test.py create mode 100644 tests/QtGui/qfontdialog_test.py create mode 100644 tests/QtGui/qfontmetrics_test.py create mode 100755 tests/QtGui/qgraphicsitem_isblocked_test.py create mode 100644 tests/QtGui/qgraphicsitem_test.py create mode 100755 tests/QtGui/qgraphicsproxywidget_test.py create mode 100644 tests/QtGui/qgraphicsscene_test.py create mode 100644 tests/QtGui/qinputdialog_get_test.py create mode 100644 tests/QtGui/qitemselection_test.py create mode 100644 tests/QtGui/qlayout_ref_test.py create mode 100644 tests/QtGui/qlayout_test.py create mode 100644 tests/QtGui/qlcdnumber_test.py create mode 100644 tests/QtGui/qlistwidgetitem_test.py create mode 100644 tests/QtGui/qmainwindow_test.py create mode 100644 tests/QtGui/qmatrix_test.py create mode 100644 tests/QtGui/qmenu_test.py create mode 100644 tests/QtGui/qmenuadd_test.py create mode 100644 tests/QtGui/qobject_mi_test.py create mode 100644 tests/QtGui/qpainter_test.py create mode 100644 tests/QtGui/qpen_test.py create mode 100644 tests/QtGui/qpixmap_test.py create mode 100644 tests/QtGui/qpushbutton_test.py create mode 100644 tests/QtGui/qradialgradient_test.py create mode 100644 tests/QtGui/qregion_test.py create mode 100644 tests/QtGui/qshortcut_test.py create mode 100644 tests/QtGui/qstandarditemmodel_test.py create mode 100644 tests/QtGui/qstring_qkeysequence_test.py create mode 100755 tests/QtGui/qstyle_test.py create mode 100644 tests/QtGui/qtableview_test.py create mode 100644 tests/QtGui/qtabwidget_test.py create mode 100644 tests/QtGui/qtextedit_test.py create mode 100644 tests/QtGui/qtoolbar_test.py create mode 100644 tests/QtGui/qtoolbox_test.py create mode 100644 tests/QtGui/qvariant_test.py create mode 100644 tests/QtGui/qwidget_setlayout_test.py create mode 100644 tests/QtGui/qwidget_test.py create mode 100644 tests/QtGui/reference_count_test.py create mode 100644 tests/QtGui/sample.png create mode 100644 tests/QtGui/standardpixmap_test.py create mode 100644 tests/QtGui/timed_app_test.py create mode 100644 tests/QtGui/virtual_protected_inheritance_test.py create mode 100644 tests/QtGui/virtual_pure_override.py create mode 100644 tests/QtGui/wrong_return_test.py create mode 100644 tests/QtGui/x11_symbols.py create mode 100644 tests/QtHelp/CMakeLists.txt create mode 100644 tests/QtHelp/help_test.py create mode 100644 tests/QtMaemo5/CMakeLists.txt create mode 100644 tests/QtMaemo5/pickselector_test.py create mode 100644 tests/QtMaemo5/qmaemo5import_test.py create mode 100644 tests/QtMultimedia/CMakeLists.txt create mode 100644 tests/QtMultimedia/audio_test.py create mode 100644 tests/QtNetwork/CMakeLists.txt create mode 100644 tests/QtNetwork/accessManager_test.py create mode 100644 tests/QtNetwork/http_test.py create mode 100644 tests/QtNetwork/tcpserver_test.py create mode 100644 tests/QtNetwork/udpsocket_test.py create mode 100644 tests/QtOpenGL/CMakeLists.txt create mode 100644 tests/QtOpenGL/qglbuffer_test.py create mode 100644 tests/QtScript/CMakeLists.txt create mode 100644 tests/QtScript/base_test.py create mode 100644 tests/QtScript/engine_test.py create mode 100644 tests/QtScript/test_base.py create mode 100644 tests/QtScriptTools/CMakeLists.txt create mode 100644 tests/QtScriptTools/debugger_test.py create mode 100644 tests/QtSql/CMakeLists.txt create mode 100755 tests/QtSql/qsqldatabaseandqueries_test.py create mode 100644 tests/QtSvg/CMakeLists.txt create mode 100644 tests/QtSvg/qsvggenerator_test.py create mode 100644 tests/QtTest/CMakeLists.txt create mode 100644 tests/QtTest/click_test.py create mode 100644 tests/QtTest/eventfilter_test.py create mode 100644 tests/QtUiTools/CMakeLists.txt create mode 100644 tests/QtUiTools/test.ui create mode 100644 tests/QtUiTools/ui_test.py create mode 100644 tests/QtUiTools/uiloader_test.py create mode 100644 tests/QtWebKit/CMakeLists.txt create mode 100644 tests/QtWebKit/fox.html create mode 100644 tests/QtWebKit/webpage_test.py create mode 100644 tests/QtWebKit/webview_test.py create mode 100644 tests/QtXml/CMakeLists.txt create mode 100644 tests/QtXml/qdomdocument_test.py create mode 100644 tests/QtXml/qxmlsimplereader_test.py create mode 100644 tests/QtXmlPatterns/CMakeLists.txt create mode 100644 tests/QtXmlPatterns/import_test.py create mode 100644 tests/phonon/CMakeLists.txt delete mode 100644 tests/qtcore/blocking_signals_test.py delete mode 100644 tests/qtcore/buffer_test.py delete mode 100644 tests/qtcore/child_event_test.py delete mode 100644 tests/qtcore/deletelater_test.py delete mode 100644 tests/qtcore/duck_punching_test.py delete mode 100644 tests/qtcore/missing_symbols_test.py delete mode 100644 tests/qtcore/qabs_test.py delete mode 100644 tests/qtcore/qabstracttransition_test.py delete mode 100644 tests/qtcore/qanimationgroup_test.py delete mode 100755 tests/qtcore/qbitarray_test.py delete mode 100755 tests/qtcore/qbytearray_buffer_protocol_test.py delete mode 100755 tests/qtcore/qbytearray_concatenation_operator_test.py delete mode 100644 tests/qtcore/qbytearray_operator_iadd_test.py delete mode 100644 tests/qtcore/qbytearray_operator_test.py delete mode 100644 tests/qtcore/qbytearray_test.py delete mode 100644 tests/qtcore/qchar_test.py delete mode 100755 tests/qtcore/qcoreapplication_instance_test.py delete mode 100644 tests/qtcore/qdatastream_test.py delete mode 100644 tests/qtcore/qdate_test.py delete mode 100644 tests/qtcore/qenum_test.py delete mode 100644 tests/qtcore/qevent_test.py delete mode 100644 tests/qtcore/qfile_test.py delete mode 100644 tests/qtcore/qfileinfo_test.py delete mode 100644 tests/qtcore/qflags_test.py delete mode 100644 tests/qtcore/qhandle_test.py delete mode 100644 tests/qtcore/qlatin1string_test.py delete mode 100644 tests/qtcore/qlinef_test.py delete mode 100644 tests/qtcore/qlocale_test.py delete mode 100644 tests/qtcore/qmetaobject_test.py delete mode 100644 tests/qtcore/qmodelindex_internalpointer_test.py delete mode 100644 tests/qtcore/qobject_children_segfault_test.py delete mode 100644 tests/qtcore/qobject_connect_notify_test.py delete mode 100644 tests/qtcore/qobject_event_filter_test.py delete mode 100644 tests/qtcore/qobject_inherits_test.py delete mode 100644 tests/qtcore/qobject_parent_test.py delete mode 100644 tests/qtcore/qobject_property_test.py delete mode 100644 tests/qtcore/qobject_protected_methods_test.py delete mode 100644 tests/qtcore/qobject_test.py delete mode 100644 tests/qtcore/qobject_timer_event_test.py delete mode 100644 tests/qtcore/qobject_tr_as_instance_test.py delete mode 100644 tests/qtcore/qpoint_test.py delete mode 100644 tests/qtcore/qprocess_test.py delete mode 100644 tests/qtcore/qrect_test.py delete mode 100644 tests/qtcore/qresource_test.py delete mode 100644 tests/qtcore/qsize_test.py delete mode 100644 tests/qtcore/qslot_object_test.py delete mode 100644 tests/qtcore/qsrand_test.py delete mode 100644 tests/qtcore/qstate_test.py delete mode 100644 tests/qtcore/qstatemachine_test.py delete mode 100755 tests/qtcore/qstring_buffer_protocol_test.py delete mode 100644 tests/qtcore/qstring_operator_test.py delete mode 100644 tests/qtcore/qstring_test.py delete mode 100644 tests/qtcore/qstringlist_test.py delete mode 100644 tests/qtcore/qtext_codec_test.py delete mode 100644 tests/qtcore/qtextstream_test.py delete mode 100644 tests/qtcore/qthread_prod_cons_test.py delete mode 100755 tests/qtcore/qthread_signal_test.py delete mode 100644 tests/qtcore/qthread_test.py delete mode 100644 tests/qtcore/qtimer_singleshot_test.py delete mode 100644 tests/qtcore/qtimer_timeout_test.py delete mode 100644 tests/qtcore/qtnamespace_test.py delete mode 100644 tests/qtcore/quoteEnUS.txt delete mode 100644 tests/qtcore/qurl_test.py delete mode 100644 tests/qtcore/qvariant_pyobject_test.py delete mode 100644 tests/qtcore/qvariant_test.py delete mode 100644 tests/qtcore/resources.qrc delete mode 100644 tests/qtcore/resources_mc.py delete mode 100755 tests/qtcore/static_method_test.py delete mode 100644 tests/qtcore/static_protected_methods_test.py delete mode 100644 tests/qtcore/thread_signals.py delete mode 100644 tests/qtcore/translation_test.py delete mode 100644 tests/qtcore/translations/trans_latin.ts delete mode 100644 tests/qtcore/translations/trans_russian.ts delete mode 100755 tests/qtcore/unaryoperator_test.py delete mode 100644 tests/qtcore/unicode_test.py delete mode 100644 tests/qtdeclarative/network.qml delete mode 100644 tests/qtdeclarative/qdeclarativenetwork_test.py delete mode 100644 tests/qtdeclarative/qdeclarativeview_test.py delete mode 100644 tests/qtdeclarative/view.qml delete mode 100644 tests/qtgui/add_action_test.py delete mode 100755 tests/qtgui/customproxywidget_test.py delete mode 100644 tests/qtgui/float_to_int_implicit_conversion_test.py delete mode 100644 tests/qtgui/grandparent_method_test.py delete mode 100644 tests/qtgui/hashabletype_test.py delete mode 100755 tests/qtgui/keep_reference_test.py delete mode 100644 tests/qtgui/missing_symbols_test.py delete mode 100644 tests/qtgui/paint_event_test.py delete mode 100644 tests/qtgui/parent_method_test.py delete mode 100644 tests/qtgui/python_properties_test.py delete mode 100644 tests/qtgui/qapp_test.py delete mode 100644 tests/qtgui/qapplication_exit_segfault_test.py delete mode 100644 tests/qtgui/qapplication_singleton_test.py delete mode 100644 tests/qtgui/qbrush_test.py delete mode 100644 tests/qtgui/qcolor_test.py delete mode 100644 tests/qtgui/qdatastream_gui_operators_test.py delete mode 100644 tests/qtgui/qfontdialog_test.py delete mode 100644 tests/qtgui/qfontmetrics_test.py delete mode 100755 tests/qtgui/qgraphicsitem_isblocked_test.py delete mode 100644 tests/qtgui/qgraphicsitem_test.py delete mode 100755 tests/qtgui/qgraphicsproxywidget_test.py delete mode 100644 tests/qtgui/qgraphicsscene_test.py delete mode 100644 tests/qtgui/qinputdialog_get_test.py delete mode 100644 tests/qtgui/qitemselection_test.py delete mode 100644 tests/qtgui/qlabel_pixmap_refcount.py delete mode 100644 tests/qtgui/qlayout_ref_test.py delete mode 100644 tests/qtgui/qlayout_test.py delete mode 100644 tests/qtgui/qlcdnumber_test.py delete mode 100644 tests/qtgui/qlistwidgetitem_test.py delete mode 100644 tests/qtgui/qmainwindow_test.py delete mode 100644 tests/qtgui/qmatrix_test.py delete mode 100644 tests/qtgui/qmenu_test.py delete mode 100644 tests/qtgui/qmenuadd_test.py delete mode 100644 tests/qtgui/qobject_mi_test.py delete mode 100644 tests/qtgui/qpainter_test.py delete mode 100644 tests/qtgui/qpen_test.py delete mode 100644 tests/qtgui/qpixmap_test.py delete mode 100644 tests/qtgui/qpushbutton_test.py delete mode 100644 tests/qtgui/qradialgradient_test.py delete mode 100644 tests/qtgui/qregion_test.py delete mode 100644 tests/qtgui/qshortcut_test.py delete mode 100644 tests/qtgui/qstandarditemmodel_test.py delete mode 100644 tests/qtgui/qstring_qkeysequence_test.py delete mode 100755 tests/qtgui/qstyle_test.py delete mode 100644 tests/qtgui/qtableview_test.py delete mode 100644 tests/qtgui/qtabwidget_test.py delete mode 100644 tests/qtgui/qtextedit_test.py delete mode 100644 tests/qtgui/qtoolbar_test.py delete mode 100644 tests/qtgui/qtoolbox_test.py delete mode 100644 tests/qtgui/qvariant_test.py delete mode 100644 tests/qtgui/qwidget_setlayout_test.py delete mode 100644 tests/qtgui/qwidget_test.py delete mode 100644 tests/qtgui/reference_count_test.py delete mode 100644 tests/qtgui/sample.png delete mode 100644 tests/qtgui/standardpixmap_test.py delete mode 100644 tests/qtgui/timed_app_test.py delete mode 100644 tests/qtgui/virtual_protected_inheritance_test.py delete mode 100644 tests/qtgui/virtual_pure_override.py delete mode 100644 tests/qtgui/wrong_return_test.py delete mode 100644 tests/qtgui/x11_symbols.py delete mode 100644 tests/qthelp/help_test.py delete mode 100644 tests/qtmaemo5/pickselector_test.py delete mode 100644 tests/qtmaemo5/qmaemo5import_test.py delete mode 100644 tests/qtmultimedia/audio_test.py delete mode 100644 tests/qtnetwork/accessManager_test.py delete mode 100644 tests/qtnetwork/http_test.py delete mode 100644 tests/qtnetwork/tcpserver_test.py delete mode 100644 tests/qtnetwork/udpsocket_test.py delete mode 100644 tests/qtopengl/qglbuffer_test.py delete mode 100644 tests/qtscript/base_test.py delete mode 100644 tests/qtscript/engine_test.py delete mode 100644 tests/qtscript/test_base.py delete mode 100644 tests/qtscripttools/debugger_test.py delete mode 100755 tests/qtsql/qsqldatabaseandqueries_test.py delete mode 100644 tests/qtsvg/qsvggenerator_test.py delete mode 100644 tests/qttest/click_test.py delete mode 100644 tests/qttest/eventfilter_test.py delete mode 100644 tests/qtuitools/test.ui delete mode 100644 tests/qtuitools/ui_test.py delete mode 100644 tests/qtuitools/uiloader_test.py delete mode 100644 tests/qtwebkit/fox.html delete mode 100644 tests/qtwebkit/webpage_test.py delete mode 100644 tests/qtwebkit/webview_test.py delete mode 100644 tests/qtxml/qdomdocument_test.py delete mode 100644 tests/qtxml/qxmlsimplereader_test.py delete mode 100644 tests/qtxmlpatterns/import_test.py create mode 100644 tests/signals/CMakeLists.txt mode change 100644 => 100755 tests/signals/args_dont_match_test.py mode change 100644 => 100755 tests/signals/decorators_test.py mode change 100644 => 100755 tests/signals/invalid_callback_test.py mode change 100644 => 100755 tests/signals/lambda_gui_test.py mode change 100644 => 100755 tests/signals/lambda_test.py mode change 100644 => 100755 tests/signals/multiple_connections_gui_test.py mode change 100644 => 100755 tests/signals/multiple_connections_test.py mode change 100644 => 100755 tests/signals/pysignal_test.py mode change 100644 => 100755 tests/signals/qobject_destroyed_test.py mode change 100644 => 100755 tests/signals/qobject_receivers_test.py mode change 100644 => 100755 tests/signals/segfault_proxyparent_test.py mode change 100644 => 100755 tests/signals/self_connect_test.py mode change 100644 => 100755 tests/signals/short_circuit_test.py mode change 100644 => 100755 tests/signals/signal2signal_connect_test.py mode change 100644 => 100755 tests/signals/signal_autoconnect_test.py mode change 100644 => 100755 tests/signals/signal_connectiontype_support.py mode change 100644 => 100755 tests/signals/signal_emission_gui_test.py mode change 100644 => 100755 tests/signals/signal_emission_test.py mode change 100644 => 100755 tests/signals/signal_func_test.py mode change 100644 => 100755 tests/signals/signal_manager_refcount_test.py mode change 100644 => 100755 tests/signals/signal_object_test.py mode change 100644 => 100755 tests/signals/signal_with_primitive_type_test.py mode change 100644 => 100755 tests/signals/slot_reference_count_test.py mode change 100644 => 100755 tests/signals/static_metaobject_test.py mode change 100644 => 100755 tests/signals/upstream_segfault_test.py (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ada5b7ae3..d87414fda 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,22 +1,44 @@ +set(PYSIDE_TIMEOUT 5) -file(GLOB TEST_FILES */*_test.py) +macro(TEST_QT_MODULE var name) + if(NOT DISABLE_${name} AND ${var}) + add_subdirectory(${name}) + endif() +endmacro(TEST_QT_MODULE) -set(test_blacklist ) +macro(PYSIDE_TEST) + set(TEST_NAME ${ARGV0}) + if (${ARGC} EQUAL 1) + set(EXPECT_TO_FAIL 0) + elseif(${ARGC} EQUAL 2) + set(EXPECT_TO_FAIL ${ARGV1}) + else() + message(WARNING "Ivalid call of macro PYSIDE_TEST") + endif() + set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}") + add_test(${TEST_NAME} ${TEST_CMD}) + set_tests_properties(${TEST_NAME} PROPERTIES + TIMEOUT ${PYSIDE_TIMEOUT} + WILL_FAIL ${EXPECT_TO_FAIL}) +endmacro(PYSIDE_TEST) -foreach(test_file ${TEST_FILES}) - string(REGEX MATCH "/([^/]+)//?([^/]+)_test.py" test_name ${test_file} ) - list(FIND test_blacklist ${CMAKE_MATCH_1}_${CMAKE_MATCH_2} expect_fail) - add_test(${CMAKE_MATCH_1}_${CMAKE_MATCH_2} sh - ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - "${pysidebase_BINARY_DIR}:${libpyside_BINARY_DIR}" - "${CMAKE_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}/util" - ${PYTHON_EXECUTABLE} - ${test_file}) - set_tests_properties(${CMAKE_MATCH_1}_${CMAKE_MATCH_2} PROPERTIES TIMEOUT 5) - if (${expect_fail} GREATER -1) - set_tests_properties(${CMAKE_MATCH_1}_${CMAKE_MATCH_2} PROPERTIES WILL_FAIL TRUE) - endif(${expect_fail} GREATER -1) -# Should set python path here -# Looks like it's fixed in 2.8: -# http://www.vtk.org/Bug/print_bug_page.php?bug_id=7885 -endforeach(test_file ${TEST_FILES}) + +add_subdirectory(signals) +TEST_QT_MODULE(QT_QTCORE_FOUND QtCore) +TEST_QT_MODULE(QT_QTGUI_FOUND QtGui) +TEST_QT_MODULE(QT_QTNETWORK_FOUND QtNetwork) +TEST_QT_MODULE(QT_QTWEBKIT_FOUND QtWebKit) +TEST_QT_MODULE(QT_QTSVG_FOUND QtSvg) +TEST_QT_MODULE(QT_QTXML_FOUND QtXml) +TEST_QT_MODULE(QT_QTTEST_FOUND QtTest) +TEST_QT_MODULE(QT_QTOPENGL_FOUND QtOpenGL) +TEST_QT_MODULE(QT_QTSQL_FOUND QtSql) +TEST_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) +TEST_QT_MODULE(QT_QTHELP_FOUND QtHelp) +TEST_QT_MODULE(QT_QTXMLPATTERNS_FOUND QtXmlPatterns) +TEST_QT_MODULE(QT_QTMAEMO5_FOUND QtMaemo5) +TEST_QT_MODULE(QT_QTSCRIPT_FOUND QtScript) +TEST_QT_MODULE(QT_QTSCRIPTTOOLS_FOUND QtScriptTools) +TEST_QT_MODULE(QT_QTMULTIMEDIA_FOUND QtMultimedia) +TEST_QT_MODULE(QT_PHONON_FOUND phonon) +TEST_QT_MODULE(QT_QTDECLARATIVE_FOUND QtDeclarative) diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt new file mode 100644 index 000000000..536d40861 --- /dev/null +++ b/tests/QtCore/CMakeLists.txt @@ -0,0 +1,71 @@ +PYSIDE_TEST(blocking_signals_test.py) +PYSIDE_TEST(buffer_test.py) +PYSIDE_TEST(child_event_test.py) +PYSIDE_TEST(deletelater_test.py) +PYSIDE_TEST(duck_punching_test.py) +PYSIDE_TEST(missing_symbols_test.py) +PYSIDE_TEST(qabs_test.py) +PYSIDE_TEST(qabstracttransition_test.py) +PYSIDE_TEST(qanimationgroup_test.py) +PYSIDE_TEST(qbitarray_test.py) +PYSIDE_TEST(qbytearray_buffer_protocol_test.py) +PYSIDE_TEST(qbytearray_concatenation_operator_test.py) +PYSIDE_TEST(qbytearray_operator_iadd_test.py) +PYSIDE_TEST(qbytearray_operator_test.py) +PYSIDE_TEST(qbytearray_test.py) +PYSIDE_TEST(qchar_test.py) +PYSIDE_TEST(qcoreapplication_instance_test.py) +PYSIDE_TEST(qdatastream_test.py) +PYSIDE_TEST(qdate_test.py) +PYSIDE_TEST(qenum_test.py) +PYSIDE_TEST(qevent_test.py) +PYSIDE_TEST(qfileinfo_test.py) +PYSIDE_TEST(qfile_test.py) +PYSIDE_TEST(qflags_test.py) +PYSIDE_TEST(qhandle_test.py) +PYSIDE_TEST(qlatin1string_test.py) +PYSIDE_TEST(qlinef_test.py) +PYSIDE_TEST(qlocale_test.py) +PYSIDE_TEST(qmetaobject_test.py) +PYSIDE_TEST(qmodelindex_internalpointer_test.py) +PYSIDE_TEST(qobject_children_segfault_test.py) +PYSIDE_TEST(qobject_connect_notify_test.py) +PYSIDE_TEST(qobject_event_filter_test.py) +PYSIDE_TEST(qobject_inherits_test.py) +PYSIDE_TEST(qobject_parent_test.py) +PYSIDE_TEST(qobject_property_test.py) +PYSIDE_TEST(qobject_protected_methods_test.py) +PYSIDE_TEST(qobject_test.py) +PYSIDE_TEST(qobject_timer_event_test.py) +PYSIDE_TEST(qobject_tr_as_instance_test.py) +PYSIDE_TEST(qpoint_test.py) +PYSIDE_TEST(qprocess_test.py) +PYSIDE_TEST(qrect_test.py) +PYSIDE_TEST(qresource_test.py) +PYSIDE_TEST(qsize_test.py) +PYSIDE_TEST(qslot_object_test.py) +PYSIDE_TEST(qsrand_test.py) +PYSIDE_TEST(qstatemachine_test.py) +PYSIDE_TEST(qstate_test.py) +PYSIDE_TEST(qstring_buffer_protocol_test.py) +PYSIDE_TEST(qstringlist_test.py) +PYSIDE_TEST(qstring_operator_test.py) +PYSIDE_TEST(qstring_test.py) +PYSIDE_TEST(qtext_codec_test.py) +PYSIDE_TEST(qtextstream_test.py) +PYSIDE_TEST(qthread_prod_cons_test.py) +PYSIDE_TEST(qthread_signal_test.py) +PYSIDE_TEST(qthread_test.py) +PYSIDE_TEST(qtimer_singleshot_test.py) +PYSIDE_TEST(qtimer_timeout_test.py) +PYSIDE_TEST(qtnamespace_test.py) +PYSIDE_TEST(qurl_test.py) +PYSIDE_TEST(qvariant_pyobject_test.py) +PYSIDE_TEST(qvariant_test.py) +PYSIDE_TEST(resources_mc.py) +PYSIDE_TEST(static_method_test.py) +PYSIDE_TEST(static_protected_methods_test.py) +PYSIDE_TEST(thread_signals.py) +PYSIDE_TEST(translation_test.py) +PYSIDE_TEST(unaryoperator_test.py) +PYSIDE_TEST(unicode_test.py) diff --git a/tests/QtCore/blocking_signals_test.py b/tests/QtCore/blocking_signals_test.py new file mode 100644 index 000000000..96582f6cc --- /dev/null +++ b/tests/QtCore/blocking_signals_test.py @@ -0,0 +1,107 @@ + +''' Test case for QObject.signalsBlocked() and blockSignal()''' + +import unittest +import os +from tempfile import mkstemp + +from PySide.QtCore import QObject, SIGNAL, QFile + +class TestSignalsBlockedBasic(unittest.TestCase): + '''Basic test case for signalsBlocked''' + + def testBasic(self): + '''QObject.signalsBlocked() and blockSignals() + The signals aren't blocked by default. + blockSignals returns the previous value''' + obj = QObject() + self.assert_(not obj.signalsBlocked()) + self.assert_(not obj.blockSignals(True)) + self.assert_(obj.signalsBlocked()) + self.assert_(obj.blockSignals(False)) + +class TestSignalsBlocked(unittest.TestCase): + '''Test case to check if the signals are really blocked''' + + def setUp(self): + #Set up the basic resources needed + self.obj = QObject() + self.args = tuple() + self.called = False + + def tearDown(self): + #Delete used resources + del self.obj + del self.args + + def callback(self, *args): + #Default callback + if args == self.args: + self.called = True + else: + raise TypeError("Invalid arguments") + + def testShortCircuitSignals(self): + #Blocking of Python short-circuit signals + QObject.connect(self.obj, SIGNAL('mysignal'), self.callback) + + self.obj.emit(SIGNAL('mysignal')) + self.assert_(self.called) + + self.called = False + self.obj.blockSignals(True) + self.obj.emit(SIGNAL('mysignal')) + self.assert_(not self.called) + + def testPythonSignals(self): + #Blocking of Python typed signals + QObject.connect(self.obj, SIGNAL('mysignal(int,int)'), self.callback) + self.args = (1, 3) + + self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) + self.assert_(self.called) + + self.called = False + self.obj.blockSignals(True) + self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) + self.assert_(not self.called) + +class TestQFileSignalBlocking(unittest.TestCase): + '''Test case for blocking the signal QIODevice.aboutToClose()''' + + def setUp(self): + #Set up the needed resources - A temp file and a QFile + self.called = False + handle, self.filename = mkstemp() + os.close(handle) + + self.qfile = QFile(self.filename) + + def tearDown(self): + #Release acquired resources + os.remove(self.filename) + del self.qfile + + def callback(self): + #Default callback + self.called = True + + def testAboutToCloseBlocking(self): + #QIODevice.aboutToClose() blocking + + QObject.connect(self.qfile, SIGNAL('aboutToClose()'), self.callback) + + self.assert_(self.qfile.open(QFile.ReadOnly)) + self.qfile.close() + self.assert_(self.called) + + self.called = False + self.qfile.blockSignals(True) + + self.assert_(self.qfile.open(QFile.ReadOnly)) + self.qfile.close() + self.assert_(not self.called) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/buffer_test.py b/tests/QtCore/buffer_test.py new file mode 100644 index 000000000..2917232a1 --- /dev/null +++ b/tests/QtCore/buffer_test.py @@ -0,0 +1,13 @@ +#!/usr/bin/python + +import unittest +from PySide.QtCore import QString + +class BufferTest(unittest.TestCase): + def testQByteArray(self): + data = buffer("PySide") + str = QString(data) + self.assertEqual(data, str) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/child_event_test.py b/tests/QtCore/child_event_test.py new file mode 100644 index 000000000..ccc27c848 --- /dev/null +++ b/tests/QtCore/child_event_test.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +'''Test case for QObject.childEvent and QTimer.childEvent overloading''' + +import unittest +from time import sleep +from PySide.QtCore import QObject, QTimer, QCoreApplication + +from helper import UsesQCoreApplication + +class ExtQObject(QObject): + def __init__(self): + QObject.__init__(self) + self.child_event_received = False + + def childEvent(self, event): + QObject.childEvent(self, event) + self.child_event_received = True + +class ExtQTimer(QTimer): + def __init__(self): + QTimer.__init__(self) + self.child_event_received = False + + def childEvent(self, event): + QTimer.childEvent(self, event) + self.child_event_received = True + + +class TestChildEvent(UsesQCoreApplication): + '''Test case for QObject::childEvent and QTimer::childEvent''' + + def setUp(self): + UsesQCoreApplication.setUp(self) + + def tearDown(self): + UsesQCoreApplication.tearDown(self) + + def testQObject(self): + parent = ExtQObject() + child = QObject() + child.setParent(parent) + print "parent seted" + #self.assert_(parent.child_event_received) + + """ + def testQTimer(self): + parent = ExtQTimer() + child = QObject() + child.setParent(parent) + self.assert_(parent.child_event_received) + """ + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/deletelater_test.py b/tests/QtCore/deletelater_test.py new file mode 100644 index 000000000..3b2f7d9e3 --- /dev/null +++ b/tests/QtCore/deletelater_test.py @@ -0,0 +1,22 @@ +#!/usr/bin/python + +'''Test cases for QTimer.singleShot''' + +import unittest + +from PySide.QtCore import QObject, QTimer, QCoreApplication, SIGNAL +from helper import UsesQCoreApplication + +class TestDeleteLater(UsesQCoreApplication): + '''Test case for function DeleteLater''' + + def testCase(self): + o = QObject() + o.deleteLater() + del o + QTimer.singleShot(100, self.app.quit) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/duck_punching_test.py b/tests/QtCore/duck_punching_test.py new file mode 100644 index 000000000..e20c0c1b1 --- /dev/null +++ b/tests/QtCore/duck_punching_test.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +'''Test case for duck punching new implementations of C++ virtual methods into object instances.''' + +import unittest +import types +from PySide.QtCore import QObject, QEvent +from helper import UsesQCoreApplication + +class Duck(QObject): + def __init__(self): + QObject.__init__(self) + def childEvent(self, event): + QObject.childEvent(self, event) + +class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication): + '''Test case for duck punching new implementations of C++ virtual methods into object instances.''' + + def setUp(self): + #Acquire resources + self.duck_childEvent_called = False + UsesQCoreApplication.setUp(self) + + def tearDown(self): + #Release resources + del self.duck_childEvent_called + UsesQCoreApplication.tearDown(self) + + + def testChildEventMonkeyPatch(self): + #Test if the new childEvent injected on QObject instance is called from C++ + parent = QObject() + def childEvent(obj, event): + self.duck_childEvent_called = True + QObject.childEvent(obj, event) + parent.childEvent = types.MethodType(childEvent, parent, QObject) + child = QObject() + child.setParent(parent) + self.assert_(self.duck_childEvent_called) + + def testChildEventMonkeyPatchWithInheritance(self): + #Test if the new childEvent injected on a QObject's extension class instance is called from C++ + parent = Duck() + def childEvent(obj, event): + QObject.childEvent(obj, event) + self.duck_childEvent_called = True + child = QObject() + child.setParent(parent) + parent.childEvent = types.MethodType(childEvent, parent, QObject) + child = QObject() + child.setParent(parent) + self.assert_(self.duck_childEvent_called) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/missing_symbols_test.py b/tests/QtCore/missing_symbols_test.py new file mode 100644 index 000000000..f535c53d3 --- /dev/null +++ b/tests/QtCore/missing_symbols_test.py @@ -0,0 +1,16 @@ + +'''(Very) Simple test case for missing names from QtCore''' + +import unittest +from PySide import QtCore + +class MissingClasses(unittest.TestCase): + + def testQSettings(self): # Bug 232 + getattr(QtCore, 'QSettings') + + def testQtTrNoop(self): # Bug 220 + getattr(QtCore, 'QT_TR_NOOP') + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qabs_test.py b/tests/QtCore/qabs_test.py new file mode 100644 index 000000000..1727ae6d5 --- /dev/null +++ b/tests/QtCore/qabs_test.py @@ -0,0 +1,20 @@ + +import unittest + +from PySide import QtCore + + +class QAbsTest(unittest.TestCase): + '''Tests for QtCore.qAbs''' + + def testBasic(self): + def check(x): + self.assertEqual(QtCore.qAbs(x), abs(x)) + + check(0) + check(-10) + check(10) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qabstracttransition_test.py b/tests/QtCore/qabstracttransition_test.py new file mode 100644 index 000000000..510b8ef64 --- /dev/null +++ b/tests/QtCore/qabstracttransition_test.py @@ -0,0 +1,156 @@ +#!/usr/bin/python +import unittest +from sys import getrefcount +from PySide.QtCore import QObject, SIGNAL, QCoreApplication, QTimer, QVariant +from PySide.QtCore import QState, QFinalState, QStateMachine, QParallelAnimationGroup, QEventTransition + +def addStates(transition): + sx = QState() + sy = QState() + transition.setTargetStates([sx, sy]) + +def addAnimation(transition): + animation = QParallelAnimationGroup() + transition.addAnimation(animation) + +class QAbstractTransitionTest(unittest.TestCase): + + def testBasic(self): + app = QCoreApplication([]) + + o = QObject() + o.setProperty("text", QVariant("INdT")) + + machine = QStateMachine() + s1 = QState() + s1.assignProperty(o, "text", QVariant("Rocks")) + + s2 = QFinalState() + t = s1.addTransition(o, SIGNAL("change()"), s2) + + self.assertEqual(t.targetStates(), [s2]) + + addStates(t) + self.assertEqual(len(t.targetStates()), 2) + + animation = QParallelAnimationGroup() + t.addAnimation(animation) + + self.assertEqual(t.animations(), [animation]) + + addAnimation(t) + self.assertEqual(t.animations()[0].parent(), None) + + machine.addState(s1) + machine.addState(s2) + machine.setInitialState(s1) + machine.start() + + QTimer.singleShot(100, app.quit) + app.exec_() + + def testRefCountOfTargetState(self): + transition = QEventTransition() + state1 = QState() + refcount1 = getrefcount(state1) + + transition.setTargetState(state1) + + self.assertEqual(transition.targetState(), state1) + self.assertEqual(getrefcount(transition.targetState()), refcount1 + 1) + + state2 = QState() + refcount2 = getrefcount(state2) + + transition.setTargetState(state2) + + self.assertEqual(transition.targetState(), state2) + self.assertEqual(getrefcount(transition.targetState()), refcount2 + 1) + self.assertEqual(getrefcount(state1), refcount1) + + del transition + + self.assertEqual(getrefcount(state2), refcount2) + + def testRefCountOfTargetStates(self): + transition = QEventTransition() + state1 = QState() + state2 = QState() + states = [state1, state2] + refcount1 = getrefcount(state1) + refcount2 = getrefcount(state2) + + transition.setTargetStates(states) + + self.assertEqual(transition.targetStates(), states) + self.assertEqual(transition.targetState(), state1) + self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1) + self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1) + + del states + del transition + + self.assertEqual(getrefcount(state1), refcount1) + self.assertEqual(getrefcount(state2), refcount2) + + def testRefCountOfTargetStatesAfterSingleTargetState(self): + transition = QEventTransition() + state0 = QState() + refcount0 = getrefcount(state0) + + transition.setTargetState(state0) + + self.assertEqual(transition.targetState(), state0) + self.assertEqual(getrefcount(transition.targetState()), refcount0 + 1) + + state1 = QState() + state2 = QState() + states = [state1, state2] + refcount1 = getrefcount(state1) + refcount2 = getrefcount(state2) + + transition.setTargetStates(states) + + self.assertEqual(getrefcount(state0), refcount0) + self.assertEqual(transition.targetStates(), states) + self.assertEqual(transition.targetState(), state1) + self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1) + self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1) + + del states + del transition + + self.assertEqual(getrefcount(state1), refcount1) + self.assertEqual(getrefcount(state2), refcount2) + + def testRefCountOfTargetStatesBeforeSingleTargetState(self): + transition = QEventTransition() + state1 = QState() + state2 = QState() + states = [state1, state2] + refcount1 = getrefcount(state1) + refcount2 = getrefcount(state2) + + transition.setTargetStates(states) + + self.assertEqual(transition.targetStates(), states) + self.assertEqual(transition.targetState(), state1) + self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1) + self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1) + + state3 = QState() + refcount3 = getrefcount(state3) + + transition.setTargetState(state3) + + self.assertEqual(transition.targetState(), state3) + self.assertEqual(getrefcount(transition.targetState()), refcount3 + 1) + + del states + + self.assertEqual(getrefcount(state1), refcount1) + self.assertEqual(getrefcount(state2), refcount2) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qanimationgroup_test.py b/tests/QtCore/qanimationgroup_test.py new file mode 100644 index 000000000..05bd81e10 --- /dev/null +++ b/tests/QtCore/qanimationgroup_test.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +import unittest +from PySide.QtCore import QObject, QState, QFinalState, SIGNAL, QCoreApplication, QTimer, QStateMachine, QSignalTransition, QVariant, QParallelAnimationGroup, QSequentialAnimationGroup, QAnimationGroup + +class QAnimationGroupTest(unittest.TestCase): + + def testBasic(self): + app = QCoreApplication([]) + + panim = QParallelAnimationGroup() + sanim = QSequentialAnimationGroup() + panim.addAnimation(sanim) + + self.assertEqual(sanim.parent(), panim) + + panim.clear() + + self.assertRaises(RuntimeError, lambda :sanim.parent()) + + QTimer.singleShot(100, app.quit) + app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qbitarray_test.py b/tests/QtCore/qbitarray_test.py new file mode 100755 index 000000000..0ae6e1d2f --- /dev/null +++ b/tests/QtCore/qbitarray_test.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +'''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators''' + +import unittest + +from PySide.QtCore import QBitArray + +def bool_list_from_qbitarray(qbitarray): + '''This function is used instead of a list comprehension because + the QBitArray is being tested also to check if it is providing + the iterable protocol. + ''' + qbitarray_values = [] + for i in range(qbitarray.size()): + qbitarray_values.append(qbitarray.at(i)) + return qbitarray_values + +class QBitArrayIsIterableTest(unittest.TestCase): + '''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators''' + + def setUp(self): + #Acquire resources + self.qbitarray = QBitArray(3) + self.qbitarray_values = [True, False, False] + # WARNING: do not pythonify the following loop + for i in range(len(self.qbitarray_values)): + self.qbitarray.setBit(i, self.qbitarray_values[i]) + + self.inverted_qbitarray_values = [not bit for bit in self.qbitarray_values] + + self.other_qbitarray = QBitArray(3) + self.other_qbitarray_values = [True, True, False] + # WARNING: do not pythonify the following loop + for i in range(len(self.other_qbitarray_values)): + self.other_qbitarray.setBit(i, self.other_qbitarray_values[i]) + + def tearDown(self): + #Release resources + del self.qbitarray + del self.other_qbitarray + del self.qbitarray_values + del self.other_qbitarray_values + del self.inverted_qbitarray_values + + def testQBitArrayIsIterable(self): + #Tests if QBitArray class is iterable + qbitarray_is_iterable = True + try: + bitarray = [bit for bit in self.qbitarray] + except: + qbitarray_is_iterable = False + self.assertTrue(qbitarray_is_iterable) + + def testQBitArrayInvertOperator(self): + #Tests QBitArray '~' (__invert__) operator + inverted_qbitarray = ~self.qbitarray + # WARNING: do not pythonify the following loop, the + # iterability of QBitArray class is tested in another place + inverted_qbitarray_values = bool_list_from_qbitarray(inverted_qbitarray) + self.assertEqual(self.inverted_qbitarray_values, inverted_qbitarray_values) + + def testQBitArrayOrBitwiseOperator(self): + #Tests QBitArray '|' (or) operator + has_or_bitwise_operator = True + ored_qbitarray, ored_bool_list = None, None + try: + ored_qbitarray = self.qbitarray | self.other_qbitarray + ored_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)] + except: + has_or_bitwise_operator = False + self.assertTrue(has_or_bitwise_operator) + self.assertEqual(bool_list_from_qbitarray(ored_qbitarray), ored_bool_list) + + def testQBitArrayAndBitwiseOperator(self): + #Tests QBitArray '&' (and) operator + has_and_bitwise_operator = True + anded_qbitarray, anded_bool_list = None, None + try: + anded_qbitarray = self.qbitarray | self.other_qbitarray + anded_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)] + except: + has_and_bitwise_operator = False + self.assertTrue(has_and_bitwise_operator) + self.assertEqual(bool_list_from_qbitarray(anded_qbitarray), anded_bool_list) + + def testQBitArrayXorBitwiseOperator(self): + #Tests QBitArray '^' (xor) operator + has_xor_bitwise_operator = True + xored_qbitarray, xored_bool_list = None, None + try: + xored_qbitarray = self.qbitarray | self.other_qbitarray + xored_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)] + except: + has_xor_bitwise_operator = False + self.assertTrue(has_xor_bitwise_operator) + self.assertEqual(bool_list_from_qbitarray(xored_qbitarray), xored_bool_list) + + +class QBitArrayGetItemTest(unittest.TestCase): + '''Test case for []/__getitem__ operator''' + + def create_bitarray(self, values): + '''helper function to create a bit array''' + obj = QBitArray(len(values)) + for i, value in enumerate(values): + obj.setBit(i, value) + return obj + + def testSequenceProtocol(self): + '''QBitArray sequence protocol''' + data = [True, False, True] + obj = self.create_bitarray(data) + for reference, value in zip(data, obj): + self.assertEqual(reference, value) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qbytearray_buffer_protocol_test.py b/tests/QtCore/qbytearray_buffer_protocol_test.py new file mode 100755 index 000000000..117e50b93 --- /dev/null +++ b/tests/QtCore/qbytearray_buffer_protocol_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Tests QByteArray implementation of Python buffer protocol''' + +import unittest + +from os.path import isdir +from PySide.QtCore import QByteArray + +class QByteArrayBufferProtocolTest(unittest.TestCase): + '''Tests QByteArray implementation of Python buffer protocol''' + + def testQByteArrayBufferProtocol(self): + #Tests QByteArray implementation of Python buffer protocol using the os.path.isdir + #function which an unicode object or other object implementing the Python buffer protocol + isdir(QByteArray('/tmp')) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qbytearray_concatenation_operator_test.py b/tests/QtCore/qbytearray_concatenation_operator_test.py new file mode 100755 index 000000000..b9a01ff63 --- /dev/null +++ b/tests/QtCore/qbytearray_concatenation_operator_test.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QByteArray concatenation with '+' operator''' + +import unittest + +from PySide.QtCore import QByteArray + +class QByteArrayConcatenationOperatorTest(unittest.TestCase): + '''Test cases for QByteArray concatenation with '+' operator''' + + def testConcatQByteArrayAndPythonString(self): + #Test concatenation of a QByteArray with a Python string, in this order + qba = QByteArray('foo') + result = qba + 'bar' + self.assert_(isinstance(result, QByteArray)) + self.assertEqual(result, 'foobar') + # NOTICE: the standard behavior of PyQt is to return a QString object + # for this case. As this is a minor issue the assertion will be left commented. + #self.assertEqual(result.__class__.__name__, 'QString') + + def testConcatPythonStringAndQByteArray(self): + #Test concatenation of a Python string with a QByteArray, in this order + concat_python_string_add_qbytearray_worked = True + qba = QByteArray('foo') + result = 'bar' + qba + self.assert_(isinstance(result, QByteArray)) + self.assertEqual(result, 'barfoo') + + # NOTICE: Does not makes sense concat a unicode string with a QByteArray, because the + # user does not know nothing about the internal representation of the unicode string. + #def testConcatPythonUnicodeAndQByteArray(self): + ##Test concatenation of a Python unicode object with a QByteArray, in this order + #concat_python_unicode_add_qbytearray_worked = True + #qba = QByteArray('foo') + #result = None + #try: + #result = u'ümlaut' + qba + #except: + #concat_python_unicode_add_qbytearray_worked = False + #self.assertTrue(concat_python_unicode_add_qbytearray_worked) + #self.assertEqual(result.__class__.__name__, 'unicode') + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qbytearray_operator_iadd_test.py b/tests/QtCore/qbytearray_operator_iadd_test.py new file mode 100644 index 000000000..168f22de9 --- /dev/null +++ b/tests/QtCore/qbytearray_operator_iadd_test.py @@ -0,0 +1,73 @@ + +import unittest +import new + +from PySide.QtCore import QByteArray, QString +from helper.docmodifier import DocModifier + +class BaseQByteArrayOperatorIAdd(object): + '''Base class for QByteArray += operator tests. + + Implementing classes should inherit from unittest.TestCase and implement + setUp, setting self.obj and self.orig_obj to the target QByteArray and original + one, respectively''' + + __metaclass__ = DocModifier + + def testSingleString(self): + '''QByteArray += string of size 1''' + s = '0' + self.obj += s + self.assertEqual(self.obj, self.orig_obj + s) + self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s)) + + def testString(self): + '''QByteArray += string of size > 1''' + s = 'dummy' + self.obj += s + self.assertEqual(self.obj, self.orig_obj + s) + self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s)) + + def testQByteArray(self): + '''QByteArray += QByteArray''' + s = QByteArray('array') + self.obj += s + self.assertEqual(self.obj, self.orig_obj + s) + + def testChar(self): + '''QByteArray += char (number < 256)''' + s = ord('a') + self.obj += s + self.assertEqual(self.obj, self.orig_obj + s) + self.assertEqual(self.obj.size(), self.orig_obj.size() + 1) + + def testQString(self): + '''QByteArray += QString''' + s = QString('dummy') + self.obj += s + self.assertEqual(self.obj, self.orig_obj + s) + self.assertEqual(self.obj.size(), self.orig_obj.size() + s.size()) + +class NullQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd): + '''Test case for operator QByteArray += on null QByteArrays''' + + doc_prefix = 'Null object' + doc_filter = lambda x: x.startswith('test') + + def setUp(self): + self.obj = QByteArray() + self.orig_obj = QByteArray() + + +class ValidQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd): + '''Test case for operator QByteArray += on valid QByteArrays''' + + doc_prefix = 'Valid object' + doc_filter = lambda x: x.startswith('test') + + def setUp(self): + self.obj = QByteArray('some byte array') + self.orig_obj = QByteArray('some byte array') + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qbytearray_operator_test.py b/tests/QtCore/qbytearray_operator_test.py new file mode 100644 index 000000000..4a20c04c5 --- /dev/null +++ b/tests/QtCore/qbytearray_operator_test.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QByteArray operators''' + +import unittest + +from PySide.QtCore import QByteArray, QString + +class QByteArrayOperatorEqual(unittest.TestCase): + '''TestCase for operator QByteArray == QByteArray''' + + def testDefault(self): + #QByteArray() == QByteArray() + obj1 = QByteArray() + obj2 = QByteArray() + self.assertEqual(obj1, obj2) + + def testSimple(self): + #QByteArray(some_string) == QByteArray(some_string) + string = 'egg snakes' + self.assertEqual(QByteArray(string), QByteArray(string)) + + def testPyString(self): + #QByteArray(string) == string + string = 'my test string' + self.assertEqual(QByteArray(string), string) + + def testQString(self): + #QByteArray(string) == QString(string) + string = 'another test string' + self.assertEqual(QByteArray(string), QString(string)) + +class QByteArrayOperatorAt(unittest.TestCase): + '''TestCase for operator QByteArray[]''' + + def testInRange(self): + #QByteArray[x] where x is a valid index + string = 'abcdefgh' + obj = QByteArray(string) + + for i in range(len(string)): + self.assertEqual(obj[i], string[i]) + + def testInRangeReverse(self): + #QByteArray[x] where x is a valid index (reverse order) + string = 'abcdefgh' + obj = QByteArray(string) + + for i in range(len(string)-1, 0, -1): + self.assertEqual(obj[i], string[i]) + + + def testOutOfRange(self): + #QByteArray[x] where x is out of index + string = '1234567' + obj = QByteArray(string) + self.assertRaises(IndexError, lambda :obj[len(string)]) + + +class QByteArrayOperatorLen(unittest.TestCase): + '''Test case for __len__ operator of QByteArray''' + + def testBasic(self): + '''QByteArray __len__''' + self.assertEqual(len(QByteArray()), 0) + self.assertEqual(len(QByteArray('')), 0) + self.assertEqual(len(QByteArray(' ')), 1) + self.assertEqual(len(QByteArray('yabadaba')), 8) + + +class QByteArrayOperatorStr(unittest.TestCase): + '''Test case for __str__ operator of QByteArray''' + + def testBasic(self): + '''QByteArray __str__''' + self.assertEqual(QByteArray().__str__(), '') + self.assertEqual(QByteArray('').__str__(), '') + self.assertEqual(QByteArray('aaa').__str__(), 'aaa') + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qbytearray_test.py b/tests/QtCore/qbytearray_test.py new file mode 100644 index 000000000..20bba1400 --- /dev/null +++ b/tests/QtCore/qbytearray_test.py @@ -0,0 +1,98 @@ +#!/usr/bin/python +'''Unit tests for QByteArray''' + +import unittest +import ctypes +import sys + +from PySide.QtCore import QByteArray + +class QByteArrayTestToNumber(unittest.TestCase): + def testToNumberInt(self): + obj = QByteArray('37') + self.assertEqual((37, True), obj.toInt()) + + def testToNumberUShort(self): + obj = QByteArray('37') + self.assertEqual((37, True), obj.toUShort()) + + def testToNumberFloat(self): + obj = QByteArray('37.109') + self.assertEqual((ctypes.c_float(37.109).value, True), + obj.toFloat()) + + def testToNumberDouble(self): + obj = QByteArray('37.109') + self.assertEqual((ctypes.c_double(37.109).value, True), + obj.toDouble()) + +class QByteArraySplit(unittest.TestCase): + '''Test case for QByteArray.split''' + + def testPathSeparator(self): + #QByteArray.split('/') + obj = QByteArray(unittest.__file__) + self.assertEqual(obj.split('/'), unittest.__file__.split('/')) + +class QByteArrayData(unittest.TestCase): + + '''Test case for QByteArray.data''' + + def testData(self): + url = QByteArray("http://web.openbossa.org/") + self.assertEqual(url.data(), "http://web.openbossa.org/") + +class QByteArrayOperatorAtSetter(unittest.TestCase): + '''Test case for operator QByteArray[] - __setitem__''' + + def testSetterString(self): + '''QByteArray[x] = pythonstring''' + obj = QByteArray('123456') + obj[1] = '0' + self.assertEqual(obj, QByteArray('103456')) + + def testSetterStringLarge(self): + '''QByteArray[x] = pythonstring (larget than 1 char)''' + obj = QByteArray('123456') + obj[3] = 'abba' + self.assertEqual(obj, QByteArray('123abba56')) + + def testSetterQByteArray(self): + '''QByteArray[x] = qbytearray''' + obj = QByteArray('123456') + obj[3] = QByteArray('array') + self.assertEqual(obj, QByteArray('123array56')) + + +class QByteArrayOperatorAtSetterNegativeIndex(unittest.TestCase): + '''Test case for QByteArray[] - __setitem__ - for negative index''' + + def testSetterNegativeIndex(self): + '''QByteArray[x] = string - negative index''' + obj = QByteArray('123456') + obj[-3] = 'array' + self.assertEqual(obj, QByteArray('123array56')) + + +class QByteArrayOperatorAtSetterLargeIndex(unittest.TestCase): + '''Test case for QByteArray[] - __setitem__ - for 'overflown' index''' + + def testSetterLargeIndexEmpty(self): + '''QByteArray[x] = somestring - Overflow index on empty string''' + # should pad with spaces if the index is larger + obj = QByteArray('') + obj[2] = 'a' + self.assertEqual(obj, QByteArray(' a')) + + def testSetterLargeIndexNormal(self): + '''QByteArray[x] = somestring - Overflow index on normal string''' + # should pad with spaces if the index is larger + obj = QByteArray('mystring') + obj[10] = 'normal' + self.assertEqual(obj, QByteArray('mystring normal')) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qchar_test.py b/tests/QtCore/qchar_test.py new file mode 100644 index 000000000..a40724b0e --- /dev/null +++ b/tests/QtCore/qchar_test.py @@ -0,0 +1,59 @@ + +'''Test cases for QChar''' + +import unittest + +from PySide.QtCore import QString, QChar, QTextStream, QLatin1Char + + +class EqualTest(unittest.TestCase): + '''Tests for '__equal__''' + + def testEqualQChar(self): + '''QChar == QChar''' + self.assertEqual(QChar('a'), QChar('a')) + + def testEqualPyString(self): + '''QChar == Python string''' + self.assertEqual(QChar('a'), 'a') + + +class ImplicitConvQLatin1Char(unittest.TestCase): + '''Tests for implicit conversion from QLatin1Char to QChar''' + + def testQLatin1CharToChar(self): + '''QLatin1Char implicitly convertible to QChar''' + stream = QTextStream() + stream.setPadChar(QLatin1Char('-')) + self.assertEqual(QChar('-'), stream.padChar()) + + +class QCharCtorBigNumber(unittest.TestCase): + '''QChar constructors receiving ints''' + + def testInt(self): + '''QChar(int)''' + codepoint = 512 + qchar = QChar(codepoint) + reference = unichr(codepoint) + self.assertEqual(qchar.unicode(), codepoint) + + +class QCharCtorString(unittest.TestCase): + '''QChar constructor receiving strings''' + + def testBasic(self): + '''QChar(char)''' + reference = 'a' + qchar = QChar(reference) + self.assertEqual(ord(reference), ord(qchar.toAscii())) + + def testError(self): + '''QChar(char)''' + reference = 'aaaaaa' + self.assertRaises(TypeError, QChar, reference) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qcoreapplication_instance_test.py b/tests/QtCore/qcoreapplication_instance_test.py new file mode 100755 index 000000000..365148d34 --- /dev/null +++ b/tests/QtCore/qcoreapplication_instance_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QCoreApplication.instance static method''' + +import unittest + +from PySide.QtCore import QCoreApplication + +class QCoreApplicationInstanceTest(unittest.TestCase): + '''Test cases for QCoreApplication.instance static method''' + + def testQCoreApplicationInstance(self): + #Tests QCoreApplication.instance() + self.assertEqual(QCoreApplication.instance(), None) + app = QCoreApplication([]) + self.assertEqual(QCoreApplication.instance(), app) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py new file mode 100644 index 000000000..d71ed2f24 --- /dev/null +++ b/tests/QtCore/qdatastream_test.py @@ -0,0 +1,330 @@ +#!/usr/bin/python +'''Unit tests for QDataStream''' + +import unittest + +from PySide.QtCore import QDataStream, QString, QIODevice, QByteArray +from PySide.QtCore import QBitArray, QDate, QTime, QDateTime, QLine, QChar + +def create_bitarray(string): + array = QBitArray(len(string)) + for i, char in enumerate(string): + array.setBit(i, char != '0') + return array + +class QDataStreamWrite(unittest.TestCase): + '''Test case for QDatastream write* functions''' + + def setUp(self): + self.ba = QByteArray() + self.read = QDataStream(self.ba, QIODevice.ReadOnly) + self.write = QDataStream(self.ba, QIODevice.WriteOnly) + + def testWriteUInt8(self): + '''QDataStream.writeUInt8 (accepting str of size 1)''' + x = 0xFF + self.write.writeUInt8(chr(x)) + y = self.read.readUInt8() + self.assertEqual(x, y) + + self.assertRaises(TypeError, self.write.writeUInt8, 'aaaaa') + + def testWriteInt8(self): + '''QDataStream.writeInt8 (accepting str of size 1)''' + x = 65 + self.write.writeInt8(chr(x)) + y = self.read.readInt8() + self.assertEqual(x, y) + + self.assertRaises(TypeError, self.write.writeInt8, 'aaaaa') + + def testWriteUInt8Int(self): + '''QDataStream.writeUInt8 (accepting integer)''' + x = 0xFF + self.write.writeUInt8(x) + y = self.read.readUInt8() + self.assertEqual(x, y) + + def testWriteInt8Int(self): + '''QDataStream.writeInt8 (accepting integer)''' + x = 65 + self.write.writeInt8(x) + y = self.read.readInt8() + self.assertEqual(x, y) + + def testWriteUInt16(self): + '''QDataStream.writeUInt16''' + x = 0x4423 + self.write.writeUInt16(x) + y = int(self.read.readUInt16()) + self.assertEqual(x, y) + + def testWriteUInt32(self): + '''QDataStream.writeUInt32''' + x = 0xdeadbeef + self.write.writeUInt32(x) + y = int(self.read.readUInt32()) + self.assertEqual(x, y) + + +class QDataStreamShift(unittest.TestCase): + '''Test case for << and >> operators''' + + def setUp(self): + self.ba = QByteArray() + self.stream = QDataStream(self.ba, QIODevice.WriteOnly) + self.read_stream = QDataStream(self.ba, QIODevice.ReadOnly) + + def testQCharValid(self): + '''QDataStream <<>> QChar - valid''' + self.stream << QChar(42) + + res = QChar() + + self.read_stream >> res + self.assertEqual(res, QChar(42)) + + def testQCharNull(self): + '''QDataStream <<>> QChar - null''' + self.stream << QChar() + + res = QChar() + + self.read_stream >> res + self.assertEqual(res, QChar()) + self.assert_(res.isNull()) + + def testQByteArrayValid(self): + '''QDataStream <<>> QByteArray - valid''' + self.stream << QByteArray("hello") + + res = QByteArray() + + self.read_stream >> res + self.assertEqual(res, QByteArray("hello")) + + def testQByteArrayEmpty(self): + '''QDataStream <<>> QByteArray - empty''' + self.stream << QByteArray("") + + res = QByteArray() + + self.read_stream >> res + self.assertEqual(res, QByteArray("")) + self.assert_(res.isEmpty()) + self.assert_(not res.isNull()) + + def testQByteArrayNull(self): + '''QDataStream <<>> QByteArray - null''' + self.stream << QByteArray() + + res = QByteArray() + + self.read_stream >> res + self.assertEqual(res, QByteArray()) + self.assert_(res.isEmpty()) + self.assert_(res.isNull()) + + def testQStringValid(self): + '''QDataStream <<>> QString - valid''' + self.stream << QString('Ka-boom') + + res = QString() + + self.read_stream >> res + self.assertEqual(res, QString('Ka-boom')) + + def testQStringEmpty(self): + '''QDataStream <<>> QString - empty''' + self.stream << QString('') + + res = QString() + + self.read_stream >> res + self.assertEqual(res, QString("")) + self.assert_(res.isEmpty()) + self.assert_(not res.isNull()) + + def testQStringNull(self): + '''QDataStream <<>> QString - null''' + self.stream << QString() + + res = QString() + + self.read_stream >> res + self.assertEqual(res, QString()) + self.assert_(res.isEmpty()) + self.assert_(res.isNull()) + + + def testQBitArrayNull(self): + '''QDataStream <<>> QBitArray - null''' + self.stream << QBitArray() + + res = QBitArray() + + self.read_stream >> res + self.assertEqual(res, QBitArray()) + + def testQBitArrayValid(self): + '''QDataStream <<>> QBitArray - valid''' + self.stream << create_bitarray('01010101') + + res = QBitArray() + + self.read_stream >> res + self.assertEqual(res, create_bitarray('01010101')) + + def testQDateNull(self): + '''QDataStream <<>> QDate - null''' + self.stream << QDate() + + res = QDate() + + self.read_stream >> res + self.assertEqual(res, QDate()) + self.assert_(not res.isValid()) + self.assert_(res.isNull()) + + def testQDateValid(self): + '''QDataStream <<>> QDate - valid''' + self.stream << QDate(2012, 12, 21) + + res = QDate() + + self.read_stream >> res + self.assertEqual(res, QDate(2012, 12, 21)) + self.assert_(res.isValid()) + self.assert_(not res.isNull()) + + + def testQTimeNull(self): + '''QDataStream <<>> QTime - null''' + self.stream << QTime() + + res = QTime() + + self.read_stream >> res + self.assertEqual(res, QTime()) + self.assert_(not res.isValid()) + self.assert_(res.isNull()) + + def testQTimeValid(self): + '''QDataStream <<>> QTime - valid''' + self.stream << QTime(12, 12, 21) + + res = QTime() + + self.read_stream >> res + self.assertEqual(res, QTime(12, 12, 21)) + self.assert_(res.isValid()) + self.assert_(not res.isNull()) + + def testQDateTimeNull(self): + '''QDataStream <<>> QDateTime - null''' + + self.stream << QDateTime() + + res = QDateTime() + + self.read_stream >> res + self.assertEqual(res, QDateTime()) + self.assert_(not res.isValid()) + self.assert_(res.isNull()) + + def testQDateTimeValid(self): + '''QDataStream <<>> QDateTime - valid''' + time = QTime(23, 23, 23) + date = QDate(2009, 01, 01) + + self.stream << QDateTime(date, time) + + res = QDateTime() + + self.read_stream >> res + self.assertEqual(res, QDateTime(date, time)) + self.assert_(res.isValid()) + self.assert_(not res.isNull()) + + +class QDataStreamShiftBitArray(unittest.TestCase): + + def _check_bitarray(self, data_set): + '''Check the >> operator for the given data set''' + + for data, expectedStatus, expectedString in data_set: + stream = QDataStream(data, QIODevice.ReadOnly) + string = QBitArray() + stream >> string + + self.assertEqual(stream.status(), expectedStatus) + self.assertEqual(string.size(), expectedString.size()) + self.assertEqual(string, expectedString) + + def testOk(self): + '''QDataStream with valid QBitArray''' + data = [] + + data.append((QByteArray('\x00\x00\x00\x00'), QDataStream.Ok, + QBitArray())) + data.append((QByteArray('\x00\x00\x00\x01\x00'), QDataStream.Ok, + create_bitarray('0'))) + data.append((QByteArray('\x00\x00\x00\x01\x01'), QDataStream.Ok, + create_bitarray('1'))) + data.append((QByteArray('\x00\x00\x00\x02\x03'), QDataStream.Ok, + create_bitarray('11'))) + data.append((QByteArray('\x00\x00\x00\x03\x07'), QDataStream.Ok, + create_bitarray('111'))) + data.append((QByteArray('\x00\x00\x00\x04\x0f'), QDataStream.Ok, + create_bitarray('1111'))) + data.append((QByteArray('\x00\x00\x00\x05\x1f'), QDataStream.Ok, + create_bitarray('11111'))) + data.append((QByteArray('\x00\x00\x00\x06\x3f'), QDataStream.Ok, + create_bitarray('111111'))) + data.append((QByteArray('\x00\x00\x00\x07\x7f'), QDataStream.Ok, + create_bitarray('1111111'))) + data.append((QByteArray('\x00\x00\x00\x07\x7e'), QDataStream.Ok, + create_bitarray('0111111'))) + data.append((QByteArray('\x00\x00\x00\x07\x00'), QDataStream.Ok, + create_bitarray('0000000'))) + data.append((QByteArray('\x00\x00\x00\x07\x39'), QDataStream.Ok, + create_bitarray('1001110'))) + + self._check_bitarray(data) + + def testPastEnd(self): + '''QDataStream >> QBitArray reading past the end of the data''' + data = [] + + data.append((QByteArray(), QDataStream.ReadPastEnd, + QBitArray())) + data.append((QByteArray('\x00'), QDataStream.ReadPastEnd, + QBitArray())) + data.append((QByteArray('\x00\x00'), QDataStream.ReadPastEnd, + QBitArray())) + data.append((QByteArray('\x00\x00\x00'), QDataStream.ReadPastEnd, + QBitArray())) + data.append((QByteArray('\x00\x00\x00\x01'), QDataStream.ReadPastEnd, + QBitArray())) + data.append((QByteArray('\x00\x00\x00\x02'), QDataStream.ReadPastEnd, + QBitArray())) + data.append((QByteArray('\x00\x00\x00\x03'), QDataStream.ReadPastEnd, + QBitArray())) + data.append((QByteArray('\x00\x00\x00\x04'), QDataStream.ReadPastEnd, + QBitArray())) + + self._check_bitarray(data) + + def testCorruptData(self): + '''QDataStream reading corrupt data''' + data = [] + + data.append((QByteArray('\x00\x00\x00\x01\x02'), + QDataStream.ReadCorruptData, + QBitArray())) + + self._check_bitarray(data) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qdate_test.py b/tests/QtCore/qdate_test.py new file mode 100644 index 000000000..49234486f --- /dev/null +++ b/tests/QtCore/qdate_test.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +'''Test cases for QDate''' + +import unittest + +from PySide.QtCore import * + +class TestQDate (unittest.TestCase): + def testGetDate(self): + date = QDate(2009, 22, 9) + tuple_ = date.getDate() + self.assertEquals(tuple, tuple_.__class__) + (y, m, d) = tuple_ + self.assertEqual(date.year(), y) + self.assertEqual(date.month(), m) + self.assertEqual(date.day(), d) + + def testGetWeekNumber(self): + date = QDate(2000, 1, 1) + tuple_ = date.weekNumber() + self.assertEquals(tuple, tuple_.__class__) + (week, yearNumber) = tuple_ + self.assertEqual(week, 52) + self.assertEqual(yearNumber, 1999) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qenum_test.py b/tests/QtCore/qenum_test.py new file mode 100644 index 000000000..e3f963869 --- /dev/null +++ b/tests/QtCore/qenum_test.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +'''Test cases for QEnum and QFlags''' + +import unittest + +from PySide.QtCore import QIODevice, QString, Qt, QVariant + +class TestEnum(unittest.TestCase): + + def testToInt(self): + self.assertEqual(QIODevice.NotOpen, 0) + self.assertEqual(QIODevice.ReadOnly, 1) + self.assertEqual(QIODevice.WriteOnly, 2) + self.assertEqual(QIODevice.ReadWrite, 1 | 2) + self.assertEqual(QIODevice.Append, 4) + self.assertEqual(QIODevice.Truncate, 8) + self.assertEqual(QIODevice.Text, 16) + self.assertEqual(QIODevice.Unbuffered, 32) + + def testToIntInFunction(self): + self.assertEqual(QString.number(QIODevice.WriteOnly), "2") + +class TestQFlags(unittest.TestCase): + def testToItn(self): + om = QIODevice.NotOpen + + self.assertEqual(om, QIODevice.NotOpen) + self.assertTrue(om == 0) + + self.assertTrue(om != QIODevice.ReadOnly) + self.assertTrue(om != 1) + + def testToIntInFunction(self): + om = QIODevice.WriteOnly + self.assertEqual(int(om), 2) + + def testNonExtensibleEnums(self): + try: + om = QIODevice.OpenMode(QIODevice.WriteOnly) + self.assertFail() + except: + pass + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qevent_test.py b/tests/QtCore/qevent_test.py new file mode 100644 index 000000000..07f23f098 --- /dev/null +++ b/tests/QtCore/qevent_test.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +'''Test cases for QtCore.QEvent''' + +import unittest + +from PySide.QtCore import QEvent + +class QEventTypeFlag(unittest.TestCase): + '''Test case for usage of QEvent.Type flags''' + + def testFlagAccess(self): + #QEvent.Type flags usage + + event = QEvent(QEvent.Timer) + self.assertEqual(event.type(), QEvent.Timer) + + event = QEvent(QEvent.Close) + self.assertEqual(event.type(), QEvent.Close) + + event = QEvent(QEvent.IconTextChange) + self.assertEqual(event.type(), QEvent.IconTextChange) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qfile_test.py b/tests/QtCore/qfile_test.py new file mode 100644 index 000000000..adbdd68b7 --- /dev/null +++ b/tests/QtCore/qfile_test.py @@ -0,0 +1,31 @@ + +import unittest + +import os +import tempfile + +from PySide.QtCore import QFile, QIODevice + +class GetCharTest(unittest.TestCase): + '''Test case for QIODevice.getChar in QFile''' + + def setUp(self): + '''Acquire resources''' + handle, self.filename = tempfile.mkstemp() + os.write(handle, 'a') + os.close(handle) + + def tearDown(self): + '''release resources''' + os.remove(self.filename) + + def testBasic(self): + '''QFile.getChar''' + obj = QFile(self.filename) + obj.open(QIODevice.ReadOnly) + self.assertEqual(obj.getChar(), (True, 'a')) + self.assert_(not obj.getChar()[0]) + obj.close() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qfileinfo_test.py b/tests/QtCore/qfileinfo_test.py new file mode 100644 index 000000000..580b5a7d5 --- /dev/null +++ b/tests/QtCore/qfileinfo_test.py @@ -0,0 +1,17 @@ + +import unittest + +import os +import tempfile + +from PySide.QtCore import QFile, QFileInfo + +class QFileConstructor(unittest.TestCase): + '''QFileInfo constructor with qfile''' + + def testBasic(self): + '''QFileInfo(QFile)''' + obj = QFileInfo(QFile()) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qflags_test.py b/tests/QtCore/qflags_test.py new file mode 100644 index 000000000..1346c11ef --- /dev/null +++ b/tests/QtCore/qflags_test.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +'''Test cases for QFlags''' + +import unittest +from PySide.QtCore import QIODevice, Qt, QFile + +class QFlagTest(unittest.TestCase): + '''Test case for usage of flags''' + + def testCallFunction(self): + f = QFile("/tmp/t0"); + self.assertEqual(f.open(QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite), True) + om = f.openMode() + self.assertEqual(om & QIODevice.Truncate, QIODevice.Truncate) + self.assertEqual(om & QIODevice.Text, QIODevice.Text) + self.assertEqual(om & QIODevice.ReadWrite, QIODevice.ReadWrite) + self.assert_(om == QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite) + f.close() + + +class QFlagOperatorTest(unittest.TestCase): + '''Test case for operators in QFlags''' + + def testInvert(self): + '''QFlags ~ (invert) operator''' + self.assert_(isinstance(~QIODevice.ReadOnly, QIODevice.OpenMode)) + + def testOr(self): + '''QFlags | (or) operator''' + self.assert_(isinstance(QIODevice.ReadOnly | QIODevice.WriteOnly, QIODevice.OpenMode)) + + def testAnd(self): + '''QFlags & (and) operator''' + self.assert_(isinstance(QIODevice.ReadOnly & QIODevice.WriteOnly, QIODevice.OpenMode)) + + def testIOr(self): + '''QFlags |= (ior) operator''' + flag = Qt.WindowFlags() + self.assert_(flag & Qt.Widget == 0) + flag |= Qt.WindowMinimizeButtonHint + self.assert_(flag & Qt.WindowMinimizeButtonHint) + + def testInvertOr(self): + '''QFlags ~ (invert) operator over the result of an | (or) operator''' + self.assert_(isinstance(~(Qt.ItemIsSelectable | Qt.ItemIsEditable), Qt.ItemFlags)) + + def testEqual(self): + '''QFlags == operator''' + flags = Qt.Window + flags |= Qt.WindowMinimizeButtonHint + flag_type = (flags & Qt.WindowType_Mask) + self.assertEqual(flag_type, Qt.Window) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qhandle_test.py b/tests/QtCore/qhandle_test.py new file mode 100644 index 000000000..bcf6dea3d --- /dev/null +++ b/tests/QtCore/qhandle_test.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +'''Test cases for QEnum and QFlags''' + +import unittest + +from PySide.QtCore import QThread, Qt + +class TestHANDLE(unittest.TestCase): + def testIntConversion(self): + i = 0 + h = QThread.currentThreadId() + i = 0 + int(h) + self.assertEqual(i, int(h)) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qlatin1string_test.py b/tests/QtCore/qlatin1string_test.py new file mode 100644 index 000000000..fdcf6ec98 --- /dev/null +++ b/tests/QtCore/qlatin1string_test.py @@ -0,0 +1,21 @@ + +'''Test cases for QLatin1String''' + +import unittest + +from PySide.QtCore import QString, QLatin1String, QObject + + +class ImplicitConvQLatin1String(unittest.TestCase): + '''Tests for implicit conversion from QLatin1String to QString''' + + def testQLatin1String(self): + '''QString implicit convertion from QLatin1String''' + obj = QObject() + obj.setObjectName(QLatin1String('dummy')) + + self.assertEqual(QString('dummy'), obj.objectName()) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qlinef_test.py b/tests/QtCore/qlinef_test.py new file mode 100644 index 000000000..31b5db955 --- /dev/null +++ b/tests/QtCore/qlinef_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +'''Test cases for QLineF''' + +import unittest +import os + +from PySide.QtCore import * + +class TestQLineF (unittest.TestCase): + def testIntersect(self): + l1 = QLineF(0, 0, 1, 0) + l2 = QLineF(1, -1, 1, 1) + tuple_ = l1.intersect(l2) + self.assertEquals(tuple, tuple_.__class__) + (value, p) = tuple_ + self.assertEquals(QLineF.BoundedIntersection, value) + self.assertEqual(QPointF(1, 0), p) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qlocale_test.py b/tests/QtCore/qlocale_test.py new file mode 100644 index 000000000..f1bff8e82 --- /dev/null +++ b/tests/QtCore/qlocale_test.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +'''Unit tests for QLocale''' + +import unittest +import ctypes +import sys + +from PySide.QtCore import QLocale + +class QLocaleTestToNumber(unittest.TestCase): + def testToNumberInt(self): + obj = QLocale(QLocale.C) + self.assertEqual((37, True), obj.toInt('37')) + + def testToNumberFloat(self): + obj = QLocale(QLocale.C) + self.assertEqual((ctypes.c_float(37.109).value, True), + obj.toFloat('37.109')) + + def testToNumberDouble(self): + obj = QLocale(QLocale.C) + self.assertEqual((ctypes.c_double(37.109).value, True), + obj.toDouble('37.109')) + + def testToNumberShort(self): + obj = QLocale(QLocale.C) + self.assertEqual((ctypes.c_short(37).value, True), + obj.toShort('37')) + + def testToNumberULongLong(self): + obj = QLocale(QLocale.C) + self.assertEqual((ctypes.c_ulonglong(37).value, True), + obj.toULongLong('37')) + + def testToNumberULongLongNegative(self): + obj = QLocale(QLocale.C) + self.assert_(not obj.toULongLong('-37')[1]) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qmetaobject_test.py b/tests/QtCore/qmetaobject_test.py new file mode 100644 index 000000000..667e763ad --- /dev/null +++ b/tests/QtCore/qmetaobject_test.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Tests for static methos conflicts with class methods''' + +import unittest + +from PySide.QtCore import * + +class Foo(QFile): + pass + +class DynObject(QObject): + def slot(self): + pass + +class qmetaobject_test(unittest.TestCase): + def test_QMetaObject(self): + qobj = QObject() + qobj_metaobj = qobj.metaObject() + self.assertEqual(qobj_metaobj.className(), "QObject") + + obj = QFile() + m = obj.metaObject() + self.assertEqual(m.className(), "QFile") + self.assertNotEqual(m.methodCount(), qobj_metaobj.methodCount()) + + obj = Foo() + m = obj.metaObject() + self.assertEqual(m.className(), "Foo") + f = QFile() + fm = f.metaObject() + self.assertEqual(m.methodCount(), fm.methodCount()) + + def test_DynamicSlotSignal(self): + o = DynObject() + o2 = QObject() + + method_count_base = o.metaObject().methodCount() + + o.connect(o2, SIGNAL("bar()"), o.slot) + slot_index = o.metaObject().indexOfMethod("slot()") + + o.connect(o, SIGNAL("foo()"), o2, SIGNAL("bar()")) + signal_index = o.metaObject().indexOfMethod("foo()"); + + self.assert_(slot_index != signal_index) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qmodelindex_internalpointer_test.py b/tests/QtCore/qmodelindex_internalpointer_test.py new file mode 100644 index 000000000..015d1c926 --- /dev/null +++ b/tests/QtCore/qmodelindex_internalpointer_test.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +''' Test case for QAbstractListModel.createIndex and QModelIndex.internalPointer''' + +import sys +import unittest +from PySide.QtCore import * + +class MyModel (QAbstractListModel): + pass + +class TestQModelIndexInternalPointer(unittest.TestCase): + ''' Test case for QAbstractListModel.createIndex and QModelIndex.internalPointer''' + + def setUp(self): + #Acquire resources + self.model = MyModel() + + def tearDown(self): + #Release resources + del self.model + + def testInternalPointer(self): + #Test QAbstractListModel.createIndex and + #QModelIndex.internalPointer with regular + #Python objects + idx = self.model.createIndex(0, 0, "Hello") + self.assertEqual("Hello", idx.internalPointer()) + a = [1, 2, 3] + idx = self.model.createIndex(0, 0, a) + self.assertEqual(a, idx.internalPointer()) + + def testReferenceCounting(self): + #Test reference counting when retrieving data with + #QModelIndex.internalPointer + a = [1, 2, 3] + a_refcnt = sys.getrefcount(a) + idx = self.model.createIndex(0, 0, a) + ptr = idx.internalPointer() + self.assertEqual(sys.getrefcount(a), a_refcnt + 1) + + def testIndexForDefaultDataArg(self): + #Test QAbstractListModel.createIndex with a default + #value for data argument + idx = self.model.createIndex(0, 0) + self.assertEqual(None, idx.internalPointer()) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qobject_children_segfault_test.py b/tests/QtCore/qobject_children_segfault_test.py new file mode 100644 index 000000000..930a082cf --- /dev/null +++ b/tests/QtCore/qobject_children_segfault_test.py @@ -0,0 +1,29 @@ + +'''Test cases for parent-child relationship''' + +import unittest + +from PySide.QtCore import QObject, QCoreApplication + +class ChildrenCoreApplication(unittest.TestCase): + '''Test case for calling QObject.children after creating a QCoreApp''' + + def testQCoreAppChildren(self): + #QObject.children() after creating a QCoreApplication + # Minimal test: + # 1- Create QCoreApp + # 2- Create parent and childrens + # 3- While keeping the children alive, call parent.children() + # 4- Delete parent + app = QCoreApplication([]) + parent = QObject() + children = [QObject(parent) for x in range(25)] + # Uncomment the lines below to make the test pass + # del children + # del child2 + del parent # XXX Segfaults here + self.assert_(True) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_connect_notify_test.py b/tests/QtCore/qobject_connect_notify_test.py new file mode 100644 index 000000000..441037585 --- /dev/null +++ b/tests/QtCore/qobject_connect_notify_test.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +''' Test case for QObject::connectNotify()''' + +import unittest +from PySide.QtCore import * +from helper import UsesQCoreApplication + +def cute_slot(): + pass + +class Obj(QObject): + def __init__(self): + QObject.__init__(self) + self.con_notified = False + self.dis_notified = False + + def connectNotify(self, signal): + self.con_notified = True + + def disconnectNotify(self, signal): + self.dis_notified = True + + def reset(self): + self.con_notified = False + self.dis_notified = False + +class TestQObjectConnectNotify(UsesQCoreApplication): + '''Test case for QObject::connectNotify''' + def setUp(self): + UsesQCoreApplication.setUp(self) + self.called = False + + def tearDown(self): + UsesQCoreApplication.tearDown(self) + + def testBasic(self): + sender = Obj() + receiver = QObject() + sender.connect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) + self.assert_(sender.con_notified) + sender.disconnect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) + self.assert_(sender.dis_notified) + + def testPySignal(self): + sender = Obj() + receiver = QObject() + sender.connect(SIGNAL("foo()"), receiver, SLOT("deleteLater()")) + self.assert_(sender.con_notified) + sender.disconnect(SIGNAL("foo()"), receiver, SLOT("deleteLater()")) + self.assert_(sender.dis_notified) + + def testPySlots(self): + sender = Obj() + receiver = QObject() + sender.connect(SIGNAL("destroyed()"), cute_slot) + self.assert_(sender.con_notified) + sender.disconnect(SIGNAL("destroyed()"), cute_slot) + self.assert_(sender.dis_notified) + + def testpyAll(self): + sender = Obj() + receiver = QObject() + sender.connect(SIGNAL("foo()"), cute_slot) + self.assert_(sender.con_notified) + sender.disconnect(SIGNAL("foo()"), cute_slot) + self.assert_(sender.dis_notified) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_event_filter_test.py b/tests/QtCore/qobject_event_filter_test.py new file mode 100644 index 000000000..8018fcda0 --- /dev/null +++ b/tests/QtCore/qobject_event_filter_test.py @@ -0,0 +1,80 @@ + +'''Test cases for QObject.eventFilter''' + +import unittest + +from PySide.QtCore import QObject, QTimerEvent + +from helper import UsesQCoreApplication + +class FilterObject(QObject): + '''Filter object for the basic test''' + def __init__(self, obj=None, event_type=None, *args): + #Creates a new filter object + QObject.__init__(self, *args) + self.obj = obj + self.event_type = event_type + self.events_handled = 0 + self.events_bypassed = 0 + + def setTargetObject(self, obj): + #Sets the object that will be filtered + self.obj = obj + + def eventFilter(self, obj, event): + '''Just checks if is the correct object and event type + incrementing counter until reaching the limit. After that it + stops filtering the events for the object.''' + if (self.obj == obj): + if isinstance(event, self.event_type) and self.events_handled < 5: + self.events_handled += 1 + return True + else: + self.events_bypassed += 1 + return False + else: + return QObject.eventFilter(self, obj, event) + +class FilteredObject(QObject): + '''Class that will be filtered. Quits the app after 5 timer events''' + def __init__(self, app, *args): + QObject.__init__(self, *args) + self.app = app + self.times_called = 0 + + def timerEvent(self, evt): + #Overriden method + self.times_called += 1 + + if self.times_called == 5: + self.app.quit() + +class TestQObjectEventFilterPython(UsesQCoreApplication): + '''QObject.eventFilter - Reimplemented in python + Filters 5 TimerEvents and then bypasses the other events to the + timerEvent method. After 5 runs, the timerEvent method will ask + the core application to exit''' + def setUp(self): + #Acquire resources + UsesQCoreApplication.setUp(self) + self.obj_filter = FilterObject(event_type=QTimerEvent) + def tearDown(self): + #Release resources + del self.obj_filter + UsesQCoreApplication.tearDown(self) + + def testEventFilter(self): + #QObject.eventFilter reimplemented in python + filtered = FilteredObject(self.app) + filtered.installEventFilter(self.obj_filter) + self.obj_filter.setTargetObject(filtered) + + filtered.startTimer(0) + + self.app.exec_() + + self.assertEqual(filtered.times_called, 5) + self.assertEqual(self.obj_filter.events_handled, 5) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_inherits_test.py b/tests/QtCore/qobject_inherits_test.py new file mode 100644 index 000000000..9e02b0a46 --- /dev/null +++ b/tests/QtCore/qobject_inherits_test.py @@ -0,0 +1,43 @@ +'''Test cases for QObject methods''' + +import unittest + +from PySide.QtCore import QObject + +class InheritsCase(unittest.TestCase): + '''Test case for QObject.inherits''' + + def testCppInheritance(self): + #QObject.inherits() for c++ classes + #An class inherits itself + self.assert_(QObject().inherits('QObject')) + + def testPythonInheritance(self): + #QObject.inherits() for python classes + + class Dummy(QObject): + #Dummy class + pass + + self.assert_(Dummy().inherits('QObject')) + self.assert_(Dummy().inherits('Dummy')) + self.assert_(not Dummy().inherits('FooBar')) + + def testPythonMultiInheritance(self): + #QObject.inherits() for multiple inheritance + # QObject.inherits(classname) should fail if classname isn't a + # QObject subclass + + class Parent(object): + #Dummy parent + pass + class Dummy(QObject, Parent): + #Dummy class + pass + + self.assert_(Dummy().inherits('QObject')) + self.assert_(not Dummy().inherits('Parent')) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_parent_test.py b/tests/QtCore/qobject_parent_test.py new file mode 100644 index 000000000..4699fc60c --- /dev/null +++ b/tests/QtCore/qobject_parent_test.py @@ -0,0 +1,234 @@ + +'''Test cases for parent-child relationship''' + +import unittest +from sys import getrefcount + +from PySide.QtCore import QObject, QTimer + +class ParentRefCountCase(unittest.TestCase): + '''Test case for the refcount changes of setParent''' + + def setUp(self): + #Acquire resources + self.parent = QObject() + self.child = QObject() + + def tearDown(self): + #Release resources + del self.child + del self.parent + + def testSetParent(self): + #QObject.setParent() refcount changes + self.assertEqual(getrefcount(self.child), 2) + self.child.setParent(self.parent) + self.assertEqual(getrefcount(self.child), 3) + + def testConstructor(self): + #QObject(QObject) refcount changes + child = QObject(self.parent) + self.assertEqual(getrefcount(child), 3) + +class ParentCase(unittest.TestCase): + '''Small collection of tests related to parent-child relationship''' + + def testSetParent(self): + #QObject.setParent() + parent = QObject() + child = QObject() + child.setParent(parent) + + self.assertEqual(parent, child.parent()) + + def testParentConstructor(self): + #QObject(parent) + parent = QObject() + child = QObject(parent) + + self.assertEqual(parent, child.parent()) + + orig_repr = repr(child) + del child + self.assertEqual(orig_repr, repr(parent.children()[0])) + + def testChildren(self): + #QObject.children() + parent = QObject() + children = [QObject(parent) for x in range(25)] + + self.assertEqual(parent.children(), children) + + def testFindChild(self): + #QObject.findChild() with all QObject + parent = QObject() + name = 'object%d' + children = [QObject(parent) for i in range(20)] + + for i, child in enumerate(children): + child.setObjectName(name % i) + + for i, child in enumerate(children): + self.assertEqual(child, parent.findChild(QObject, name % i)) + + def testFindChildren(self): + #QObject.findChildren() with all QObject + parent = QObject() + target_name = 'foo' + children = [QTimer(parent) for i in range(20)] + children.extend([QObject(parent) for i in range(20)]) + + for i, child in enumerate(children): + if i % 5 == 0: + child.setObjectName(target_name) + else: + child.setObjectName(str(i)) + + # Emulates findChildren with the intended outcome + target_children = [x for x in children if x.objectName() == target_name] + test_children = parent.findChildren(QObject, target_name) + + self.assertEqual(sorted(target_children), sorted(test_children)) + + def testParentEquality(self): + #QObject.parent() == parent + parent = QObject() + child = QObject(parent) + self.assertEqual(parent, child.parent()) + + +class TestParentOwnership(unittest.TestCase): + '''Test case for Parent/Child object ownership''' + + def testParentDestructor(self): + parent = QObject() + self.assertEqual(getrefcount(parent), 2) + + child = QObject(parent) + self.assertEqual(getrefcount(child), 3) + self.assertEqual(getrefcount(parent), 2) + + del parent + self.assertEqual(getrefcount(child), 2) + + # this will fail because parent deleted child cpp object + self.assertRaises(RuntimeError, lambda :child.objectName()) + + # test parent with multiples children + def testMultipleChildren(self): + o = QObject() + self.assertEqual(getrefcount(o), 2) + + c = QObject(o) + self.assertEqual(getrefcount(c), 3) + self.assertEqual(getrefcount(o), 2) + + c2 = QObject(o) + self.assertEqual(getrefcount(o), 2) + self.assertEqual(getrefcount(c), 3) + self.assertEqual(getrefcount(c2), 3) + + del o + self.assertEqual(getrefcount(c), 2) + self.assertEqual(getrefcount(c2), 2) + + # this will fail because parent deleted child cpp object + self.assertRaises(RuntimeError, lambda :c.objectName()) + self.assertRaises(RuntimeError, lambda :c2.objectName()) + + # test recursive parent + def testRecursiveParent(self): + o = QObject() + self.assertEqual(getrefcount(o), 2) + + c = QObject(o) + self.assertEqual(getrefcount(c), 3) + self.assertEqual(getrefcount(o), 2) + + c2 = QObject(c) + self.assertEqual(getrefcount(o), 2) + self.assertEqual(getrefcount(c), 3) + self.assertEqual(getrefcount(c2), 3) + + del o + self.assertEqual(getrefcount(c), 2) + self.assertEqual(getrefcount(c2), 2) + + # this will fail because parent deleted child cpp object + self.assertRaises(RuntimeError, lambda :c.objectName()) + self.assertRaises(RuntimeError, lambda :c2.objectName()) + + # test parent transfer + def testParentTransfer(self): + o = QObject() + self.assertEqual(getrefcount(o), 2) + + c = QObject() + self.assertEqual(getrefcount(c), 2) + + c.setParent(o) + self.assertEqual(getrefcount(c), 3) + + c.setParent(None) + self.assertEqual(getrefcount(c), 2) + + del c + del o + + +class ExtQObject(QObject): + def __init__(self): + QObject.__init__(self) + +class ReparentingTest(unittest.TestCase): + '''Test cases for reparenting''' + + def testParentedQObjectIdentity(self): + object_list = [] + parent = QObject() + for i in range(3): + obj = QObject() + object_list.append(obj) + obj.setParent(parent) + for child in parent.children(): + self.assert_(child in object_list) + + def testParentedExtQObjectType(self): + object_list = [] + parent = QObject() + for i in range(3): + obj = ExtQObject() + object_list.append(obj) + obj.setParent(parent) + for orig, child in zip(object_list, parent.children()): + self.assertEqual(type(orig), type(child)) + + def testReparentedQObjectIdentity(self): + object_list = [] + old_parent = QObject() + new_parent = QObject() + for i in range(3): + obj = QObject() + object_list.append(obj) + obj.setParent(old_parent) + for obj in object_list: + obj.setParent(new_parent) + for child in new_parent.children(): + self.assert_(child in object_list) + + def testReparentedExtQObjectType(self): + object_list = [] + old_parent = QObject() + new_parent = QObject() + for i in range(3): + obj = ExtQObject() + object_list.append(obj) + obj.setParent(old_parent) + for obj in object_list: + obj.setParent(new_parent) + for orig, child in zip(object_list, new_parent.children()): + self.assertEqual(type(orig), type(child)) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py new file mode 100644 index 000000000..33df2ac9b --- /dev/null +++ b/tests/QtCore/qobject_property_test.py @@ -0,0 +1,71 @@ + +'''Test cases for QObject property and setProperty''' + +import unittest + +from PySide.QtCore import QObject, QVariant, QString + +class PropertyCase(unittest.TestCase): + '''Test case for QObject properties''' + + def testObjectNameProperty(self): + #QObject.setProperty() for existing C++ property + obj = QObject() + self.assert_(obj.setProperty('objectName', QVariant('dummy'))) + self.assertEqual(obj.objectName(), 'dummy') + + self.assert_(obj.setProperty('objectName', QVariant('foobar'))) + self.assertEqual(obj.objectName(), 'foobar') + + def testDynamicProperty(self): + #QObject.setProperty() for dynamic properties + obj = QObject() + + # Should return false when creating a new dynamic property + self.assert_(not obj.setProperty('dummy', QVariant('mydata'))) + prop = obj.property('dummy') + self.assert_(isinstance(prop, QVariant)) + self.assert_(prop.isValid()) + self.assertEqual(obj.property('dummy').toString(), 'mydata') + + self.assert_(not obj.setProperty('dummy', QVariant('zigzag'))) + prop = obj.property('dummy') + self.assert_(isinstance(prop, QVariant)) + self.assert_(prop.isValid()) + self.assertEqual(obj.property('dummy').toString(), 'zigzag') + + self.assert_(not obj.setProperty('dummy', QVariant(42))) + prop = obj.property('dummy') + self.assert_(isinstance(prop, QVariant)) + self.assert_(prop.isValid()) + # QVariant.toInt has a bool* arg in C++, so returns a tuple + self.assertEqual(obj.property('dummy').toInt(), (42, True)) + + def testQStringProperty(self): + obj = QObject() + self.assert_(not obj.setProperty('dummy', QString('data'))) + prop = obj.property('dummy') + + self.assert_(isinstance(prop, QVariant)) + self.assert_(prop.isValid()) + self.assertEqual(obj.property('dummy').toString(), QString('data')) + + def testImplicitQVariantProperty(self): + obj = QObject() + self.assert_(not obj.setProperty('dummy', 'data')) + prop = obj.property('dummy') + + self.assert_(isinstance(prop, QVariant)) + self.assert_(prop.isValid()) + self.assertEqual(obj.property('dummy').toString(), 'data') + + def testInvalidProperty(self): + #QObject.property() for invalid properties + obj = QObject() + + prop = obj.property('dummy') + self.assert_(not prop.isValid()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_protected_methods_test.py b/tests/QtCore/qobject_protected_methods_test.py new file mode 100644 index 000000000..530b870a2 --- /dev/null +++ b/tests/QtCore/qobject_protected_methods_test.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +'''Test cases for QObject protected methods''' + +import unittest + +from PySide.QtCore import QObject, QThread, SIGNAL + +class Dummy(QObject): + '''Dummy class''' + pass + +class QObjectReceivers(unittest.TestCase): + '''Test case for QObject.receivers()''' + + def cb(self, *args): + #Dummy callback + pass + + def testQObjectReceiversExtern(self): + #QObject.receivers() - Protected method external access + + obj = Dummy() + self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0) + + QObject.connect(obj, SIGNAL("destroyed()"), self.cb) + self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0) + + def testQThreadReceiversExtern(self): + #QThread.receivers() - Inherited protected method + + obj = QThread() + self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0) + QObject.connect(obj, SIGNAL("destroyed()"), self.cb) + self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_test.py b/tests/QtCore/qobject_test.py new file mode 100644 index 000000000..a1749babc --- /dev/null +++ b/tests/QtCore/qobject_test.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QObject methods''' + +import unittest + +from PySide.QtCore import QObject + +class ObjectNameCase(unittest.TestCase): + '''Tests related to QObject object name''' + + def testSimple(self): + #QObject.objectName(string) + name = 'object1' + obj = QObject() + obj.setObjectName(name) + + self.assertEqual(name, obj.objectName()) + + def testEmpty(self): + #QObject.objectName('') + name = '' + obj = QObject() + obj.setObjectName(name) + + self.assertEqual(name, obj.objectName()) + + def testDefault(self): + #QObject.objectName() default + obj = QObject() + self.assertEqual('', obj.objectName()) + + def testUnicode(self): + #QObject.setObjectName(unicode) + name = u'diseño' + #FIXME Strange error on upstream when using equal(name, obj) + obj = QObject() + obj.setObjectName(name) + self.assertEqual(obj.objectName(), name) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_timer_event_test.py b/tests/QtCore/qobject_timer_event_test.py new file mode 100644 index 000000000..b46207d88 --- /dev/null +++ b/tests/QtCore/qobject_timer_event_test.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +'''Test case for QObject.timerEvent overloading''' + +import unittest +from time import sleep +from PySide.QtCore import QObject, QCoreApplication + +from helper import UsesQCoreApplication + +class Dummy(QObject): + + def __init__(self, app): + super(Dummy, self).__init__() + self.times_called = 0 + self.app = app + + def timerEvent(self, event): + QObject.timerEvent(self, event) + event.accept() + self.times_called += 1 + + if self.times_called == 5: + self.app.exit(0) + +class QObjectTimerEvent(UsesQCoreApplication): + + def setUp(self): + #Acquire resources + super(QObjectTimerEvent, self).setUp() + + def tearDown(self): + #Release resources + super(QObjectTimerEvent, self).tearDown() + + def testTimerEvent(self): + #QObject.timerEvent overloading + obj = Dummy(self.app) + timer_id = obj.startTimer(200) + self.app.exec_() + obj.killTimer(timer_id) + self.assertEqual(obj.times_called, 5) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qobject_tr_as_instance_test.py b/tests/QtCore/qobject_tr_as_instance_test.py new file mode 100644 index 000000000..5aa70530b --- /dev/null +++ b/tests/QtCore/qobject_tr_as_instance_test.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +'''Unit tests for QObject's tr and trUtf8 static methods.''' + +import os +import unittest +from PySide.QtCore import QObject + +#from helper import UsesQCoreApplication + +class QObjectTrTest(unittest.TestCase): + '''Test case to check if QObject tr and trUtf8 static methods could be treated as instance methods.''' + + def setUp(self): + self.obj = QObject() + + def tearDown(self): + del self.obj + + def testTrCommonCase(self): + #Test common case for QObject.tr + invar1 = 'test1' + outvar1 = self.obj.tr(invar1) + invar2 = 'test2' + outvar2 = self.obj.tr(invar2, 'test comment') + self.assertEqual((invar1, invar2), (outvar1, outvar2)) + + def testTrAsInstanceMethod(self): + #Test QObject.tr as instance + invar1 = 'test1' + outvar1 = QObject.tr(self.obj, invar1) + invar2 = 'test2' + outvar2 = QObject.tr(self.obj, invar2, 'test comment') + self.assertEqual((invar1, invar2), (outvar1, outvar2)) + + def testTrUtf8CommonCase(self): + #Test common case for QObject.trUtf8 + invar1 = 'test1' + outvar1 = self.obj.trUtf8(invar1) + invar2 = 'test2' + outvar2 = self.obj.trUtf8(invar2, 'test comment') + self.assertEqual((invar1, invar2), (outvar1, outvar2)) + + def testTrUtf8AsInstanceMethod(self): + #Test QObject.trUtf8 as instance + invar1 = 'test1' + outvar1 = QObject.trUtf8(self.obj, invar1) + invar2 = 'test2' + outvar2 = QObject.trUtf8(self.obj, invar2, 'test comment') + self.assertEqual((invar1, invar2), (outvar1, outvar2)) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qpoint_test.py b/tests/QtCore/qpoint_test.py new file mode 100644 index 000000000..dfce76939 --- /dev/null +++ b/tests/QtCore/qpoint_test.py @@ -0,0 +1,21 @@ + +'''Test cases for QPoint and QPointF''' + +import unittest + +from PySide.QtCore import QPoint, QPointF + + +class QPointTest(unittest.TestCase): + + def testQPointCtor(self): + point = QPoint(QPoint(10,20)) + +class QPointFTest(unittest.TestCase): + + def testQPointFCtor(self): + pointf = QPointF(QPoint(10,20)) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qprocess_test.py b/tests/QtCore/qprocess_test.py new file mode 100644 index 000000000..b01c68ba3 --- /dev/null +++ b/tests/QtCore/qprocess_test.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +'''Test cases for QProcess''' + +import unittest +import os + +from PySide.QtCore import * + +class TestQProcess (unittest.TestCase): + def testStartDetached(self): + value, pid = QProcess.startDetached("dir", [], os.getcwd()) + self.assert_(isinstance(value, bool)) + self.assert_(isinstance(pid, long)) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qrect_test.py b/tests/QtCore/qrect_test.py new file mode 100644 index 000000000..3c5f5be05 --- /dev/null +++ b/tests/QtCore/qrect_test.py @@ -0,0 +1,102 @@ +#!/usr/bin/python +'''Test cases for QRect''' + +import unittest + +from PySide.QtCore import QPoint, QRect + +class RectConstructor(unittest.TestCase): + + def testDefault(self): + #QRect() + obj = QRect() + + self.assert_(obj.isNull()) + + def testConstructorQPoint(self): + topLeft = QPoint(3, 0) + bottomRight = QPoint(0, 3) + + rect1 = QRect(topLeft, bottomRight) + rect2 = QRect(topLeft, bottomRight) + + self.assertEqual(rect1, rect2) + +class RectOperator(unittest.TestCase): + '''Test case for QRect operators''' + + def testEqual(self): + '''QRect == QRect + Note: operator == must be working as it's the main check + for correctness''' + rect1 = QRect() + rect2 = QRect() + self.assertEqual(rect1, rect2) + + rect1 = QRect(0, 4, 100, 300) + rect2 = QRect(0, 4, 100, 300) + self.assertEqual(rect1, rect2) + + def testNullRectIntersection(self): + #QRect & QRect for null rects + rect1 = QRect() + rect2 = QRect() + rect3 = rect1 & rect2 + self.assertEqual(rect3, rect1) + self.assertEqual(rect3, rect2) + + def testNoIntersect(self): + '''QRect & QRect for non-intersecting QRects + Non-intersecting QRects return a 'null' QRect for operator &''' + rect1 = QRect(10, 10, 5, 5) + rect2 = QRect(20, 20, 5, 5) + rect3 = rect1 & rect2 + self.assertEqual(rect3, QRect()) + + def testIntersectPartial(self): + #QRect & QRect for partial intersections + rect1 = QRect(10, 10, 10, 10) + rect2 = QRect(15, 15, 10, 10) + rect3 = rect1 & rect2 + self.assertEqual(rect3, QRect(15, 15, 5, 5)) + + def testIntersetEnclosed(self): + #QRect & QRect for a qrect inside another + rect1 = QRect(10, 10, 20, 20) + rect2 = QRect(15, 15, 5, 5) + rect3 = rect1 & rect2 + self.assertEqual(rect3, rect2) + + def testNullRectIntersectBounding(self): + #QRect | QRect for null rects + rect1 = QRect() + rect2 = QRect() + rect3 = rect1 & rect2 + self.assertEqual(rect3, rect1) + self.assertEqual(rect3, rect2) + + def testNoIntersectBounding(self): + '''QRect | QRect for non-intersecting QRects + Non-intersecting QRects return a greater QRect for operator |''' + rect1 = QRect(10, 10, 5, 5) + rect2 = QRect(20, 20, 5, 5) + rect3 = rect1 | rect2 + self.assertEqual(rect3, QRect(10, 10, 15, 15)) + + def testBoundingPartialIntersection(self): + #QRect | QRect for partial intersections + rect1 = QRect(10, 10, 10, 10) + rect2 = QRect(15, 15, 10, 10) + rect3 = rect1 | rect2 + self.assertEqual(rect3, QRect(10, 10, 15, 15)) + + def testBoundingEnclosed(self): + #QRect | QRect for a qrect inside another + rect1 = QRect(10, 10, 20, 20) + rect2 = QRect(15, 15, 5, 5) + rect3 = rect1 | rect2 + self.assertEqual(rect3, rect1) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qresource_test.py b/tests/QtCore/qresource_test.py new file mode 100644 index 000000000..8f3350a60 --- /dev/null +++ b/tests/QtCore/qresource_test.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +'''Test cases for QResource usage''' + +import unittest +import os +from PySide.QtCore import QFile, QIODevice +import resources_mc + +class ResourcesUsage(unittest.TestCase): + '''Test case for resources usage''' + + def setUp(self): + f = open(os.path.join(os.path.dirname(__file__), 'quoteEnUS.txt')) + self.text = f.read() + f.close() + + def tearDown(self): + self.text = None + + def testPhrase(self): + #Test loading of quote.txt resource + f = QFile(':/quote.txt') + f.open(QIODevice.ReadOnly|QIODevice.Text) + content = f.readAll() + f.close() + self.assertEqual(self.text, content) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qsize_test.py b/tests/QtCore/qsize_test.py new file mode 100644 index 000000000..4fb060b74 --- /dev/null +++ b/tests/QtCore/qsize_test.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +'''Unit tests for QSize''' + +import unittest + +from PySide.QtCore import QSize + +class QSizeOperator(unittest.TestCase): + def testOperatorMultiply(self): + #QSize operator * float + # bug 131 + a = QSize(1, 1) + x = a * 3.4 + self.assertEqual(QSize(3, 3), x) + + def testOperatorRevertedMultiply(self): + #QSize operator * float, reverted + # bug 132 + a = QSize(1, 1) + x = 3.4 * a + self.assertEqual(QSize(3, 3), x) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qslot_object_test.py b/tests/QtCore/qslot_object_test.py new file mode 100644 index 000000000..ad0ea3a14 --- /dev/null +++ b/tests/QtCore/qslot_object_test.py @@ -0,0 +1,47 @@ +#!/usr/bin/python +import unittest +from PySide import QtCore + +global qApp + +class objTest(QtCore.QObject): + + def __init__(self, parent=None): + QtCore.QObject.__init__(self, parent) + + self.ok = False + + def slot(self): + global qApp + + self.ok = True + qApp.quit() + + + +class slotTest(unittest.TestCase): + def quit_app(self): + global qApp + + qApp.quit() + + def testBasic(self): + global qApp + timer = QtCore.QTimer() + timer.setInterval(100) + + my_obj = objTest() + my_slot = QtCore.SLOT("slot()") + QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), my_obj, my_slot) + timer.start(100) + + QtCore.QTimer.singleShot(1000, self.quit_app) + qApp.exec_() + + self.assert_(my_obj.ok) + + +if __name__ == '__main__': + global qApp + qApp = QtCore.QCoreApplication([]) + unittest.main() diff --git a/tests/QtCore/qsrand_test.py b/tests/QtCore/qsrand_test.py new file mode 100644 index 000000000..97d0a3b0b --- /dev/null +++ b/tests/QtCore/qsrand_test.py @@ -0,0 +1,16 @@ +import gc +import unittest + +from PySide.QtCore import qsrand + +class OverflowExceptionCollect(unittest.TestCase): + '''Test case for OverflowError exception during garbage collection. See bug #147''' + + def testOverflow(self): + # NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError + self.assertRaises(OverflowError, qsrand, 42415335332353253) + # should not abort if bug #147 is fixed + gc.collect() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qstate_test.py b/tests/QtCore/qstate_test.py new file mode 100644 index 000000000..d7c9a4c44 --- /dev/null +++ b/tests/QtCore/qstate_test.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +import unittest +from PySide.QtCore import QObject, QState, QFinalState, SIGNAL, QCoreApplication, QTimer, QStateMachine, QSignalTransition, QVariant + + +class QStateTest(unittest.TestCase): + def testBasic(self): + app = QCoreApplication([]) + + o = QObject() + o.setProperty("text", QVariant("INdT")) + + machine = QStateMachine() + s1 = QState() + s1.assignProperty(o, "text", QVariant("Rocks")); + + s2 = QFinalState() + t = s1.addTransition(o, SIGNAL("change()"), s2); + self.assert_(isinstance(t, QSignalTransition)) + + machine.addState(s1) + machine.addState(s2) + machine.setInitialState(s1) + machine.start() + + o.emit(SIGNAL("change()")) + + QTimer.singleShot(100, app.quit) + app.exec_() + + txt = o.property("text").toString() + self.assert_(txt, "Rocks") + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qstatemachine_test.py b/tests/QtCore/qstatemachine_test.py new file mode 100644 index 000000000..ce2449d15 --- /dev/null +++ b/tests/QtCore/qstatemachine_test.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +import unittest +from PySide.QtCore import QObject, QState, QFinalState, SIGNAL +from PySide.QtCore import QTimer, QStateMachine +from PySide.QtCore import QParallelAnimationGroup + +from helper import UsesQCoreApplication + + +class StateMachineTest(unittest.TestCase): + '''Check presence of State Machine classes''' + + def testBasic(self): + '''State machine classes''' + import PySide.QtCore + PySide.QtCore.QSignalTransition + PySide.QtCore.QPropertyAnimation + + + +class QStateMachineTest(UsesQCoreApplication): + + def cb(self, *args): + self.assertEqual(self.machine.defaultAnimations(), [self.anim]) + + def testBasic(self): + self.machine = QStateMachine() + s1 = QState() + s2 = QState() + s3 = QFinalState() + + QObject.connect(self.machine, SIGNAL("started()"), self.cb) + + self.anim = QParallelAnimationGroup() + + self.machine.addState(s1) + self.machine.addState(s2) + self.machine.addState(s3) + self.machine.setInitialState(s1) + self.machine.addDefaultAnimation(self.anim) + self.machine.start() + + QTimer.singleShot(100, self.app.quit) + self.app.exec_() + + +class QSetConverterTest(UsesQCoreApplication): + '''Test converter of QSet toPython using QStateAnimation.configuration''' + + def testBasic(self): + '''QStateMachine.configuration converting QSet to python set''' + machine = QStateMachine() + s1 = QState() + machine.addState(s1) + machine.setInitialState(s1) + machine.start() + + QTimer.singleShot(100, self.app.quit) + self.app.exec_() + + configuration = machine.configuration() + + self.assert_(isinstance(configuration, set)) + self.assert_(s1 in configuration) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qstring_buffer_protocol_test.py b/tests/QtCore/qstring_buffer_protocol_test.py new file mode 100755 index 000000000..f8475d093 --- /dev/null +++ b/tests/QtCore/qstring_buffer_protocol_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Tests QString implementation of Python buffer protocol''' + +import unittest + +from os.path import isdir +from PySide.QtCore import QString + +class QStringBufferProtocolTest(unittest.TestCase): + '''Tests QString implementation of Python buffer protocol''' + + def testQStringBufferProtocol(self): + #Tests QString implementation of Python buffer protocol using the os.path.isdir + #function which an unicode object or other object implementing the Python buffer protocol + isdir(QString('/tmp')) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qstring_operator_test.py b/tests/QtCore/qstring_operator_test.py new file mode 100644 index 000000000..6d7ae314d --- /dev/null +++ b/tests/QtCore/qstring_operator_test.py @@ -0,0 +1,161 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QString operators''' + +import unittest + +from PySide.QtCore import QString, QByteArray + +class QStringOperatorEqual(unittest.TestCase): + '''TestCase for operator QString == QString''' + + def testDefault(self): + #QString() == QString() + obj1 = QString() + obj2 = QString() + self.assertEqual(obj1, obj2) + + def testSimple(self): + #QString(some_string) == QString(some_string) + string = 'egg snakes' + self.assertEqual(QString(string), QString(string)) + + def testUnicode(self): + #QString(unicode) == QString(unicode) + string = u'àâãá' + self.assertEqual(QString(string), QString(string)) + + def testPyString(self): + #QString(string) == string + string = 'my test string' + self.assertEqual(QString(string), string) + self.assertEqual(string, QString(string)) + + def testPyUnicodeString(self): + #QString(unicode) == unicode + string = u'àâãá' + self.assertEqual(QString(string), string) + self.assertEqual(string, unicode(QString(string))) + + def testQByteArray(self): + #QString(string) == QByteArray(string) + string = 'another test string' + self.assertEqual(QString(string), QByteArray(string)) + + +class QStringOperatorAtSetter(unittest.TestCase): + '''Test case for operator QString[] - __setitem__''' + + def testSetterString(self): + '''QString[x] = pythonstring''' + obj = QString('123456') + obj[1] = '0' + self.assertEqual(obj, QString('103456')) + + def testSetterStringLarge(self): + '''QString[x] = pythonstring (larget than 1 char)''' + obj = QString('123456') + obj[3] = 'abba' + self.assertEqual(obj, QString('123abba56')) + + def testSetterQString(self): + '''QString[x] = QString''' + obj = QString('123456') + obj[3] = QString('string') + self.assertEqual(obj, QString('123string56')) + + def testSetterQByteArray(self): + '''QString[x] = qbytearray''' + obj = QString('123456') + obj[3] = QByteArray('array') + self.assertEqual(obj, QString('123array56')) + + +class QStringOperatorAtSetterNegativeIndex(unittest.TestCase): + '''Test case for QString[] - __setitem__ - for negative index''' + + def testSetterNegativeIndex(self): + '''QString[x] = string - negative index''' + obj = QString('123456') + obj[-3] = 'array' + self.assertEqual(obj, QString('123array56')) + + +class QStringOperatorAtSetterLargeIndex(unittest.TestCase): + '''Test case for QString[] - __setitem__ - for 'overflown' index''' + + def testSetterLargeIndexEmpty(self): + '''QString[x] = somestring - Overflow index on empty string''' + # should pad with spaces if the index is larger + obj = QString('') + obj[2] = 'a' + self.assertEqual(obj, QString(' a')) + + def testSetterLargeIndexNormal(self): + '''QString[x] = somestring - Overflow index on normal string''' + # should pad with spaces if the index is larger + obj = QString('mystring') + obj[10] = 'normal' + self.assertEqual(obj, QString('mystring normal')) + + +class QStringOperatorAt(unittest.TestCase): + '''TestCase for operator QString[] - __getitem__''' + + def testInRange(self): + #QString[x] where x is a valid index + string = 'abcdefgh' + obj = QString(string) + + for i in range(len(string)): + self.assertEqual(obj[i], string[i]) + + def testInRangeReverse(self): + #QString[x] where x is a valid index (reverse order) + string = 'abcdefgh' + obj = QString(string) + + for i in range(len(string)-1, 0, -1): + self.assertEqual(obj[i], string[i]) + + + def testInRangeUnicode(self): + #QString[x] where x is a valid index (unicode) + string = u'àâãá' + obj = QString(string) + + for i in range(len(string)): + self.assertEqual(obj[i], string[i]) + + def testInRangeUnicodeReverse(self): + #QString[x] where x is a valid index (unicode) (reverse order) + string = u'àâãá' + obj = QString(string) + + for i in range(len(string)-1, 0, -1): + self.assertEqual(obj[i], string[i]) + + def testOutOfRange(self): + #QString[x] where x is out of index + string = '1234567' + obj = QString(string) + self.assertRaises(IndexError, lambda :obj[len(string)]) + + def testReturnQString(self): + #QString[x] must return a QString + string = QString('123456') + data = string[0] + self.assert_(isinstance(data, QString)) + +class QStringOperatorAdd(unittest.TestCase): + '''TestCase for operator QString[]''' + + def testOperatorAdd(self): + str1 = '123' + str2 = QString('456') + self.assertEquals('123456', str1 + str2) + self.assertEquals('456123', str2 + str1) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qstring_test.py b/tests/QtCore/qstring_test.py new file mode 100644 index 000000000..3f0fb4931 --- /dev/null +++ b/tests/QtCore/qstring_test.py @@ -0,0 +1,192 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QString''' + +import unittest +import ctypes +import sys + +from PySide.QtCore import QString, QByteArray, QObject + +class QStringToNumber(unittest.TestCase): + def testReturnValueTypes(self): + obj = QString('37') + val, ok = obj.toInt() + self.assertEqual(type(val), int) + self.assertEqual(type(ok), bool) + + def testToNumberInt(self): + obj = QString('37') + self.assertEqual((37, True), obj.toInt()) + + def testToNumberLong(self): + obj = QString('3700000') + self.assertEqual((3700000, True), obj.toInt()) + + def testToNumberShort(self): + obj = QString('33') + self.assertEqual((ctypes.c_short(33).value, True), obj.toShort()) + + def testToNumberShortNegative(self): + obj = QString('-4') + self.assertEqual((ctypes.c_short(-4).value, True), obj.toShort()) + + def testToNumberShortOverflow(self): + obj = QString('1000000') + self.assertEqual(False, obj.toShort()[1]) + + def testToNumberUInt(self): + obj = QString('33') + self.assertEqual((ctypes.c_uint(33).value, True), obj.toUInt()) + + def testToNumberUIntNegative(self): + obj = QString('-4') + self.assertEqual(False, obj.toUInt()[1]) + + def testToNumberUIntOverflow(self): + obj = QString('10000000000000') + self.assertEqual(False, obj.toUInt()[1]) + + def testToNumberULong(self): + obj = QString('33') + self.assertEqual((ctypes.c_ulong(33).value, True), obj.toULong()) + + def testToNumberULongNegative(self): + obj = QString('-4') + self.assertEqual(False, obj.toULong()[1]) + + def testToNumberUShort(self): + obj = QString('33') + self.assertEqual((ctypes.c_ushort(33).value, True), obj.toUShort()) + + def testToNumberUShortLarge(self): + obj = QString('128') + self.assertEqual((ctypes.c_ushort(128).value, True), obj.toUShort()) + + def testToNumberUShortOverflow(self): + obj = QString('205000') + self.assertEqual(False, obj.toUShort()[1]) + + def testToNumberUShortNegative(self): + obj = QString('-4') + self.assertEqual(False, obj.toUShort()[1]) + + def testToNumberIntUsingHex(self): + obj = QString('2A') + self.assertEquals((0, False), obj.toInt()) + self.assertEqual((int(str(obj), 16), True), obj.toInt(16)) + + def testToNumberIntUsingHex(self): + obj = QString('101010') + self.assertEqual((int(str(obj), 2), True), obj.toInt(2)) + + def testToNumberFloat(self): + obj = QString('37.109') + self.assertEqual(ctypes.c_float(37.109).value, + obj.toFloat()[0]) + + def testToNumberDouble(self): + obj = QString('37.109') + self.assertEqual(ctypes.c_double(37.109).value, + obj.toDouble()[0]) + + def testToULongLong(self): + obj = QString('37109') + self.assertEqual(ctypes.c_ulong(37109).value, + obj.toULongLong()[0]) + +class QStringConstructor(unittest.TestCase): + '''Test case for QString constructors''' + + def testQStringDefault(self): + #QString() + obj1 = QString() + obj2 = QString() + + self.assertEqual(obj1, obj2) + + def testNullQString(self): + s = QString(None) + self.assertTrue(s.isNull()) + + def testQStringFromPy(self): + #QString(const char*) + sample = 'a new string' + obj1 = QString(sample) + obj2 = QString(sample) + self.assertEqual(obj1, obj2) + + def testQStringFromUnicode(self): + sample = u'áâãà' + obj1 = QString(sample) + obj2 = QString(sample) + self.assertEqual(obj1, obj2) + self.assertEqual(obj1, sample) + self.assertEqual(obj2, sample) + + def testQStringFromByteArray(self): + # QByteArray(const char *) must be working + sample = QByteArray('foo') + obj1 = QString(sample) + obj2 = QString(sample) + self.assertEqual(obj1, obj2) + + def testQStringArg(self): + a = QString("%1 %2 %3").arg(1).arg("two").arg(3.14) + self.assertEquals("1 two 3.14", str(a)) + + def testQStringArgNegative(self): + a = QString("%1").arg(-20) + self.assertEquals("-20", str(a)) + + +class QStringComparison(unittest.TestCase): + '''Test case for comparison to python strings''' + + def testComparePyString(self): + #Compare QStrings and Python strings. + py = '' + qstr = QString() + self.assertEqual(py, qstr) + + py = 'The quick brown fox jumps over the lazy dog' + qstr = QString(py) + self.assertEqual(py, qstr) + +class QStringRange(unittest.TestCase): + '''Test case for ranges in python strings''' + + def testSimpleRange(self): + #Test open start and open end intervals + py = 'The quick brown fox jumps over the lazy dog' + qstr = QString(py) + self.assertEqual(py[5:], qstr[5:]) + self.assertEqual(py[:7], qstr[:7]) + +class QStringIndexOf(unittest.TestCase): + def testEmpty(self): + string = QString() + self.assertEqual(string.indexOf(QString("aaa")), -1) + self.assertEqual(string.indexOf(QString()), 0) + + def testString(self): + string = QString("the quick brown fox") + self.assertEqual(string.indexOf("quick", 0), 4) + + +class QStringImplicitConvertion(unittest.TestCase): + '''Implicit conversions for QString''' + + def testQByteArray(self): + '''QString implicitly conversion: QByteArray''' + obj = QObject() + obj.setObjectName(QByteArray('foobar')) + self.assertEqual(obj.objectName(), QString('foobar')) + +class QStringHash(unittest.TestCase): + def testHash(self): + self.assertEqual(hash("key"), hash(QString("key"))) + self.assertEqual(hash(u"aéióu"), hash(QString(u"aéióu"))) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qstringlist_test.py b/tests/QtCore/qstringlist_test.py new file mode 100644 index 000000000..031051684 --- /dev/null +++ b/tests/QtCore/qstringlist_test.py @@ -0,0 +1,171 @@ + +# -*- coding: utf-8 -*- + +'''Test cases for QStringList''' + +import unittest +from random import shuffle + +from PySide.QtCore import QStringList, QString + +from helper import random_string + +class UsesManyStrings(unittest.TestCase): + '''Helper class to setup a list of strings and QStrings''' + def setUp(self): + #Creates a list of strings and python strings + self.size = 10 + # List of Python strings + self.samples = [random_string() for x in range(self.size)] + # List of QStrings + self.strings = map(QString, self.samples) + + self.obj = QStringList(self.strings) + + +class TestConstructorBasic(unittest.TestCase): + '''Basic constructor test''' + + def testEmpty(self): + #QStringList() - default constructor + obj = QStringList() + self.assert_(isinstance(obj, QStringList)) + + def testQString(self): + #QStringList(QString) + qstr = QString('aaaa') + obj = QStringList(qstr) + self.assert_(isinstance(obj, QStringList)) + + def testPyString(self): + #QStringList(python_string) constructor + string = 'forty two' + obj = QStringList(string) + self.assert_(isinstance(obj, QStringList)) + + def testPyStringUnicode(self): + #QStringList(unicode python_string) constructor + string = 'Nação Zumbi' + obj = QStringList(string) + self.assert_(isinstance(obj, QStringList)) + + +class TestConstructorList(UsesManyStrings): + '''Test case for QStringList(List) constructor''' + + def testListQString(self): + #QStringList([QString]) constructor + obj = QStringList(self.strings) + self.assert_(isinstance(obj, QStringList)) + + def testListPyString(self): + #QStringList([python_string]) constructor + obj = QStringList(self.samples) + self.assert_(isinstance(obj, QStringList)) + + def testListMixed(self): + #QStringList([python_string and QString]) mixed constructor + mixed = self.samples + self.strings + shuffle(mixed) + obj = QStringList(mixed) + self.assert_(isinstance(obj, QStringList)) + + def testCopyList(self): + #QStringList(QStringList(list)) - copy constructor + obj = QStringList(self.strings) + obj2 = QStringList(obj) + self.assert_(isinstance(obj2, QStringList)) + self.assertEqual(obj, obj2) + + +class TestComparison(unittest.TestCase): + '''Test case for comparison of QStringLists''' + + def testEqual(self): + #QStringList == QStringList + string = QString('aaaabvbbcccedde') + obj1 = QStringList(string) + obj2 = QStringList(string) + self.assertEqual(obj1, obj2) + + +class TestIndexing(unittest.TestCase): + '''Test case for indexing through []''' + def testInvalidIndexEmpty(self): + #QStringList[x] for empty list + obj = QStringList() + self.assertRaises(IndexError, lambda:obj[0]) + + def testInvalidIndexQString(self): + #QStringList[1] raising IndexError for QStringList(QString) + obj = QStringList(QString('aaaaa')) + self.assertRaises(IndexError, lambda:obj[1]) + + def testValidIndexQString(self): + #QStringList[0] not raising IndexError for QStringList(QString) + string = QString('abcdefg') + obj = QStringList(string) + self.assertEqual(obj[0], string) + + def testNegativeIndexing(self): + #QStringList[-1] not raising IndexError for QStringList(QString) + string = QString('abcdefg') + obj = QStringList(string) + self.assertEqual(obj[-1], string) + + +class TestListIndexing(UsesManyStrings): + '''Test case for indexing QStringList longer than 1 string''' + + def testValid(self): + #QStringList[] for valid indexes + for i in range(self.size): + self.assertEqual(self.strings[i], self.obj[i]) + + def testNegativeValid(self): + #QStringList[] for valid indexes + for i in range(-1, -self.size, -1): + self.assertEqual(self.strings[i], self.obj[i]) + + def testInvalid(self): + #QStringList[] for invalid negative indexes + self.assertRaises(IndexError, lambda : self.obj[self.size]) + self.assertRaises(IndexError, lambda : self.obj[-(self.size+1)]) + + +class TestSlicing(UsesManyStrings): + '''Test case for slicing a QStringList''' + + def testSlicing(self): + #QStringList slicing + for i in range(self.size): + self.assertEqual(self.obj[i:], self.strings[i:]) + self.assertEqual(self.obj[:i], self.strings[:i]) + for j in range(i): + self.assertEqual(self.obj[j:i], self.strings[j:i]) + + for i in range(-1, -self.size, -1): + self.assertEqual(self.obj[:i], self.strings[:i]) + + +class TestShiftOperator(UsesManyStrings): + '''Test case for QStringList lshift operator''' + + def testShiftOperator(self): + #QStringList lshift + a = QStringList() + a << "a" << "b" << "c"; + self.assertEquals(3, a.count()) + b = ["1", "2", "3"] + c = ["4", "5", "6"] + a << b << c + self.assertEquals(9, a.count()) + + def testShiftOperator(self): + #QStringList lshift + a = QStringList() + b = ["1", 2, "3"] + self.assertRaises(TypeError, a.__lshift__, b) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qtext_codec_test.py b/tests/QtCore/qtext_codec_test.py new file mode 100644 index 000000000..2bd7f8139 --- /dev/null +++ b/tests/QtCore/qtext_codec_test.py @@ -0,0 +1,20 @@ +import gc +import unittest + +from PySide.QtCore import QTextCodec + +class TestCodecGetters(unittest.TestCase): + + def testCodecsNames(self): + for codec_name in QTextCodec.availableCodecs(): + codec = QTextCodec.codecForName(codec_name) + self.assert_(type(codec), QTextCodec) + + def testCodecsMibs(self): + for codec_num in QTextCodec.availableMibs(): + codec = QTextCodec.codecForMib(codec_num) + self.assert_(type(codec), QTextCodec) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qtextstream_test.py b/tests/QtCore/qtextstream_test.py new file mode 100644 index 000000000..13dc6516c --- /dev/null +++ b/tests/QtCore/qtextstream_test.py @@ -0,0 +1,95 @@ + +'''Unit tests for QTextStream''' + +import unittest + +from PySide.QtCore import QTextStream, QIODevice, QString, QByteArray +from PySide.QtCore import QTextCodec, QFile + +class QTextStreamShiftTest(unittest.TestCase): + + def setUp(self): + self.ba = QByteArray() + self.read = QTextStream(self.ba, QIODevice.ReadOnly) + self.write = QTextStream(self.ba, QIODevice.WriteOnly) + + def testNumber(self): + '''QTextStream << number''' + + self.write << QString('4') + self.write.flush() + res = self.read.readLine() + self.assert_(isinstance(res, QString)) + self.assertEqual(res, QString('4')) + + def testString(self): + self.write << QString('Test_it!') + self.write.flush() + res = QString() + self.read >> res + self.assertEqual(res, QString('Test_it!')) + +class QTextStreamGetSet(unittest.TestCase): + + def setUp(self): + self.obj = QTextStream() + + + def testCodec(self): + '''QTextStream set/get Codec''' + + codec = QTextCodec.codecForName('ISO8859-1') + self.obj.setCodec(codec) + self.assertEqual(codec, self.obj.codec()) + + def testDevice(self): + '''QTextStream get/set Device''' + device = QFile() + self.obj.setDevice(device) + self.assertEqual(device, self.obj.device()) + self.obj.setDevice(None) + self.assertEqual(None, self.obj.device()) + +class QTextStreamInitialization(unittest.TestCase): + + def testConstruction(self): + '''QTextStream construction''' + obj = QTextStream() + + self.assertEqual(obj.codec(), QTextCodec.codecForLocale()) + self.assertEqual(obj.device(), None) + self.assertEqual(obj.string(), None) + + self.assert_(obj.atEnd()) + self.assertEqual(obj.readAll(), '') + +class QTextStreamReadLinesFromDevice(unittest.TestCase): + + def _check_data(self, data_set): + + for data, lines in data_set: + stream = QTextStream(data) + + res = [] + while not stream.atEnd(): + res.append(stream.readLine()) + + self.assertEqual(res, lines) + + def testLatin1(self): + '''QTextStream readLine for simple Latin1 strings''' + + data = [] + + data.append((QByteArray(), [])) + data.append((QByteArray('\n'), [''])) + data.append((QByteArray('\r\n'), [''])) + data.append((QByteArray('ole'), ['ole'])) + data.append((QByteArray('ole\n'), ['ole'])) + data.append((QByteArray('ole\r\n'), ['ole'])) + data.append((QByteArray('ole\r\ndole\r\ndoffen'), ['ole', 'dole', 'doffen'])) + + self._check_data(data) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qthread_prod_cons_test.py b/tests/QtCore/qthread_prod_cons_test.py new file mode 100644 index 000000000..fc634dd88 --- /dev/null +++ b/tests/QtCore/qthread_prod_cons_test.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +'''Producer-Consumer test/example with QThread''' + +import unittest +from random import random +import logging + +logging.basicConfig(level=logging.WARNING) + +from PySide.QtCore import QThread, QCoreApplication, QObject, SIGNAL + +class Bucket(QObject): + '''Dummy class to hold the produced values''' + def __init__(self, max_size=10, *args): + #Constructor which receives the max number of produced items + super(Bucket, self).__init__(*args) + self.data = [] + self.max_size = 10 + + def pop(self): + #Retrieves an item + return self.data.pop(0) + + def push(self, data): + #Pushes an item + self.data.append(data) + +class Producer(QThread): + '''Producer thread''' + + def __init__(self, bucket, *args): + #Constructor. Receives the bucket + super(Producer, self).__init__(*args) + self.runs = 0 + self.bucket = bucket + self.production_list = [] + + def run(self): + #Produces at most bucket.max_size items + while self.runs < self.bucket.max_size: + value = int(random()*10) % 10 + self.bucket.push(value) + self.production_list.append(value) + logging.debug('PRODUCER - pushed %d' % value) + self.runs += 1 + self.msleep(5) + + + +class Consumer(QThread): + '''Consumer thread''' + def __init__(self, bucket, *args): + #Constructor. Receives the bucket + super(Consumer, self).__init__(*args) + self.runs = 0 + self.bucket = bucket + self.consumption_list = [] + + def run(self): + #Consumes at most bucket.max_size items + while self.runs < self.bucket.max_size: + try: + value = self.bucket.pop() + self.consumption_list.append(value) + logging.debug('CONSUMER - got %d' % value) + self.runs += 1 + except IndexError: + logging.debug('CONSUMER - empty bucket') + self.msleep(5) + +class ProducerConsumer(unittest.TestCase): + '''Basic test case for producer-consumer QThread''' + + def setUp(self): + #Create fixtures + self.app = QCoreApplication([]) + + def tearDown(self): + #Destroy fixtures + del self.app + + def finishCb(self): + #Quits the application + self.app.exit(0) + + def testProdCon(self): + #QThread producer-consumer example + bucket = Bucket() + prod = Producer(bucket) + cons = Consumer(bucket) + + prod.start() + cons.start() + + QObject.connect(prod, SIGNAL('finished()'), self.finishCb) + QObject.connect(cons, SIGNAL('finished()'), self.finishCb) + + self.app.exec_() + + prod.wait() + cons.wait() + + self.assertEqual(prod.production_list, cons.consumption_list) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qthread_signal_test.py b/tests/QtCore/qthread_signal_test.py new file mode 100755 index 000000000..edd7d77f4 --- /dev/null +++ b/tests/QtCore/qthread_signal_test.py @@ -0,0 +1,64 @@ + +'''Test cases for connecting signals between threads''' + +import unittest + +from PySide.QtCore import QThread, QObject, SIGNAL, QCoreApplication + +thread_run = False + +class Source(QObject): + def __init__(self, *args): + QObject.__init__(self, *args) + + def emit_sig(self): + self.emit(SIGNAL('source()')) + +class Target(QObject): + def __init__(self, *args): + QObject.__init__(self, *args) + self.called = False + + def myslot(self): + self.called = True + +class ThreadJustConnects(QThread): + def __init__(self, source, *args): + QThread.__init__(self, *args) + self.source = source + self.target = Target() + + def run(self): + global thread_run + thread_run = True + QObject.connect(self.source, SIGNAL('source()'), self.target.myslot) + + while not self.target.called: + pass + + + +class BasicConnection(unittest.TestCase): + + def testEmitOutsideThread(self): + global thread_run + + app = QCoreApplication([]) + source = Source() + thread = ThreadJustConnects(source) + + QObject.connect(thread, SIGNAL('finished()'), lambda: app.exit(0)) + thread.start() + + while not thread_run: + pass + + source.emit_sig() + + app.exec_() + thread.wait() + + self.assert_(thread.target.called) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qthread_test.py b/tests/QtCore/qthread_test.py new file mode 100644 index 000000000..410afb908 --- /dev/null +++ b/tests/QtCore/qthread_test.py @@ -0,0 +1,76 @@ +#!/usr/bin/python +'''Test cases for QThread''' + +import unittest +from PySide.QtCore import QThread, QCoreApplication, QObject, SIGNAL, QMutex, QTimer +from PySide.QtCore import QEventLoop + +from helper import UsesQCoreApplication + +mutex = QMutex() + +class Dummy(QThread): + '''Dummy thread''' + def __init__(self, *args): + super(Dummy, self).__init__(*args) + self.called = False + + def run(self): + #Start-quit sequence + mutex.lock() + self.called = True + mutex.unlock() + +class QThreadSimpleCase(UsesQCoreApplication): + + def setUp(self): + UsesQCoreApplication.setUp(self) + self.called = False + + def tearDown(self): + UsesQCoreApplication.tearDown(self) + + def testThread(self): + #Basic QThread test + obj = Dummy() + obj.start() + obj.wait() + + self.assert_(obj.called) + + def cb(self, *args): + self.called = True + #self.exit_app_cb() + + def abort_application(self): + self._thread.terminate() + self.app.quit() + + def testSignalFinished(self): + #QThread.finished() (signal) + obj = Dummy() + QObject.connect(obj, SIGNAL('finished()'), self.cb) + mutex.lock() + obj.start() + mutex.unlock() + + self._thread = obj + QTimer.singleShot(1000, self.abort_application) + self.app.exec_() + + self.assert_(self.called) + + def testSignalStarted(self): + #QThread.started() (signal) + obj = Dummy() + QObject.connect(obj, SIGNAL('started()'), self.cb) + obj.start() + + self._thread = obj + QTimer.singleShot(1000, self.abort_application) + self.app.exec_() + + self.assert_(self.called) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qtimer_singleshot_test.py b/tests/QtCore/qtimer_singleshot_test.py new file mode 100644 index 000000000..96107ecce --- /dev/null +++ b/tests/QtCore/qtimer_singleshot_test.py @@ -0,0 +1,49 @@ +#!/usr/bin/python + +'''Test cases for QTimer.singleShot''' + +import unittest + +from PySide.QtCore import QObject, QTimer, QCoreApplication, SIGNAL +from helper import UsesQCoreApplication + +class WatchDog(QObject): + '''Exits the QCoreApplication main loop after sometime.''' + + def __init__(self, watched): + QObject.__init__(self) + self.times_called = 0 + self.watched = watched + + def timerEvent(self, evt): + self.times_called += 1 + if self.times_called == 20: + self.watched.exit_app_cb() + +class TestSingleShot(UsesQCoreApplication): + '''Test case for QTimer.singleShot''' + + def setUp(self): + #Acquire resources + UsesQCoreApplication.setUp(self) + self.watchdog = WatchDog(self) + self.called = False + + def tearDown(self): + #Release resources + del self.watchdog + del self.called + UsesQCoreApplication.tearDown(self) + + def callback(self): + self.called = True + self.app.quit() + + def testSingleShot(self): + timer = QTimer.singleShot(100, self.callback) + self.app.exec_() + self.assert_(self.called) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qtimer_timeout_test.py b/tests/QtCore/qtimer_timeout_test.py new file mode 100644 index 000000000..8dfe39529 --- /dev/null +++ b/tests/QtCore/qtimer_timeout_test.py @@ -0,0 +1,57 @@ + +'''Test case for timeout() signals from QTimer object.''' + +import unittest +import os +from tempfile import mkstemp +from PySide.QtCore import QObject, QTimer, SIGNAL +from helper import UsesQCoreApplication + +class WatchDog(QObject): + '''Exits the QCoreApplication main loop after sometime.''' + + def __init__(self, watched): + QObject.__init__(self) + self.times_called = 0 + self.watched = watched + + def timerEvent(self, evt): + self.times_called += 1 + if self.times_called == 20: + self.watched.exit_app_cb() + + +class TestTimeoutSignal(UsesQCoreApplication): + '''Test case to check if the signals are really being caught''' + + def setUp(self): + #Acquire resources + UsesQCoreApplication.setUp(self) + self.watchdog = WatchDog(self) + self.timer = QTimer() + self.called = False + + def tearDown(self): + #Release resources + del self.watchdog + del self.timer + del self.called + UsesQCoreApplication.tearDown(self) + + def callback(self, *args): + #Default callback + self.called = True + + def testTimeoutSignal(self): + #Test the QTimer timeout() signal + QObject.connect(self.timer, SIGNAL('timeout()'), self.callback) + self.timer.start(4) + self.watchdog.startTimer(10) + + self.app.exec_() + + self.assert_(self.called) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/qtnamespace_test.py b/tests/QtCore/qtnamespace_test.py new file mode 100644 index 000000000..3343a276b --- /dev/null +++ b/tests/QtCore/qtnamespace_test.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +'''Test suite for QtCore.Qt namespace''' + +import unittest + +from PySide.QtCore import Qt + +class QtNamespace(unittest.TestCase): + '''Test case for accessing attributes from Qt namespace''' + + def testBasic(self): + #Access to Qt namespace + getattr(Qt, 'Horizontal') + getattr(Qt, 'WindowMaximizeButtonHint') + self.assert_(True) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/quoteEnUS.txt b/tests/QtCore/quoteEnUS.txt new file mode 100644 index 000000000..909b4fa17 --- /dev/null +++ b/tests/QtCore/quoteEnUS.txt @@ -0,0 +1 @@ +Fine! Dishonor! Dishonor on you, dishonor on ya cow! diff --git a/tests/QtCore/qurl_test.py b/tests/QtCore/qurl_test.py new file mode 100644 index 000000000..14243a11a --- /dev/null +++ b/tests/QtCore/qurl_test.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +'''Test suite for QtCore.QUrl''' + +import unittest + +from PySide.QtCore import QUrl + +class QUrlBasicConstructor(unittest.TestCase): + '''Tests the basic constructors''' + + def testBasic(self): + #Default constructor for QUrl + url = QUrl() + self.assertEqual(url.toString(), "") + + def testSetAttributes(self): + #Construct QUrl by set* methods + url = QUrl() + + url.setScheme('ftp') + self.assertEqual(url.toString(), 'ftp:') + + url.setHost('www.google.com') + self.assertEqual(url.toString(), 'ftp://www.google.com') + + url.setPort(8080) + self.assertEqual(url.toString(), 'ftp://www.google.com:8080') + + url.setPath('mail/view') + self.assertEqual(url.toString(), + 'ftp://www.google.com:8080/mail/view') + + url.setUserName('john') + self.assertEqual(url.toString(), + 'ftp://john@www.google.com:8080/mail/view') + + url.setPassword('abc123') + self.assertEqual(url.toString(), + 'ftp://john:abc123@www.google.com:8080/mail/view') + +class QueryItemsTest(unittest.TestCase): + '''Test query item management''' + + def testQueryItems(self): + #QUrl.queryItems + url = QUrl('http://www.google.com/search?q=python&hl=en') + valid_data = [(('q'), ('python')), (('hl'), ('en'))] + + self.assertEqual(sorted(url.queryItems()), sorted(valid_data)) + + def testEncodedQueryItems(self): + #QUrl.encodedQueryItems + url = QUrl('http://www.google.com/search?q=python&hl=en') + valid_data = [(('q'), ('python')), (('hl'), ('en'))] + + self.assertEqual(sorted(url.encodedQueryItems()), sorted(valid_data)) + + def testSetQueryItems(self): + #QUrl.setQueryItems + urla = QUrl('http://www.google.com/search?q=python&hl=en') + urlb = QUrl('http://www.google.com/search') + + urlb.setQueryItems(urla.queryItems()) + + self.assertEqual(urla, urlb) + + def testAddQueryItem(self): + #QUrl.addQueryItem + url = QUrl() + valid_data = [('hl', 'en'), ('user', 'konqui')] + + url.addQueryItem(*valid_data[0]) + self.assertEqual(url.queryItems()[0], valid_data[0]) + + url.addQueryItem(*valid_data[1]) + self.assertEqual(sorted(url.queryItems()), sorted(valid_data)) + + def testAllEncodedQueryItemsValues(self): + #QUrl.allEncodedQueryItemValues + url = QUrl() + key = 'key' + valid_data = ['data', 'valid', 'test'] + + for i, data in enumerate(valid_data): + url.addQueryItem(key, data) + self.assertEqual(url.allEncodedQueryItemValues(key), + list(valid_data[:i+1])) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qvariant_pyobject_test.py b/tests/QtCore/qvariant_pyobject_test.py new file mode 100644 index 000000000..82da5556f --- /dev/null +++ b/tests/QtCore/qvariant_pyobject_test.py @@ -0,0 +1,71 @@ + +'''QVariant handling of PyObjects, including pure-python or derived from Qt''' + +import unittest + +from PySide.QtCore import QSize, QVariant, QString + + +class Dummy(object): + '''Pure python sample class''' + pass + + +class MySize(QSize): + '''Extended class''' + pass + + +class QVariantPurePython(unittest.TestCase): + '''QVariant + pure python classes''' + + def testTypeNamePythonClasses(self): + '''QVariant of pure python classes''' + d = Dummy() + obj = QVariant(d) + # inherited type name from other binding + self.assertEqual('PyQt_PyObject', obj.typeName()) + + +class QVariantInheritedPython(unittest.TestCase): + '''QVariant + classes inherited from C++''' + + # This works only on PyQt4 4.5.x, not on PyQt4 4.4.x or PySide + def testSubClassConvertion(self): + '''QVariant(QSize subclass) type is UserType and returns same object''' + mysize = MySize(0, 0) + variant = QVariant(mysize) + + self.assertEqual(variant.type(), QVariant.UserType) + self.assertTrue(variant.toPyObject() is mysize) + + +class QVariantToPyObject(unittest.TestCase): + '''QVariant.toPyObject tests''' + + def testQVariantPyList(self): + '''QVariant(QVariantList).toPyObject() equals original list''' + obj = QVariant([1, 'two', 3]) + self.assertEqual(obj.toPyObject(), [1, 'two', 3]) + + def testPyObject(self): + '''QVariant(pure PyObject).toPyObject should return the same object''' + d = Dummy() + obj = QVariant(d) + self.assert_(d is obj.toPyObject()) + + def testNoneToPyObject(self): + '''QVariant().toPyObject() should return None''' + obj = QVariant() + self.assertEqual(None, obj.toPyObject()) + + def testQStringToPyObject(self): + '''QVariant(python string).toPyObject() return an equal QString''' + d = 'abc' + obj = QVariant('abc') + self.assert_(isinstance(obj.toPyObject(), QString)) + self.assertEqual(d, obj.toPyObject()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/qvariant_test.py b/tests/QtCore/qvariant_test.py new file mode 100644 index 000000000..5c23b4049 --- /dev/null +++ b/tests/QtCore/qvariant_test.py @@ -0,0 +1,141 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QVariant''' + +import unittest +import sys + +from PySide.QtCore import QSize, QVariant, QByteArray, QStringList, QString + + +class QVariantToNumber(unittest.TestCase): + '''QVariant of number types''' + + def testToNumberInt(self): + '''QVariant(int).toInt()''' + obj = QVariant('37') + self.assertEqual((37, True), obj.toInt()) + + def testToNumberLongLong(self): + '''QVariant(int).toLongLong()''' + obj = QVariant('37') + self.assertEqual((37, True), obj.toLongLong()) + + def testToNumberUInt(self): + '''QVariant(int).toUInt()''' + obj = QVariant('37') + self.assertEqual((37, True), obj.toUInt()) + + def testToNumberUIntNegative(self): + '''QVariant(negative int).toUInt()''' + obj = QVariant('-37') + self.assert_(not obj.toUInt()[1]) + + def testToNumberULongLong(self): + '''QVariant(int).toULongLong()''' + obj = QVariant('37') + self.assertEqual((37, True), obj.toULongLong()) + + def testToNumberULongLongNegative(self): + '''QVariant(negative int).toULongLong()''' + obj = QVariant('-37') + self.assert_(not obj.toULongLong()[1]) + + def testToNumberFloat(self): + '''QVariant(double).toFloat()''' + obj = QVariant('37.109') + self.assertEqual((37.109, True), obj.toDouble()) + + +class QVariantTypeName(unittest.TestCase): + '''QVariant.typeName()''' + + def testTypeNameQString(self): + '''QVariant(QString).typeName()''' + obj = QVariant(QString('aaaa')) + self.assertEqual('QString', obj.typeName()) + + def testTypeNameString(self): + '''QVariant(PyString).typeName()''' + obj = QVariant('aaaa') + self.assertEqual('QString', obj.typeName()) + + def testTypeNameInt(self): + '''QVariant(int).typeName()''' + obj = QVariant(34) + self.assertEqual('int', obj.typeName()) + + def testTypeNameDouble(self): + '''QVariant(double).typeName()''' + obj = QVariant(3.14) + self.assertEqual('double', obj.typeName()) + + def testTypeNameBool(self): + '''QVariant(bool).typeName()''' + obj = QVariant(True) + self.assertEqual('bool', obj.typeName()) + + def testTypeNameQByteArray(self): + '''QVariant(QByteArray).typeName()''' + obj = QVariant(QByteArray('aaaa')) + self.assertEqual('QByteArray', obj.typeName()) + + def testTypeNameNone(self): + '''QVariant().typeName()''' + obj = QVariant() + self.assertEqual(None, obj.typeName()) + + def testTypeNameQVariantList(self): + '''QVariant(QVariantList).typeName()''' + obj = QVariant([1, 2, 3, 4]) + self.assertEqual('QVariantList', obj.typeName()) + + obj = QVariant([1.0, 2.2, 3.3, 4.2]) + self.assertEqual('QVariantList', obj.typeName()) + + obj = QVariant(['aaa', 'bbb', 'ccc', 'dddd']) + self.assertEqual('QVariantList', obj.typeName()) + + obj = QVariant([QString('aaa'), QString('bbb'), + QString('ccc'), QString('dddd')]) + self.assertEqual('QVariantList', obj.typeName()) + + def testTypeNameQStringList(self): + '''QVariant(QStringList).typeName()''' + obj = QVariant(QStringList()) + self.assertEqual('QStringList', obj.typeName()) + obj = QVariant(QStringList(['aaa', 'bbb', 'ccc'])) + self.assertEqual('QStringList', obj.typeName()) + + +class QVariantConstructor(unittest.TestCase): + '''More qvariant constructions''' + + def testCopyConstructor(self): + '''QVariant copy constructor''' + obj = QVariant(1) + cpy = QVariant(obj) + + self.assertEqual(obj.type(), cpy.type()) + + def testQStringConstructor(self): + '''QVariant(PyString).type == QVariant.string''' + obj = QVariant("PySide") + self.assertEqual(obj.type(), QVariant.String) + + def testQSizeConstructor(self): + '''QVariant(QSize).type == QVariant.Size''' + mysize = QSize(0, 0) + variant = QVariant(mysize) + + self.assertEqual(variant.type(), QVariant.Size) + self.assertEqual(variant.toSize(), mysize) + + def testToList(self): + v = QVariant((1,2,3)) + self.assertEqual(v.toList(), (1, 2, 3)) + v = QVariant([0,1,2]) + self.assertEqual(v.toList(), [0, 1, 2]) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/resources.qrc b/tests/QtCore/resources.qrc new file mode 100644 index 000000000..cea17b440 --- /dev/null +++ b/tests/QtCore/resources.qrc @@ -0,0 +1,6 @@ + + + quoteEnUS.txt + + + diff --git a/tests/QtCore/resources_mc.py b/tests/QtCore/resources_mc.py new file mode 100644 index 000000000..132c8db12 --- /dev/null +++ b/tests/QtCore/resources_mc.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +# Resource object code +# +# Created: Thu Mar 26 11:08:45 2009 +# by: The Resource Compiler for PyQt (Qt v4.5.0) +# +# WARNING! All changes made in this file will be lost! + +from PySide import QtCore + +qt_resource_data = "\ +\x00\x00\x00\x35\ +\x46\ +\x69\x6e\x65\x21\x20\x44\x69\x73\x68\x6f\x6e\x6f\x72\x21\x20\x44\ +\x69\x73\x68\x6f\x6e\x6f\x72\x20\x6f\x6e\x20\x79\x6f\x75\x2c\x20\ +\x64\x69\x73\x68\x6f\x6e\x6f\x72\x20\x6f\x6e\x20\x79\x61\x20\x63\ +\x6f\x77\x21\x0a\ +" + +qt_resource_name = "\ +\x00\x09\ +\x06\xa8\xaa\x74\ +\x00\x71\ +\x00\x75\x00\x6f\x00\x74\x00\x65\x00\x2e\x00\x74\x00\x78\x00\x74\ +" + +qt_resource_struct = "\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +" + +def qInitResources(): + QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/tests/QtCore/static_method_test.py b/tests/QtCore/static_method_test.py new file mode 100755 index 000000000..1f9de78f7 --- /dev/null +++ b/tests/QtCore/static_method_test.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +'''Test cases for overloads involving static and non-static versions of a method.''' + +import os +import unittest + +from PySide.QtCore import QFile + +class StaticNonStaticMethodsTest(unittest.TestCase): + '''Test cases for overloads involving static and non-static versions of a method.''' + + def setUp(self): + filename = 'somefile%d.txt' % os.getpid() + self.existing_filename = os.path.join(os.path.curdir, filename) + self.delete_file = False + if not os.path.exists(self.existing_filename): + f = open(self.existing_filename, 'w') + for line in range(10): + f.write('sbrubbles\n') + f.close() + self.delete_file = True + + self.non_existing_filename = os.path.join(os.path.curdir, 'inexistingfile.txt') + i = 0 + while os.path.exists(self.non_existing_filename): + i += 1 + filename = 'inexistingfile-%d.txt' % i + self.non_existing_filename = os.path.join(os.path.curdir, filename) + + def tearDown(self): + if self.delete_file: + os.remove(self.existing_filename) + + def testCallingStaticMethodWithClass(self): + '''Call static method using class.''' + self.assert_(QFile.exists(self.existing_filename)) + self.assertFalse(QFile.exists(self.non_existing_filename)) + + def testCallingStaticMethodWithInstance(self): + '''Call static method using instance of class.''' + f = QFile(self.non_existing_filename) + self.assert_(f.exists(self.existing_filename)) + self.assertFalse(f.exists(self.non_existing_filename)) + + def testCallingInstanceMethod(self): + '''Call instance method.''' + f1 = QFile(self.non_existing_filename) + self.assertFalse(f1.exists()) + f2 = QFile(self.existing_filename) + self.assert_(f2.exists()) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/static_protected_methods_test.py b/tests/QtCore/static_protected_methods_test.py new file mode 100644 index 000000000..9d920a438 --- /dev/null +++ b/tests/QtCore/static_protected_methods_test.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +'''Unit tests for static protected methods''' + +import unittest, time + +from PySide.QtCore import QThread + +class Test (QThread): + def run(self): + start = time.time() + self.sleep(1) + self.time_elapsed = time.time() - start + +class QStaticProtectedCall(unittest.TestCase): + '''Test case for static protected method call''' + + def setUp(self): + pass + + def tearDown(self): + pass + + def testPathSeparator(self): + thread = Test() + thread.start() + thread.wait() + self.assertTrue(thread.time_elapsed <= 1.1) # tolarance of 100ms + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/thread_signals.py b/tests/QtCore/thread_signals.py new file mode 100644 index 000000000..9eea82907 --- /dev/null +++ b/tests/QtCore/thread_signals.py @@ -0,0 +1,33 @@ + +''' Test case for QObject.signalsBlocked() and blockSignal()''' + +import unittest +import os +from tempfile import mkstemp + +from PySide.QtCore import QObject, SIGNAL, QFile, QThread, QTimer, Qt +from helper import UsesQCoreApplication + +class MyThread(QThread): + + def run(self): + self.emit(SIGNAL("test(const QString&)"), "INdT - PySide"); + +class TestThreadSignal(UsesQCoreApplication): + + __called__ = True + def _callback(self, msg): + self.assertEqual(msg, "INdT - PySide") + self.__called__ = True + self.app.quit() + + def testThread(self): + t = MyThread() + QObject.connect(t, SIGNAL("test(const QString&)"), self._callback); + t.start() + + self.app.exec_() + self.assert_(self.__called__); + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtCore/translation_test.py b/tests/QtCore/translation_test.py new file mode 100644 index 000000000..870c8c50f --- /dev/null +++ b/tests/QtCore/translation_test.py @@ -0,0 +1,62 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +'''Unit tests to test QTranslator and translation in general.''' + +import os +import unittest +from PySide.QtCore import QObject, QTranslator, QCoreApplication, QString + +from helper import UsesQCoreApplication + +class TranslationTest(UsesQCoreApplication): + '''Test case for Qt translation facilities.''' + + def setUp(self): + super(TranslationTest, self).setUp() + self.trdir = os.path.join(os.path.dirname(__file__), 'translations') + # os.system is probably not the best way to do it + os.system('lrelease %s/*.ts > /dev/null' % self.trdir) + + def tearDown(self): + os.system('rm %s/*.qm > /dev/null' % self.trdir) + super(TranslationTest, self).tearDown() + + def testLatin(self): + #Set string value to Latin + translator = QTranslator() + translator.load(os.path.join(self.trdir, 'trans_latin.qm')) + self.app.installTranslator(translator) + + obj = QObject() + obj.setObjectName(obj.tr('Hello World!')) + self.assertEqual(obj.objectName(), u'Orbis, te saluto!') + + def testRussian(self): + #Set string value to Russian + translator = QTranslator() + translator.load(os.path.join(self.trdir, 'trans_russian.qm')) + self.app.installTranslator(translator) + + obj = QObject() + obj.setObjectName(obj.tr('Hello World!')) + self.assertEqual(obj.objectName(), u'привет мир!') + + def testUtf8(self): + translator = QTranslator() + translator.load(os.path.join(self.trdir, 'trans_russian.qm')) + self.app.installTranslator(translator) + + obj = QObject() + obj.setObjectName(obj.trUtf8('Hello World!')) + self.assertEqual(obj.objectName(), u'привет мир!') + + def testTranslateWithNoneDisambiguation(self): + value = 'String here' + obj = QCoreApplication.translate('context', value, None, QCoreApplication.UnicodeUTF8) + self.assert_(isinstance(obj, QString)) + self.assertEqual(obj, value) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/translations/trans_latin.ts b/tests/QtCore/translations/trans_latin.ts new file mode 100644 index 000000000..b9fcf41be --- /dev/null +++ b/tests/QtCore/translations/trans_latin.ts @@ -0,0 +1,11 @@ + + + + + QObject + + Hello World! + Orbis, te saluto! + + + diff --git a/tests/QtCore/translations/trans_russian.ts b/tests/QtCore/translations/trans_russian.ts new file mode 100644 index 000000000..d1ba49bd2 --- /dev/null +++ b/tests/QtCore/translations/trans_russian.ts @@ -0,0 +1,11 @@ + + + + + QObject + + Hello World! + привет мир! + + + diff --git a/tests/QtCore/unaryoperator_test.py b/tests/QtCore/unaryoperator_test.py new file mode 100755 index 000000000..94db1feec --- /dev/null +++ b/tests/QtCore/unaryoperator_test.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +'''Tests the presence of unary operator __neg__ on the QPoint class''' + +import unittest + +from PySide.QtCore import QPoint + +class NegUnaryOperatorTest(unittest.TestCase): + '''Tests the presence of unary operator __neg__ on the QPoint class''' + + def setUp(self): + #Acquire resources + self.x, self.y = 10, 20 + self.neg_x, self.neg_y = -self.x, -self.y + self.qpoint = QPoint(self.x, self.y) + + def tearDown(self): + #Release resources + del self.qpoint + del self.x + del self.y + del self.neg_x + del self.neg_y + + def testNegUnaryOperator(self): + #Test __neg__ unary operator on QPoint class + __neg__method_exists = True + try: + neg_qpoint = -self.qpoint + except: + __neg__method_exists = False + + self.assertTrue(__neg__method_exists) + self.assertEqual(self.qpoint, -neg_qpoint) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtCore/unicode_test.py b/tests/QtCore/unicode_test.py new file mode 100644 index 000000000..f0bb883ed --- /dev/null +++ b/tests/QtCore/unicode_test.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +'''Unit tests for QString conversion to/from Python Unicode''' + +import unittest + +from PySide.QtCore import QObject + +class UnicodeConversion(unittest.TestCase): + '''Test case for QString to/from Python Unicode conversion''' + + def setUp(self): + pass + + def tearDown(self): + pass + + def testSetRegularStringRetrieveUnicode(self): + #Set regular Python string retrieve unicode + obj = QObject() + obj.setObjectName('test') + self.assertEqual(obj.objectName(), u'test') + + def testSetUnicodeRetrieveUnicode(self): + #Set Python unicode string and retrieve unicode + obj = QObject() + obj.setObjectName(u'ümlaut') + self.assertEqual(obj.objectName(), u'ümlaut') + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt new file mode 100644 index 000000000..4896010bd --- /dev/null +++ b/tests/QtDeclarative/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(qdeclarativenetwork_test.py FALSE) +PYSIDE_TEST(qdeclarativeview_test.py FALSE) diff --git a/tests/QtDeclarative/network.qml b/tests/QtDeclarative/network.qml new file mode 100644 index 000000000..4b849e071 --- /dev/null +++ b/tests/QtDeclarative/network.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +Image { + width: 100 + height: 100 + source: "http://qt.nokia.com/logo.png" +} diff --git a/tests/QtDeclarative/qdeclarativenetwork_test.py b/tests/QtDeclarative/qdeclarativenetwork_test.py new file mode 100644 index 000000000..a03a484a0 --- /dev/null +++ b/tests/QtDeclarative/qdeclarativenetwork_test.py @@ -0,0 +1,35 @@ +'''Test cases for QDeclarativeNetwork''' + +import unittest + +from PySide.QtCore import QUrl +from PySide.QtDeclarative import QDeclarativeView, QDeclarativeNetworkAccessManagerFactory +from PySide.QtNetwork import QNetworkAccessManager + +from helper import adjust_filename, TimedQApplication + +class MyNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory): + def create(self, parent): + nam = QNetworkAccessManager(parent) + return nam + +class TestQDeclarativeNetworkFactory(TimedQApplication): + + def setUp(self): + TimedQApplication.setUp(self, timeout=1000) + + def testQDeclarativeNetworkFactory(self): + view = QDeclarativeView() + + url = QUrl.fromLocalFile(adjust_filename('network.qml', __file__)) + + view.engine().setNetworkAccessManagerFactory(MyNetworkAccessManagerFactory()) + view.setSource(url) + view.show() + + self.assertEqual(view.status(), QDeclarativeView.Ready) + + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtDeclarative/qdeclarativeview_test.py b/tests/QtDeclarative/qdeclarativeview_test.py new file mode 100644 index 000000000..8101c5f01 --- /dev/null +++ b/tests/QtDeclarative/qdeclarativeview_test.py @@ -0,0 +1,31 @@ +'''Test cases for QDeclarativeView''' + +import unittest + +from PySide.QtCore import QUrl, QStringList, QVariant +from PySide.QtGui import QPushButton +from PySide.QtDeclarative import QDeclarativeView + +from helper import adjust_filename, TimedQApplication + + +class TestQDeclarativeView(TimedQApplication): + + def testQDeclarativeViewList(self): + view = QDeclarativeView() + + dataList = QStringList(["Item 1", "Item 2", "Item 3", "Item 4"]) + + ctxt = view.rootContext() + ctxt.setContextProperty("myModel", dataList) + + url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__)) + view.setSource(url) + view.show() + + self.assertEqual(view.status(), QDeclarativeView.Ready) + + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtDeclarative/view.qml b/tests/QtDeclarative/view.qml new file mode 100644 index 000000000..ec5597df7 --- /dev/null +++ b/tests/QtDeclarative/view.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + Text { text: modelData } + } + } +} diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt new file mode 100644 index 000000000..fb6d8015b --- /dev/null +++ b/tests/QtGui/CMakeLists.txt @@ -0,0 +1,58 @@ +PYSIDE_TEST(add_action_test.py) +PYSIDE_TEST(customproxywidget_test.py) +PYSIDE_TEST(float_to_int_implicit_conversion_test.py) +PYSIDE_TEST(grandparent_method_test.py) +PYSIDE_TEST(hashabletype_test.py) +PYSIDE_TEST(keep_reference_test.py) +PYSIDE_TEST(missing_symbols_test.py) +PYSIDE_TEST(paint_event_test.py) +PYSIDE_TEST(parent_method_test.py) +PYSIDE_TEST(python_properties_test.py) +PYSIDE_TEST(qapplication_exit_segfault_test.py) +PYSIDE_TEST(qapplication_singleton_test.py) +PYSIDE_TEST(qapp_test.py) +PYSIDE_TEST(qbrush_test.py) +PYSIDE_TEST(qcolor_test.py) +PYSIDE_TEST(qdatastream_gui_operators_test.py) +PYSIDE_TEST(qfontdialog_test.py) +PYSIDE_TEST(qfontmetrics_test.py) +PYSIDE_TEST(qgraphicsitem_isblocked_test.py) +PYSIDE_TEST(qgraphicsitem_test.py) +PYSIDE_TEST(qgraphicsproxywidget_test.py) +PYSIDE_TEST(qgraphicsscene_test.py) +PYSIDE_TEST(qinputdialog_get_test.py) +PYSIDE_TEST(qitemselection_test.py) +PYSIDE_TEST(qlayout_ref_test.py) +PYSIDE_TEST(qlayout_test.py) +PYSIDE_TEST(qlcdnumber_test.py) +PYSIDE_TEST(qlistwidgetitem_test.py) +PYSIDE_TEST(qmainwindow_test.py) +PYSIDE_TEST(qmatrix_test.py) +PYSIDE_TEST(qmenuadd_test.py) +PYSIDE_TEST(qmenu_test.py) +PYSIDE_TEST(qobject_mi_test.py) +PYSIDE_TEST(qpainter_test.py) +PYSIDE_TEST(qpen_test.py) +PYSIDE_TEST(qpixmap_test.py) +PYSIDE_TEST(qpushbutton_test.py) +PYSIDE_TEST(qradialgradient_test.py) +PYSIDE_TEST(qregion_test.py) +PYSIDE_TEST(qshortcut_test.py) +PYSIDE_TEST(qstandarditemmodel_test.py) +PYSIDE_TEST(qstring_qkeysequence_test.py) +PYSIDE_TEST(qstyle_test.py) +PYSIDE_TEST(qtableview_test.py) +PYSIDE_TEST(qtabwidget_test.py) +PYSIDE_TEST(qtextedit_test.py) +PYSIDE_TEST(qtoolbar_test.py) +PYSIDE_TEST(qtoolbox_test.py) +PYSIDE_TEST(qvariant_test.py) +PYSIDE_TEST(qwidget_setlayout_test.py) +PYSIDE_TEST(qwidget_test.py TRUE) #Bug 237 +PYSIDE_TEST(reference_count_test.py) +PYSIDE_TEST(standardpixmap_test.py) +PYSIDE_TEST(timed_app_test.py) +PYSIDE_TEST(virtual_protected_inheritance_test.py) +PYSIDE_TEST(virtual_pure_override.py) +PYSIDE_TEST(wrong_return_test.py) +PYSIDE_TEST(x11_symbols.py) diff --git a/tests/QtGui/add_action_test.py b/tests/QtGui/add_action_test.py new file mode 100644 index 000000000..7e20c459d --- /dev/null +++ b/tests/QtGui/add_action_test.py @@ -0,0 +1,44 @@ + +'''Tests for QMenuBar.addAction(identifier, callback) calls''' + +import unittest + +from PySide.QtCore import SLOT +from PySide.QtGui import QMenuBar, QAction, QPushButton + +from helper import UsesQApplication + + +class AddActionTest(UsesQApplication): + '''QMenuBar addAction''' + + def tearDown(self): + try: + del self.called + except AttributeError: + pass + super(AddActionTest, self).tearDown() + + def _callback(self): + self.called = True + + def testBasic(self): + '''QMenuBar.addAction(id, callback)''' + menubar = QMenuBar() + action = menubar.addAction("Accounts", self._callback) + action.activate(QAction.Trigger) + self.assert_(self.called) + + def testWithCppSlot(self): + '''QMenuBar.addAction(id, object, slot)''' + menubar = QMenuBar() + widget = QPushButton() + widget.setCheckable(True) + widget.setChecked(False) + action = menubar.addAction("Accounts", widget, SLOT("toggle()")) + action.activate(QAction.Trigger) + self.assert_(widget.isChecked()) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/customproxywidget_test.py b/tests/QtGui/customproxywidget_test.py new file mode 100755 index 000000000..b9ccdff7a --- /dev/null +++ b/tests/QtGui/customproxywidget_test.py @@ -0,0 +1,33 @@ +import unittest + +from helper import UsesQApplication +from PySide.QtCore import Qt, QTimer +from PySide.QtGui import QLabel, QPainter +from PySide.QtGui import QGraphicsScene, QGraphicsView, QGraphicsItem, QGraphicsProxyWidget + +class CustomProxy(QGraphicsProxyWidget): + def __init__(self, parent=None, wFlags=0): + QGraphicsProxyWidget.__init__(self, parent, wFlags) + +class CustomProxyWidgetTest(UsesQApplication): + def testCustomProxyWidget(self): + scene = QGraphicsScene() + + proxy = CustomProxy(None, Qt.Window) + widget = QLabel('Widget') + proxy.setWidget(widget) + proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache) + scene.addItem(proxy) + scene.setSceneRect(scene.itemsBoundingRect()) + + view = QGraphicsView(scene) + view.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform) + view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate) + view.show() + + timer = QTimer.singleShot(100, self.app.quit) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/float_to_int_implicit_conversion_test.py b/tests/QtGui/float_to_int_implicit_conversion_test.py new file mode 100644 index 000000000..cc7d18fd9 --- /dev/null +++ b/tests/QtGui/float_to_int_implicit_conversion_test.py @@ -0,0 +1,32 @@ + +'''Test cases for QImage''' + +import unittest + +from PySide.QtGui import QImage, qRgb + +from helper import UsesQApplication + +class SetPixelFloat(UsesQApplication): + '''Test case for calling setPixel with float as argument''' + + def setUp(self): + #Acquire resources + super(SetPixelFloat, self).setUp() + self.color = qRgb(255, 0, 0) + self.image = QImage(200, 200, QImage.Format_RGB32) + + def tearDown(self): + #Release resources + del self.color + del self.image + super(SetPixelFloat, self).tearDown() + + def testFloat(self): + #QImage.setPixel(float, float, color) - Implicit conversion + self.image.setPixel(3.14, 4.2, self.color) + self.assertEqual(self.image.pixel(3.14, 4.2), self.color) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/grandparent_method_test.py b/tests/QtGui/grandparent_method_test.py new file mode 100644 index 000000000..3c1829377 --- /dev/null +++ b/tests/QtGui/grandparent_method_test.py @@ -0,0 +1,23 @@ + +'''Tests for calling methods further than the direct parent''' + +import unittest + +from PySide.QtGui import QPushButton, QWidget + +from helper import UsesQApplication + +class Dummy(QPushButton): + + def show(self): + QWidget.show(self) + self.called = True + +class GrandParentMethod(UsesQApplication): + def testMethod(self): + obj = Dummy() + obj.show() + self.assert_(obj.called) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/hashabletype_test.py b/tests/QtGui/hashabletype_test.py new file mode 100644 index 000000000..64683a398 --- /dev/null +++ b/tests/QtGui/hashabletype_test.py @@ -0,0 +1,18 @@ +'''Test cases for __hash__''' + +import unittest + +from PySide.QtGui import QTreeWidgetItem +from helper import UsesQApplication + +class HashableTest(UsesQApplication): + + def testQTreeWidgetItemHash(self): + h = {} + obj = QTreeWidgetItem() + h[obj] = 2 + self.assert_(h.get(obj), 2) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/keep_reference_test.py b/tests/QtGui/keep_reference_test.py new file mode 100755 index 000000000..d0962d5df --- /dev/null +++ b/tests/QtGui/keep_reference_test.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python + +import unittest + +from sys import getrefcount +from helper import UsesQApplication +from PySide.QtCore import QAbstractTableModel, QVariant +from PySide.QtGui import QTableView + +class TestModel(QAbstractTableModel): + def __init__(self, parent=None): + QAbstractTableModel.__init__(self, parent) + def rowCount(self, parent): + return 0 + def columnCount(self, parent): + return 0 + def data(self, index, role): + return QVariant() + +class KeepReferenceTest(UsesQApplication): + + def testModelWithoutParent(self): + view = QTableView() + model = TestModel() + view.setModel(model) + samemodel = view.model() + self.assertEqual(model, samemodel) + + def testModelWithParent(self): + view = QTableView() + model = TestModel(self.app) + view.setModel(model) + samemodel = view.model() + self.assertEqual(model, samemodel) + + def testReferenceCounting(self): + '''Tests reference count of model object referred by view objects.''' + model1 = TestModel() + refcount1 = getrefcount(model1) + view1 = QTableView() + view1.setModel(model1) + self.assertEqual(getrefcount(view1.model()), refcount1 + 1) + + view2 = QTableView() + view2.setModel(model1) + self.assertEqual(getrefcount(view2.model()), refcount1 + 2) + + model2 = TestModel() + view2.setModel(model2) + self.assertEqual(getrefcount(view1.model()), refcount1 + 1) + + def testReferenceCountingWhenDeletingReferrer(self): + '''Tests reference count of model object referred by deceased view object.''' + model = TestModel() + refcount1 = getrefcount(model) + view = QTableView() + view.setModel(model) + self.assertEqual(getrefcount(view.model()), refcount1 + 1) + + del view + self.assertEqual(getrefcount(model), refcount1) + + def testReferreedObjectSurvivalAfterContextEnd(self): + '''Model object assigned to a view object must survive after getting out of context.''' + def createModelAndSetToView(view): + model = TestModel() + model.setObjectName('created model') + view.setModel(model) + view = QTableView() + createModelAndSetToView(view) + model = view.model() + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/missing_symbols_test.py b/tests/QtGui/missing_symbols_test.py new file mode 100644 index 000000000..de23c569e --- /dev/null +++ b/tests/QtGui/missing_symbols_test.py @@ -0,0 +1,29 @@ + +'''(Very) Simple test case for missing names from QtGui''' + +import unittest +from PySide import QtGui + +class MissingClasses(unittest.TestCase): + def testQDrag(self): # Bug 222 + getattr(QtGui, 'QDrag') + + def testQDropEvent(self): # Bug 255 + getattr(QtGui, 'QDropEvent') + +class MissingMembers(unittest.TestCase): + + def testQFontMetricsSize(self): # Bug 223 + QtGui.QFontMetrics.size + + def testQLayoutSetSpacing(self): # Bug 231 + QtGui.QLayout.setSpacing + + def testQImageLoad(self): # Bug 257 + QtGui.QImage.load + + def testQStandardItemModelinsertRow(self): # Bug 227 + QtGui.QStandardItemModel.insertRow + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/paint_event_test.py b/tests/QtGui/paint_event_test.py new file mode 100644 index 000000000..02253908e --- /dev/null +++ b/tests/QtGui/paint_event_test.py @@ -0,0 +1,71 @@ + +'''Test paint event override in python''' + +import unittest + +from PySide.QtCore import QTimerEvent +from PySide.QtGui import QApplication, QWidget + +from helper import UsesQApplication + +class MyWidget(QWidget): + '''Sample widget''' + + def __init__(self, app=None): + #Creates a new widget + if app is None: + app = QApplication([]) + + super(MyWidget, self).__init__() + self.app = app + self.runs = 0 + self.max_runs = 5 + self.paint_event_called = False + + def timerEvent(self, event): + #Timer event method + self.runs += 1 + + if self.runs == self.max_runs: + self.app.quit() + + if not isinstance(event, QTimerEvent): + raise TypeError('Invalid event type. Must be QTimerEvent') + + def paintEvent(self, event): + #Empty paint event method + # XXX: should be using super here, but somehow PyQt4 + # complains about paintEvent not present in super + QWidget.paintEvent(self, event) + self.paint_event_called = True + + +class PaintEventOverride(UsesQApplication): + '''Test case for overriding QWidget.paintEvent''' + + qapplication = True + + def setUp(self): + #Acquire resources + super(PaintEventOverride, self).setUp() + self.widget = MyWidget(self.app) + + def tearDown(self): + #Release resources + del self.widget + super(PaintEventOverride, self).tearDown() + + def testPaintEvent(self): + #Test QWidget.paintEvent override + timer_id = self.widget.startTimer(100) + self.widget.show() + self.app.exec_() + + self.widget.killTimer(timer_id) + + self.assert_(self.widget.paint_event_called) + self.assertEqual(self.widget.runs, 5) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/parent_method_test.py b/tests/QtGui/parent_method_test.py new file mode 100644 index 000000000..8d0ba9601 --- /dev/null +++ b/tests/QtGui/parent_method_test.py @@ -0,0 +1,25 @@ + +import unittest + +from PySide.QtCore import QObject, QTimer, QThread +from PySide.QtGui import * + +class Foo(QTableView): + def __init__(self, parent=None): + QTableView.__init__(self, parent) + +from helper import UsesQApplication + +class TestParentType(UsesQApplication): + + def testParentType(self): + # Test the problem with calling QObject.parent from a QWidget + # when the parent is a python class derived from a QWidget-derived + # class. The method was returning the last C++ class in the hierarchy + parent = Foo() + w2 = QWidget(parent) + self.assert_(isinstance(w2.parentWidget(), Foo)) + self.assert_(isinstance(w2.parent(), Foo)) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/python_properties_test.py b/tests/QtGui/python_properties_test.py new file mode 100644 index 000000000..7d6c024e7 --- /dev/null +++ b/tests/QtGui/python_properties_test.py @@ -0,0 +1,15 @@ +import unittest +from PySide import QtGui, QtCore + +class Properties(unittest.TestCase): + + def testStaticProperty(self): + self.assertEqual(QtGui.QGraphicsItem.UserType, 65536) + + def testInstanceProperty(self): + p = QtGui.QStyleOptionViewItemV3() + self.assert_(isinstance(p.locale, QtCore.QLocale)) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qapp_test.py b/tests/QtGui/qapp_test.py new file mode 100644 index 000000000..c371492e6 --- /dev/null +++ b/tests/QtGui/qapp_test.py @@ -0,0 +1,17 @@ + +''' Test the presence of qApp Macro''' + +import unittest + +from PySide import QtGui + +class QAppPresence(unittest.TestCase): + + def testQApp(self): + #QtGui.qApp variable is instance of QApplication + self.assert_(isinstance(QtGui.qApp, QtGui.QApplication)) + + +if __name__ == '__main__': + app = QtGui.QApplication([]) + unittest.main() diff --git a/tests/QtGui/qapplication_exit_segfault_test.py b/tests/QtGui/qapplication_exit_segfault_test.py new file mode 100644 index 000000000..72b810a98 --- /dev/null +++ b/tests/QtGui/qapplication_exit_segfault_test.py @@ -0,0 +1,17 @@ + +import unittest +import sys + +from PySide.QtGui import QApplication, QPushButton, QWidget, QSpinBox + +class QApplicationDelete(unittest.TestCase): + '''Test for segfault when deleting a QApplication before a QWidget''' + + def testQPushButton(self): + #QApplication deleted before QPushButton + a = QApplication([]) + b = QPushButton('aaaa') + del a + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qapplication_singleton_test.py b/tests/QtGui/qapplication_singleton_test.py new file mode 100644 index 000000000..9c959f9d4 --- /dev/null +++ b/tests/QtGui/qapplication_singleton_test.py @@ -0,0 +1,12 @@ + +import unittest + +from PySide.QtGui import QApplication + +class TestSingleton(unittest.TestCase): + def testBasic(self): + a = QApplication([]) + self.assertRaises(RuntimeError, QApplication, []) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qbrush_test.py b/tests/QtGui/qbrush_test.py new file mode 100644 index 000000000..cf11652a5 --- /dev/null +++ b/tests/QtGui/qbrush_test.py @@ -0,0 +1,24 @@ + +'''Test cases for QBrush''' + +import unittest + +from PySide.QtCore import Qt +from PySide.QtGui import QApplication, QColor, QBrush + +from helper import UsesQApplication + +class Constructor(UsesQApplication): + '''Test case for constructor of QBrush''' + + def testQColor(self): + #QBrush(QColor) constructor + color = QColor('black') + obj = QBrush(color) + self.assertEqual(obj.color(), color) + + obj = QBrush(Qt.blue) + self.assertEqual(obj.color(), Qt.blue) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qcolor_test.py b/tests/QtGui/qcolor_test.py new file mode 100644 index 000000000..3c2f11ba0 --- /dev/null +++ b/tests/QtGui/qcolor_test.py @@ -0,0 +1,68 @@ + +import unittest +import colorsys + +from PySide.QtCore import Qt +from PySide.QtGui import QColor + + +class QColorGetTest(unittest.TestCase): + + def setUp(self): + self.color = QColor(20, 40, 60, 80) + + def testGetRgb(self): + self.assertEqual(self.color.getRgb(), (20, 40, 60, 80)) + + def testGetRgbF(self): + self.assertEqual(self.color.getRgbF(), (20.0/255, 40.0/255, 60.0/255, 80.0/255)) + + def testGetHsl(self): + self.assertEqual(self.color.getHsl(), (210, 128, 40, self.color.alpha())) + + def testGetHslF(self): + hls = colorsys.rgb_to_hls(20.0/255, 40.0/255, 60.0/255) + hsla = hls[0], hls[2], hls[1], self.color.alphaF() + for x, y in zip(self.color.getHslF(), hsla): # Due to rounding problems + self.assert_(x - y < 1/100000.0) + + def testGetHsv(self): + hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255) + hsva = int(hsv[0]*360.0), int(hsv[1]*255), int(hsv[2]*256), self.color.alpha() + self.assertEqual(self.color.getHsv(), hsva) + + def testGetHsvF(self): + hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255) + hsva = hsv[0], hsv[1], hsv[2], self.color.alphaF() + self.assertEqual(self.color.getHsvF(), hsva) + + def testGetCmyk(self): # not supported by colorsys + self.assertEqual(self.color.getCmyk(), (170, 85, 0, 195, 80)) + + def testGetCmykF(self): # not supported by colorsys + for x, y in zip(self.color.getCmykF(), (170/255.0, 85/255.0, 0, 195/255.0, 80/255.0)): + self.assert_(x - y < 1/10000.0) + + +class QColorQRgbConstructor(unittest.TestCase): + '''QColor(QRgb) constructor''' + # Affected by bug #170 - QColor(QVariant) coming before QColor(uint) + # in overload sorting + + def testBasic(self): + '''QColor(QRgb)''' + color = QColor(255, 0, 0) + #QRgb format #AARRGGBB + rgb = 0x00FF0000 + self.assertEqual(QColor(rgb), color) + + +class QColorEqualGlobalColor(unittest.TestCase): + + def testEqualGlobalColor(self): + '''QColor == Qt::GlobalColor''' + self.assertEqual(QColor(255, 0, 0), Qt.red) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qdatastream_gui_operators_test.py b/tests/QtGui/qdatastream_gui_operators_test.py new file mode 100644 index 000000000..dbb638fd3 --- /dev/null +++ b/tests/QtGui/qdatastream_gui_operators_test.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +import unittest +import sys + +from PySide.QtCore import QDataStream, QByteArray, QIODevice, Qt +from PySide.QtGui import QPixmap, QColor + +from helper import UsesQApplication + +class QPixmapQDatastream(UsesQApplication): + '''QDataStream <<>> QPixmap''' + + def setUp(self): + super(QPixmapQDatastream, self).setUp() + self.source_pixmap = QPixmap(100, 100) + self.source_pixmap.fill(Qt.red) + self.output_pixmap = QPixmap() + self.buffer = QByteArray() + self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly) + self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly) + + def testStream(self): + self.write_stream << self.source_pixmap + + self.read_stream >> self.output_pixmap + + image = self.output_pixmap.toImage() + pixel = image.pixel(10,10) + self.assertEqual(pixel, QColor(Qt.red).rgba()) + self.assertEqual(self.source_pixmap.toImage(), self.output_pixmap.toImage()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qfontdialog_test.py b/tests/QtGui/qfontdialog_test.py new file mode 100644 index 000000000..02bce7828 --- /dev/null +++ b/tests/QtGui/qfontdialog_test.py @@ -0,0 +1,22 @@ +import unittest +import sys + +from PySide import QtGui +from PySide import QtCore + +from helper import TimedQApplication + +class TestFontDialog(TimedQApplication): + + def testGetFont(self): + QtGui.QFontDialog.getFont() + + def testGetFontQDialog(self): + QtGui.QFontDialog.getFont(QtGui.QFont("FreeSans",10)) + + def testGetFontQDialogQString(self): + QtGui.QFontDialog.getFont(QtGui.QFont("FreeSans",10), None, "Select font") + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qfontmetrics_test.py b/tests/QtGui/qfontmetrics_test.py new file mode 100644 index 000000000..7964d91d4 --- /dev/null +++ b/tests/QtGui/qfontmetrics_test.py @@ -0,0 +1,189 @@ + +'''Tests for inject codes and modifications on QFontMetrics + and QFontMetricsF''' + +import unittest +from PySide.QtGui import QFont, QFontMetrics, QFontMetricsF +from PySide.QtCore import QRect, QRectF, Qt, QSize, QSizeF +from helper import UsesQApplication + + +class QFontMetricsTest(UsesQApplication): + '''Base class for QFontMetrics tests''' + + def setUp(self): + super(QFontMetricsTest, self).setUp() + self.font = QFont() + self.metrics = QFontMetrics(self.font) + + def tearDown(self): + del self.metrics + del self.font + super(QFontMetricsTest, self).tearDown() + + +class BoundingRectTest(QFontMetricsTest): + '''Tests for QFontMetrics.boundingRect inject code''' + + def testIntDefault(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - default args''' + rect = self.metrics.boundingRect(0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT') + self.assert_(isinstance(rect, QRect)) + + def testIntWithArg(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - single arg''' + rect = self.metrics.boundingRect(0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 2) + self.assert_(isinstance(rect, QRect)) + + def testIntWithFull(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - all argss''' + rect = self.metrics.boundingRect(0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, [1, 2, 3, 4, 5]) + self.assert_(isinstance(rect, QRect)) + + def testIntTypeError(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - type error''' + self.assertRaises(TypeError, self.metrics.boundingRect, 0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + def testQRectDefault(self): + '''QFontMetrics.boundingRect(QRect, ...) - default args''' + arg = QRect(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT') + self.assert_(isinstance(rect, QRect)) + + def testQRectWithArg(self): + '''QFontMetrics.boundingRect(QRect, ...) - only tabstops''' + arg = QRect(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 2) + self.assert_(isinstance(rect, QRect)) + + def testQRectWithFull(self): + '''QFontMetrics.boundingRect(QRect, ...) - all arguments''' + arg = QRect(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, + [1, 2, 3, 4, 5]) + self.assert_(isinstance(rect, QRect)) + + def testQRectTypeError(self): + '''QFontMetrics.boundingRect(QRect, ...) - type error''' + arg = QRect(0, 0, 100, 200) + self.assertRaises(TypeError, self.metrics.boundingRect, arg, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +class SizeTest(QFontMetricsTest): + '''Tests for QFontMetrics.size inject code''' + + def testDefault(self): + '''QFontMetrics.size - default arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT') + self.assert_(isinstance(size, QSize)) + + def testWithTabStops(self): + '''QFontMetrics.size - only tabstops''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2) + self.assert_(isinstance(size, QSize)) + + def testFull(self): + '''QFontMetrics.size - all arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2, [1, 2, 3, 4]) + self.assert_(isinstance(size, QSize)) + + def testTypeError(self): + '''QFontMetrics.size - type error''' + self.assertRaises(TypeError, self.metrics.size, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +class QFontMetricsFTest(UsesQApplication): + '''Base class for QFontMetrics tests''' + + def setUp(self): + super(QFontMetricsFTest, self).setUp() + self.font = QFont() + self.metrics = QFontMetricsF(self.font) + + def tearDown(self): + del self.metrics + del self.font + super(QFontMetricsFTest, self).tearDown() + + +class FBoundingRectTest(QFontMetricsFTest): + '''Tests for QFontMetricsF.boundingRect inject code''' + + def testQRectDefault(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - default args''' + arg = QRectF(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT') + self.assert_(isinstance(rect, QRectF)) + + def testQRectWithArg(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - only tabstops''' + arg = QRectF(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 2) + self.assert_(isinstance(rect, QRectF)) + + def testQRectWithFull(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - all arguments''' + arg = QRectF(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, + [1, 2, 3, 4, 5]) + self.assert_(isinstance(rect, QRectF)) + + def testQRectTypeError(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - type error''' + arg = QRectF(0, 0, 100, 200) + self.assertRaises(TypeError, self.metrics.boundingRect, arg, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +class FSizeTest(QFontMetricsFTest): + '''Tests for QFontMetricsF.size inject code''' + + def testDefault(self): + '''QFontMetricsF.size - default arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT') + self.assert_(isinstance(size, QSizeF)) + + def testWithTabStops(self): + '''QFontMetricsF.size - only tabstops''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2) + self.assert_(isinstance(size, QSizeF)) + + def testFull(self): + '''QFontMetricsF.size - all arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2, [1, 2, 3, 4]) + self.assert_(isinstance(size, QSizeF)) + + def testTypeError(self): + '''QFontMetricsF.size - type error''' + self.assertRaises(TypeError, self.metrics.size, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qgraphicsitem_isblocked_test.py b/tests/QtGui/qgraphicsitem_isblocked_test.py new file mode 100755 index 000000000..b281c8a59 --- /dev/null +++ b/tests/QtGui/qgraphicsitem_isblocked_test.py @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import unittest + +from PySide import QtCore +from PySide import QtGui +from helper import UsesQApplication + +class Item(QtGui.QGraphicsItem): + + def __init__(self): + QtGui.QGraphicsItem.__init__(self) + + def boundingRect(self): + return QtCore.QRectF(0, 0, 100, 100) + + def paint(self, painter, option, widget): + painter.setBrush(QtGui.QColor(255, 255, 255)) + painter.drawRect(0, 0, 100, 100) + + +class QGraphicsViewIsBlockedTest(UsesQApplication): + + def testIsBlockedByModalPanel(self): + (first, second) = Item().isBlockedByModalPanel() + self.assertFalse(first) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/QtGui/qgraphicsitem_test.py b/tests/QtGui/qgraphicsitem_test.py new file mode 100644 index 000000000..43545a431 --- /dev/null +++ b/tests/QtGui/qgraphicsitem_test.py @@ -0,0 +1,35 @@ + +''' Test cases related to QGraphicsItem and subclasses''' + +import unittest + +from PySide.QtGui import QGraphicsScene, QPolygonF, QColor, QBrush + +from helper import UsesQApplication + +class QColorOnSetBrush(UsesQApplication): + '''Test case for passing a QColor directly to setBrush''' + + def setUp(self): + #Acquire resources + super(QColorOnSetBrush, self).setUp() + + self.scene = QGraphicsScene() + poly = QPolygonF() + self.item = self.scene.addPolygon(poly) + self.color = QColor('black') + + def tearDown(self): + #Release resources + del self.color + del self.item + del self.scene + super(QColorOnSetBrush, self).tearDown() + + def testQColor(self): + #QGraphicsAbstractShapeItem.setBrush(QColor) + self.item.setBrush(self.color) + self.assertEqual(QBrush(self.color), self.item.brush()) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qgraphicsproxywidget_test.py b/tests/QtGui/qgraphicsproxywidget_test.py new file mode 100755 index 000000000..3a856bc7c --- /dev/null +++ b/tests/QtGui/qgraphicsproxywidget_test.py @@ -0,0 +1,29 @@ +import unittest + +from helper import UsesQApplication +from PySide.QtCore import Qt, QTimer +from PySide.QtGui import QLabel, QPainter +from PySide.QtGui import QGraphicsScene, QGraphicsView, QGraphicsItem, QGraphicsProxyWidget + +class QGraphicsProxyWidgetTest(UsesQApplication): + def testQGraphicsProxyWidget(self): + scene = QGraphicsScene() + + proxy = QGraphicsProxyWidget(None, Qt.Window) + widget = QLabel('Widget') + proxy.setWidget(widget) + proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache) + scene.addItem(proxy) + scene.setSceneRect(scene.itemsBoundingRect()) + + view = QGraphicsView(scene) + view.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform) + view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate) + view.show() + + timer = QTimer.singleShot(100, self.app.quit) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qgraphicsscene_test.py b/tests/QtGui/qgraphicsscene_test.py new file mode 100644 index 000000000..98177e75a --- /dev/null +++ b/tests/QtGui/qgraphicsscene_test.py @@ -0,0 +1,152 @@ + +'''Basic test cases for QGraphicsScene''' + +import unittest +import gc + +from PySide.QtCore import QPointF +from PySide.QtGui import QApplication, QPushButton, QPolygonF, QPixmap +from PySide.QtGui import QGraphicsScene, QPainterPath +from PySide.QtGui import QGraphicsEllipseItem, QGraphicsLineItem +from PySide.QtGui import QGraphicsPathItem, QGraphicsPixmapItem +from PySide.QtGui import QGraphicsPolygonItem, QGraphicsRectItem +from PySide.QtGui import QGraphicsSimpleTextItem, QGraphicsTextItem +from PySide.QtGui import QGraphicsProxyWidget + +from helper import UsesQApplication + +class Constructor(unittest.TestCase): + '''QGraphicsScene constructor''' + + def testConstructor(self): + #QGraphicsScene constructor + obj = QGraphicsScene() + self.assert_(isinstance(obj, QGraphicsScene)) + + +class ConstructorWithRect(unittest.TestCase): + '''QGraphicsScene qrect constructor and related sizes''' + + def setUp(self): + #Acquire resources + # PyQt4 doesn't accept a QRect as argument to constructor + self.scene = QGraphicsScene(0, 200, 150, 175) + + def tearDown(self): + #Release resources + del self.scene + + def testHeight(self): + #QGraphicsScene.height() + self.assertEqual(self.scene.height(), 175) + + def testWidth(self): + #QGraphicsScene.width() + self.assertEqual(self.scene.width(), 150) + + +class AddItem(UsesQApplication): + '''Tests for QGraphicsScene.add*''' + + qapplication = True + + def setUp(self): + #Acquire resources + super(AddItem, self).setUp() + self.scene = QGraphicsScene() + # While the scene does not inherits from QWidget, requires + # an application to make the internals work. + + def tearDown(self): + #Release resources + del self.scene + super(AddItem, self).tearDown() + + def testEllipse(self): + #QGraphicsScene.addEllipse + item = self.scene.addEllipse(100, 100, 100, 100) + self.assert_(isinstance(item, QGraphicsEllipseItem)) + + def testLine(self): + #QGraphicsScene.addLine + item = self.scene.addLine(100, 100, 200, 200) + self.assert_(isinstance(item, QGraphicsLineItem)) + + def testPath(self): + #QGraphicsScene.addPath + item = self.scene.addPath(QPainterPath()) + self.assert_(isinstance(item, QGraphicsPathItem)) + + def testPixmap(self): + #QGraphicsScene.addPixmap + item = self.scene.addPixmap(QPixmap()) + self.assert_(isinstance(item, QGraphicsPixmapItem)) + + def testPolygon(self): + #QGraphicsScene.addPolygon + points = [QPointF(0, 0), QPointF(100, 100), QPointF(0, 100)] + item = self.scene.addPolygon(QPolygonF(points)) + self.assert_(isinstance(item, QGraphicsPolygonItem)) + + def testRect(self): + #QGraphicsScene.addRect + item = self.scene.addRect(100, 100, 100, 100) + self.assert_(isinstance(item, QGraphicsRectItem)) + + def testSimpleText(self): + #QGraphicsScene.addSimpleText + item = self.scene.addSimpleText('Monty Python 42') + self.assert_(isinstance(item, QGraphicsSimpleTextItem)) + + def testText(self): + #QGraphicsScene.addText + item = self.scene.addText('Monty Python 42') + self.assert_(isinstance(item, QGraphicsTextItem)) + + def testWidget(self): + #QGraphicsScene.addWidget + # XXX: printing some X11 error when using under PyQt4 + item = self.scene.addWidget(QPushButton()) + self.assert_(isinstance(item, QGraphicsProxyWidget)) + + +class ItemRetrieve(UsesQApplication): + '''Tests for QGraphicsScene item retrieval methods''' + + qapplication = True + + def setUp(self): + #Acquire resources + super(ItemRetrieve, self).setUp() + self.scene = QGraphicsScene() + + self.topleft = QGraphicsRectItem(0, 0, 100, 100) + self.topright = QGraphicsRectItem(100, 0, 100, 100) + self.bottomleft = QGraphicsRectItem(0, 100, 100, 100) + self.bottomright = QGraphicsRectItem(100, 100, 100, 100) + + self.items = [self.topleft, self.topright, self.bottomleft, + self.bottomright] + + for item in self.items: + self.scene.addItem(item) + + def tearDown(self): + #Release resources + del self.scene + super(ItemRetrieve, self).tearDown() + + def testItems(self): + #QGraphicsScene.items() + items = self.scene.items() + self.assertEqual(items.sort(), self.items.sort()) + + def testItemAt(self): + #QGraphicsScene.itemAt() + self.assertEqual(self.scene.itemAt(50, 50), self.topleft) + self.assertEqual(self.scene.itemAt(150, 50), self.topright) + self.assertEqual(self.scene.itemAt(50, 150), self.bottomleft) + self.assertEqual(self.scene.itemAt(150, 150), self.bottomright) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qinputdialog_get_test.py b/tests/QtGui/qinputdialog_get_test.py new file mode 100644 index 000000000..c75f71251 --- /dev/null +++ b/tests/QtGui/qinputdialog_get_test.py @@ -0,0 +1,27 @@ +import unittest + +from PySide import QtCore, QtGui +from helper import UsesQApplication, TimedQApplication + +class TestInputDialog(TimedQApplication): + + def testGetDouble(self): + self.assertEquals(QtGui.QInputDialog.getDouble(None, "title", "label"), (0.0, False)) + + def testGetInt(self): + self.assertEquals(QtGui.QInputDialog.getInt(None, "title", "label"), (0, False)) + + def testGetInteger(self): + self.assertEquals(QtGui.QInputDialog.getInteger(None, "title", "label"), (0, False)) + + def testGetItem(self): + (item, bool) = QtGui.QInputDialog.getItem(None, "title", "label", QtCore.QStringList(["1", "2", "3"])) + self.assertEquals(str(item), "1") + + def testGetText(self): + (text, bool) = QtGui.QInputDialog.getText(None, "title", "label") + self.assertEquals(str(text),"") + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qitemselection_test.py b/tests/QtGui/qitemselection_test.py new file mode 100644 index 000000000..8c6c34e03 --- /dev/null +++ b/tests/QtGui/qitemselection_test.py @@ -0,0 +1,18 @@ +import unittest + +from helper import UsesQApplication +from PySide.QtGui import QItemSelection, QStandardItemModel + +class QItemSelectionTest(UsesQApplication): + def testLen(self): + model = QStandardItemModel(2, 2) + model.insertRow(0) + model.insertRow(1) + model.insertColumn(0) + model.insertColumn(1) + selection = QItemSelection(model.index(0,0), model.index(1,1)) + self.assertEqual(len(selection), 1) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qlayout_ref_test.py b/tests/QtGui/qlayout_ref_test.py new file mode 100644 index 000000000..a6342718d --- /dev/null +++ b/tests/QtGui/qlayout_ref_test.py @@ -0,0 +1,112 @@ + +'''Test cases for QLayout handling of child widgets references''' + +import unittest +from sys import getrefcount + +from PySide.QtGui import QHBoxLayout, QVBoxLayout, QGridLayout, QWidget +from PySide.QtGui import QStackedLayout, QFormLayout +from PySide.QtGui import QApplication, QPushButton, QLabel + +from helper import UsesQApplication + +class SaveReference(UsesQApplication): + '''Test case to check if QLayout-derived classes increment the refcount + of widgets passed to addWidget()''' + + # Adding here as nose can't see the qapplication attrib we inherit + qapplication = True + + def setUp(self): + #Acquire resources + super(SaveReference, self).setUp() + self.widget1 = QPushButton('click me') + self.widget2 = QLabel('aaa') + + def tearDown(self): + #Release resources + del self.widget2 + del self.widget1 + super(SaveReference, self).tearDown() + + def checkLayoutReference(self, layout): + #Checks the reference cound handling of layout.addWidget + self.assertEqual(getrefcount(self.widget1), 2) + layout.addWidget(self.widget1) + self.assertEqual(getrefcount(self.widget1), 3) + + self.assertEqual(getrefcount(self.widget2), 2) + layout.addWidget(self.widget2) + self.assertEqual(getrefcount(self.widget2), 3) + + # Check if doesn't mess around with previous widget refcount + self.assertEqual(getrefcount(self.widget1), 3) + + def testMoveLayout(self): + l = QHBoxLayout() + self.assertEqual(getrefcount(self.widget1), 2) + l.addWidget(self.widget1) + self.assertEqual(getrefcount(self.widget1), 2) + + w = QWidget() + w.setLayout(l) + self.assertEqual(getrefcount(self.widget1), 3) + + + def testHBoxReference(self): + #QHBoxLayout.addWidget reference count + w = QWidget() + self.checkLayoutReference(QHBoxLayout(w)) + + def testVBoxReference(self): + #QVBoxLayout.addWidget reference count + w = QWidget() + self.checkLayoutReference(QVBoxLayout(w)) + + def testGridReference(self): + #QGridLayout.addWidget reference count + w = QWidget() + self.checkLayoutReference(QGridLayout(w)) + + def testFormReference(self): + #QFormLayout.addWidget reference count + w = QWidget() + self.checkLayoutReference(QFormLayout(w)) + + def testStackedReference(self): + #QStackedLayout.addWidget reference count + w = QWidget() + self.checkLayoutReference(QStackedLayout(w)) + +class MultipleAdd(UsesQApplication): + '''Test case to check if refcount is incremented only once when multiple + calls to addWidget are made with the same widget''' + + qapplication = True + + def setUp(self): + #Acquire resources + super(MultipleAdd, self).setUp() + self.widget = QPushButton('click me') + self.win = QWidget() + self.layout = QHBoxLayout(self.win) + + def tearDown(self): + #Release resources + del self.widget + del self.layout + del self.win + super(MultipleAdd, self).tearDown() + + def testRefCount(self): + #Multiple QLayout.addWidget calls on the same widget + self.assertEqual(getrefcount(self.widget), 2) + self.layout.addWidget(self.widget) + self.assertEqual(getrefcount(self.widget), 3) + self.layout.addWidget(self.widget) + self.assertEqual(getrefcount(self.widget), 3) + self.layout.addWidget(self.widget) + self.assertEqual(getrefcount(self.widget), 3) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qlayout_test.py b/tests/QtGui/qlayout_test.py new file mode 100644 index 000000000..ae773bb0a --- /dev/null +++ b/tests/QtGui/qlayout_test.py @@ -0,0 +1,52 @@ +import unittest +import sys + +from helper import UsesQApplication +from PySide.QtGui import QLayout, QWidget, QPushButton, QWidgetItem + +class MyLayout(QLayout): + def __init__(self, parent=None): + QLayout.__init__(self, parent) + self._list = [] + + def addItem(self, item): + self.add(item) + + def addWidget(self, widget): + self.add(QWidgetItem(widget)) + + def itemAt(self, index): + if index < len(self._list): + return self._list[index] + + return None + + def count(self): + return len(self._list) + + def add(self, item): + self._list.append(item) + + + +#Test if a layout implemented in python, the QWidget.setLayout works +#fine because this implement som layout functions used in glue code of +#QWidget, then in c++ when call a virtual function this need call the QLayout +#function implemented in python + +class QLayoutTest(UsesQApplication): + + def testOwnershipTransfer(self): + b = QPushButton("teste") + l = MyLayout() + l.addWidget(b) + + self.assertEqual(sys.getrefcount(b), 2) + + w = QWidget() + w.setLayout(l) + + self.assertEqual(sys.getrefcount(b), 3) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qlcdnumber_test.py b/tests/QtGui/qlcdnumber_test.py new file mode 100644 index 000000000..eb6a4f396 --- /dev/null +++ b/tests/QtGui/qlcdnumber_test.py @@ -0,0 +1,16 @@ +import unittest + +from PySide.QtGui import QApplication, QLCDNumber + +class QLCDNumberOverflow(unittest.TestCase): + '''Test case for unhandled overflow on QLCDNumber() numDigits argument (see bug #215).''' + + def setUp(self): + self.app = QApplication([]) + + def testnumDigitsOverflow(self): + # NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError + self.assertRaises(OverflowError, QLCDNumber, 840835495615213080) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qlistwidgetitem_test.py b/tests/QtGui/qlistwidgetitem_test.py new file mode 100644 index 000000000..8f96c518f --- /dev/null +++ b/tests/QtGui/qlistwidgetitem_test.py @@ -0,0 +1,25 @@ + +import unittest + +from PySide import QtGui + +from helper import UsesQApplication + +class QListWidgetItemConstructor(UsesQApplication): + + def setUp(self): + super(QListWidgetItemConstructor, self).setUp() + self.widgetList = QtGui.QListWidget() + + def tearDown(self): + del self.widgetList + super(QListWidgetItemConstructor, self).tearDown() + + def testConstructorWithParent(self): + # Bug 235 - QListWidgetItem constructor not saving ownership + QtGui.QListWidgetItem(self.widgetList) + item = self.widgetList.item(0) + self.assertEqual(item.listWidget(), self.widgetList) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qmainwindow_test.py b/tests/QtGui/qmainwindow_test.py new file mode 100644 index 000000000..fce145d53 --- /dev/null +++ b/tests/QtGui/qmainwindow_test.py @@ -0,0 +1,32 @@ +import unittest +import sys + +from PySide import QtGui +from PySide import QtCore + +from helper import UsesQApplication + +class MainWindow(QtGui.QMainWindow): + def __init__(self): + QtGui.QMainWindow.__init__(self) + + self.createToolbar() + + def createToolbar(self): + pointerButton = QtGui.QToolButton() + pointerToolbar = self.addToolBar("Pointer type") + pointerToolbar.addWidget(pointerButton) + + +class TestMainWindow(UsesQApplication): + + def testCreateToolbar(self): + w = MainWindow() + w.show() + QtCore.QTimer.singleShot(1000, self.app.quit) + self.app.exec_() + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qmatrix_test.py b/tests/QtGui/qmatrix_test.py new file mode 100644 index 000000000..7c87e23a4 --- /dev/null +++ b/tests/QtGui/qmatrix_test.py @@ -0,0 +1,49 @@ +import unittest + +from PySide.QtCore import QPoint +from PySide.QtGui import QMatrix, QMatrix4x4 + + +def qpointTimesQMatrix(point, matrix): + '''As seen in "QPoint QMatrix::map(const QPoint &p) const" C++ implementation.''' + return QPoint(matrix.m11() * point.x() + matrix.m21() * point.y() + matrix.dx(), + matrix.m12() * point.x() + matrix.m22() * point.y() + matrix.dy()) + +class QMatrixTest(unittest.TestCase): + + def testMatrix(self): + matrix = QMatrix(11, 12, 21, 22, 100, 200) + point = QPoint(3, 3) + self.assertEqual(point * matrix, qpointTimesQMatrix(point, matrix)) + + def testMatrixWithWrongType(self): + matrix = QMatrix(11, 12, 21, 22, 100, 200) + point = QPoint(3, 3) + self.assertRaises(TypeError, matrix.__mul__, point) + + def testMatrix4x4(self): + self.assertRaises(TypeError, QMatrix4x4, [0.0, 1.0, 2.0, 3.0]) + self.assertRaises(TypeError, QMatrix4x4, [0.0, 1.0, 2.0, 'I', + 4.0, 5.0, 6.0, 7.0, + 8.0, 9.0, 'N', 11.0, + 12.0, 'd', 14.0, 'T']) + + my_data = [0.0, 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, 7.0, + 8.0, 9.0, 10.0, 11.0, + 12.0, 13.0, 14.0, 15.0] + my_datac = [0.0, 4.0, 8.0, 12.0, + 1.0, 5.0, 9.0, 13.0, + 2.0, 6.0, 10.0, 14.0, + 3.0, 7.0, 11.0, 15.0] + + m = QMatrix4x4(my_data) + d = m.data() + self.assert_(my_datac, d) + + d = m.copyDataTo() + self.assert_(my_data == list(d)) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qmenu_test.py b/tests/QtGui/qmenu_test.py new file mode 100644 index 000000000..37faf1613 --- /dev/null +++ b/tests/QtGui/qmenu_test.py @@ -0,0 +1,58 @@ + +import unittest + +from PySide.QtGui import QMenu, QKeySequence, QIcon +from PySide.QtCore import SLOT + +from helper import UsesQApplication + +class QMenuAddAction(UsesQApplication): + + def setUp(self): + super(QMenuAddAction, self).setUp() + self.menu = QMenu() + + def tearDown(self): + del self.menu + super(QMenuAddAction, self).tearDown() + + def testAddActionWithoutKeySequenceCallable(self): + # bug #280 + action = self.menu.addAction(self.app.tr('aaa'), lambda : 1) + + def testAddActionKeySequenceCallable(self): + # bug #228 + action = self.menu.addAction(self.app.tr('aaa'), lambda : 1, + QKeySequence(self.app.tr('Ctrl+O'))) + + def testAddActionKeySequenceSlot(self): + action = self.menu.addAction('Quit', self.app, SLOT('quit()'), + QKeySequence('Ctrl+O')) + +class QMenuAddActionWithIcon(UsesQApplication): + + def setUp(self): + super(QMenuAddActionWithIcon, self).setUp() + self.menu = QMenu() + self.icon = QIcon() + + def tearDown(self): + del self.menu + del self.icon + super(QMenuAddActionWithIcon, self).tearDown() + + def testAddActionWithoutKeySequenceCallable(self): + # bug #280 + action = self.menu.addAction(self.icon, self.app.tr('aaa'), lambda : 1) + + def testAddActionKeySequenceCallable(self): + # bug #228 + action = self.menu.addAction(self.icon, self.app.tr('aaa'), lambda : 1, + QKeySequence(self.app.tr('Ctrl+O'))) + + def testAddActionKeySequenceSlot(self): + action = self.menu.addAction(self.icon, 'Quit', self.app, SLOT('quit()'), + QKeySequence('Ctrl+O')) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qmenuadd_test.py b/tests/QtGui/qmenuadd_test.py new file mode 100644 index 000000000..47b112bf1 --- /dev/null +++ b/tests/QtGui/qmenuadd_test.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +''' Test the QMenu.addAction() method''' + +import unittest +import sys + +from PySide import QtGui + +from helper import UsesQApplication + +class QMenuAddAction(UsesQApplication): + + def openFile(self, *args): + self.arg = args + + def testQMenuAddAction(self): + fileMenu = QtGui.QMenu("&File") + + addNewAction = fileMenu.addAction("&Open...", self.openFile) + addNewAction.trigger() + self.assertEquals(self.arg, ()) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qobject_mi_test.py b/tests/QtGui/qobject_mi_test.py new file mode 100644 index 000000000..8ccc1d35d --- /dev/null +++ b/tests/QtGui/qobject_mi_test.py @@ -0,0 +1,37 @@ +'''Test cases for multiple inheritance from 2 QObjects''' + +import unittest + +from PySide.QtCore import QObject +from PySide.QtGui import * + +from helper import UsesQApplication + +class WidgetValidator(QWidget, QIntValidator): + def __init__(self, parent=None): + QWidget.__init__(self, parent) + QIntValidator.__init__(self, parent) + + +class DoubleQObjectInheritanceTest(UsesQApplication): + + def testDouble(self): + '''Double inheritance from QObject classes''' + + obj = WidgetValidator() + + #QObject methods + obj.setObjectName('aaaa') + self.assertEqual(obj.objectName(), 'aaaa') + + #QWidget methods + obj.setVisible(False) + self.assertFalse(obj.isVisible()) + + #QIntValidator methods + self.assertEqual(obj.validate('aaaa', 0), QValidator.Invalid) + self.assertEqual(obj.validate('33', 0), QValidator.Acceptable) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qpainter_test.py b/tests/QtGui/qpainter_test.py new file mode 100644 index 000000000..ad1d1e471 --- /dev/null +++ b/tests/QtGui/qpainter_test.py @@ -0,0 +1,49 @@ +import unittest + +from PySide.QtGui import QPainter, QBrush, QLinearGradient +from PySide.QtCore import QRect, QRectF, Qt + +class QPainterDrawText(unittest.TestCase): + + def setUp(self): + self.painter = QPainter() + self.text = 'teste!' + + def tearDown(self): + del self.text + del self.painter + + def testDrawText(self): + # bug #254 + rect = self.painter.drawText(100, 100, 100, 100, + Qt.AlignCenter | Qt.TextWordWrap, + self.text) + self.assert_(isinstance(rect, QRect)) + + def testDrawTextWithRect(self): + # bug #225 + rect = QRect(100, 100, 100, 100) + newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, + self.text) + + self.assert_(isinstance(newRect, QRect)) + + def testDrawTextWithRectF(self): + '''QPainter.drawText(QRectF, ... ,QRectF*) inject code''' + rect = QRectF(100, 52.3, 100, 100) + newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, + self.text) + + self.assert_(isinstance(newRect, QRectF)) + +class SetBrushWithOtherArgs(unittest.TestCase): + '''Using qpainter.setBrush with args other than QBrush''' + + def testSetBrushGradient(self): + painter = QPainter() + gradient = QLinearGradient(0, 0, 0, 0) + painter.setBrush(gradient) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qpen_test.py b/tests/QtGui/qpen_test.py new file mode 100644 index 000000000..f9e9b1861 --- /dev/null +++ b/tests/QtGui/qpen_test.py @@ -0,0 +1,20 @@ + +import unittest + +from PySide.QtCore import Qt +from PySide.QtGui import QPen + +class QPenTest(unittest.TestCase): + + def testCtorWithCreatedEnums(self): + '''A simple case of QPen creation using created enums.''' + width = 0 + style = Qt.PenStyle(0) + cap = Qt.PenCapStyle(0) + join = Qt.PenJoinStyle(0) + pen = QPen(Qt.blue, width, style, cap, join) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qpixmap_test.py b/tests/QtGui/qpixmap_test.py new file mode 100644 index 000000000..481409462 --- /dev/null +++ b/tests/QtGui/qpixmap_test.py @@ -0,0 +1,62 @@ +import unittest + +import os +from helper import UsesQApplication +from PySide.QtGui import * +from PySide.QtCore import * + +class QPixmapTest(UsesQApplication): + def testQVariantConstructor(self): + pixmap = QPixmap() + v = QVariant(pixmap) + pixmap_copy = QPixmap(v) + + def testQSizeConstructor(self): + pixmap = QPixmap(QSize(10,20)) + self.assert_(pixmap.size().height(), 20) + + def testQStringConstructor(self): + pixmap = QPixmap(QString("Testing!")) + + def testQVariantConstructor2(self): + v = QVariant(QPixmap()) + pixmap2 = QPixmap(v) + v = QVariant(QImage()) + pixmap2 = QPixmap(v) + + def testQPixmapLoadFromDataWithQFile(self): + f = QFile(os.path.join(os.path.dirname(__file__), 'sample.png')) + self.assert_(f.open(QIODevice.ReadOnly)) + data = f.read(f.size()) + f.close() + pixmap = QPixmap() + self.assert_(pixmap.loadFromData(data)) + + def testQPixmapLoadFromDataWithPython(self): + data = open(os.path.join(os.path.dirname(__file__),'sample.png'),'rb').read() + pixmap = QPixmap() + self.assert_(pixmap.loadFromData(data)) + + +class QPixmapToImage(UsesQApplication): + + def testFilledImage(self): + '''QPixmap.fill + toImage + image.pixel''' + pixmap = QPixmap(100, 200) + pixmap.fill(Qt.red) # Default Qt.white + + self.assertEqual(pixmap.height(), 200) + self.assertEqual(pixmap.width(), 100) + + image = pixmap.toImage() + + self.assertEqual(image.height(), 200) + self.assertEqual(image.width(), 100) + + pixel = image.pixel(10,10) + self.assertEqual(pixel, QColor(Qt.red).rgba()) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qpushbutton_test.py b/tests/QtGui/qpushbutton_test.py new file mode 100644 index 000000000..984960879 --- /dev/null +++ b/tests/QtGui/qpushbutton_test.py @@ -0,0 +1,30 @@ +import unittest + +from helper import UsesQApplication +from PySide.QtGui import QPushButton, QMenu, QWidget +from PySide.QtCore import QTimer + +class MyWidget(QWidget): + def __init__(self): + QWidget.__init__(self) + + m = QMenu(self) + b = QPushButton("Hello", self) + b.setMenu(m) + + +class QPushButtonTest(UsesQApplication): + def createMenu(self, button): + m = QMenu() + button.setMenu(m) + + def testSetMenu(self): + w = MyWidget() + w.show() + + timer = QTimer.singleShot(100, self.app.quit) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qradialgradient_test.py b/tests/QtGui/qradialgradient_test.py new file mode 100644 index 000000000..0c582c341 --- /dev/null +++ b/tests/QtGui/qradialgradient_test.py @@ -0,0 +1,29 @@ +import unittest + +from PySide.QtGui import QRadialGradient +from PySide.QtCore import QPointF + +class QRadialGradientConstructor(unittest.TestCase): + def _compare(self, qptf, tpl): + self.assertEqual((qptf.x(), qptf.y()), tpl) + + def _assertValues(self, grad): + self._compare(grad.center(), (1.0, 2.0)) + self._compare(grad.focalPoint(), (3.0, 4.0)) + self.assertEqual(grad.radius(), 5.0) + + def testAllInt(self): + grad = QRadialGradient(1, 2, 5, 3, 4) + self._assertValues(grad) + + def testQPointF(self): + grad = QRadialGradient(QPointF(1, 2), 5, QPointF(3, 4)) + self._assertValues(grad) + + def testSetQPointF(self): + grad = QRadialGradient() + grad.setCenter(QPointF(1, 2)) + self._compare(grad.center(), (1.0, 2.0)) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qregion_test.py b/tests/QtGui/qregion_test.py new file mode 100644 index 000000000..2274d5e92 --- /dev/null +++ b/tests/QtGui/qregion_test.py @@ -0,0 +1,21 @@ +import unittest +import sys + +from PySide.QtGui import QRegion +from PySide.QtCore import QPoint +from helper import UsesQApplication + +class QRegionTest(UsesQApplication): + + def testFunctionUnit(self): + r = QRegion(0, 0, 10, 10) + r2 = QRegion(5, 5, 10, 10) + + ru = r.united(r2) + self.assert_(ru.contains(QPoint(0,0))) + self.assert_(ru.contains(QPoint(5,5))) + self.assert_(ru.contains(QPoint(10,10))) + self.assert_(ru.contains(QPoint(14,14))) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qshortcut_test.py b/tests/QtGui/qshortcut_test.py new file mode 100644 index 000000000..c9cb3bc7c --- /dev/null +++ b/tests/QtGui/qshortcut_test.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +''' Test the QShortcut constructor''' + +import unittest +import sys + +from PySide import QtGui, QtCore + +class Foo(QtGui.QWidget): + def __init__(self): + QtGui.QWidget.__init__(self) + self.ok = False + self.copy = False + + def slot_of_foo(self): + self.ok = True + + def slot_of_copy(self): + self.copy = True + +class MyShortcut(QtGui.QShortcut): + def __init__(self, keys, wdg, slot): + QtGui.QShortcut.__init__(self, keys, wdg, slot) + + def emit_signal(self): + self.emit(QtCore.SIGNAL("activated()")) + +class QAppPresence(unittest.TestCase): + + def testQShortcut(self): + self.qapp = QtGui.QApplication([]) + f = Foo() + + self.sc = MyShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return), f, f.slot_of_foo) + self.scstd = MyShortcut(QtGui.QKeySequence.Copy, f, f.slot_of_copy) + QtCore.QTimer.singleShot(0, self.init); + self.qapp.exec_() + self.assertEquals(f.ok, True) + self.assertEquals(f.copy, True) + + def init(self): + self.sc.emit_signal(); + self.scstd.emit_signal(); + self.qapp.quit() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qstandarditemmodel_test.py b/tests/QtGui/qstandarditemmodel_test.py new file mode 100644 index 000000000..d83d856da --- /dev/null +++ b/tests/QtGui/qstandarditemmodel_test.py @@ -0,0 +1,26 @@ +import unittest + +from PySide.QtGui import * +from PySide.QtCore import * + +from helper import UsesQApplication + +class QStandardItemModelTest(UsesQApplication): + + def setUp(self): + super(QStandardItemModelTest, self).setUp() + self.window = QWidget() + self.model = QStandardItemModel(0, 3, self.window) + + def tearDown(self): + del self.window + del self.model + super(QStandardItemModelTest, self).tearDown() + + def testInsertRow(self): + # bug #227 + self.model.insertRow(0) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qstring_qkeysequence_test.py b/tests/QtGui/qstring_qkeysequence_test.py new file mode 100644 index 000000000..1f435e6ee --- /dev/null +++ b/tests/QtGui/qstring_qkeysequence_test.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Tests conversions of QString to and from QKeySequence.''' + +import unittest +from helper import UsesQApplication + +from PySide.QtCore import QString +from PySide.QtGui import QKeySequence, QAction + +class QStringQKeySequenceTest(UsesQApplication): + '''Tests conversions of QString to and from QKeySequence.''' + + def testQStringFromQKeySequence(self): + '''Creates a QString from a QKeySequence.''' + keyseq = 'Ctrl+A' + a = QString(QKeySequence(keyseq)) + self.assertEqual(a, keyseq) + + def testQStringAsQKeySequence(self): + '''Passes a QString to an argument expecting a QKeySequence.''' + keyseq = QString('Ctrl+A') + action = QAction(None) + action.setShortcut(keyseq) + shortcut = action.shortcut() + self.assert_(isinstance(shortcut, QKeySequence)) + self.assertEqual(shortcut.toString(), keyseq) + + def testPythonStringAsQKeySequence(self): + '''Passes a Python string to an argument expecting a QKeySequence.''' + keyseq = 'Ctrl+A' + action = QAction(None) + action.setShortcut(keyseq) + shortcut = action.shortcut() + self.assert_(isinstance(shortcut, QKeySequence)) + self.assertEqual(shortcut.toString(), keyseq) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qstyle_test.py b/tests/QtGui/qstyle_test.py new file mode 100755 index 000000000..da467e871 --- /dev/null +++ b/tests/QtGui/qstyle_test.py @@ -0,0 +1,32 @@ + +import unittest +from helper import UsesQApplication + +from PySide.QtGui import QWidget, QLabel, QFontComboBox, QStyleFactory + +class SetStyleTest(UsesQApplication): + '''Tests setting the same QStyle for all objects in a UI hierarchy.''' + + def testSetStyle(self): + '''All this test have to do is not break with some invalid Python wrapper.''' + + def setStyleHelper(widget, style): + widget.setStyle(style) + widget.setPalette(style.standardPalette()) + for child in widget.children(): + if isinstance(child, QWidget): + setStyleHelper(child, style) + + container = QWidget() + # QFontComboBox is used because it has an QLineEdit created in C++ inside it, + # and if the QWidget.setStyle(style) steals the ownership of the style + # for the C++ originated widget everything will break. + fontComboBox = QFontComboBox(container) + label = QLabel(container) + label.setText('Label') + style = QStyleFactory.create(QStyleFactory.keys()[0]) + setStyleHelper(container, style) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qtableview_test.py b/tests/QtGui/qtableview_test.py new file mode 100644 index 000000000..0ea5cab8a --- /dev/null +++ b/tests/QtGui/qtableview_test.py @@ -0,0 +1,17 @@ + +import unittest + +from PySide.QtCore import QAbstractTableModel +from PySide.QtGui import QTableWidget +from helper import UsesQApplication + +class QPenTest(UsesQApplication): + + def testItemModel(self): + tv = QTableWidget() + + self.assertEqual(type(tv.model()), QAbstractTableModel) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qtabwidget_test.py b/tests/QtGui/qtabwidget_test.py new file mode 100644 index 000000000..143f99cab --- /dev/null +++ b/tests/QtGui/qtabwidget_test.py @@ -0,0 +1,21 @@ + +import unittest + +from PySide.QtGui import QTabWidget +from helper import TimedQApplication + +class RemoveTabMethod(TimedQApplication): + def setUp(self): + TimedQApplication.setUp(self) + self.tab = QTabWidget() + + def tearDown(self): + del self.tab + TimedQApplication.tearDown(self) + + + def testRemoveTabPresence(self): + self.assert_(getattr(self.tab, 'removeTab')) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qtextedit_test.py b/tests/QtGui/qtextedit_test.py new file mode 100644 index 000000000..442cbe2cf --- /dev/null +++ b/tests/QtGui/qtextedit_test.py @@ -0,0 +1,32 @@ +'''Test cases for QTextEdit and ownership problems.''' + +import unittest +from sys import getrefcount +from PySide.QtGui import QTextEdit + +from helper import UsesQApplication + +class DontTouchReference(UsesQApplication): + '''Check if the QTextTable returned by QTextCursor.insertTable() is not + referenced by the QTextCursor that returns it.''' + + def setUp(self): + super(DontTouchReference, self).setUp() + self.editor = QTextEdit() + self.cursor = self.editor.textCursor() + self.table = self.cursor.insertTable(1, 1) + + def testQTextTable(self): + # methods which return QTextTable should not increment its reference + self.assertEqual(getrefcount(self.table), 2) + f = self.cursor.currentFrame() + del f + self.assertEqual(getrefcount(self.table), 2) + # destroying the cursor should not raise any "RuntimeError: internal + # C++ object already deleted." when accessing the QTextTable + del self.cursor + self.assertEqual(getrefcount(self.table), 2) + cell = self.table.cellAt(0, 0) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/QtGui/qtoolbar_test.py b/tests/QtGui/qtoolbar_test.py new file mode 100644 index 000000000..1bcf566db --- /dev/null +++ b/tests/QtGui/qtoolbar_test.py @@ -0,0 +1,35 @@ + +'''Test cases for QToolbar''' + +import unittest + +from PySide.QtGui import QToolBar, QMainWindow, QAction + +from helper import UsesQApplication + +class AddActionText(UsesQApplication): + '''Test case for calling QToolbar.addAction passing a text''' + + def setUp(self): + #Acquire resources + super(AddActionText, self).setUp() + self.window = QMainWindow() + self.toolbar = QToolBar() + self.window.addToolBar(self.toolbar) + + def tearDown(self): + #Release resources + super(AddActionText, self).tearDown() + del self.toolbar + del self.window + + def testText(self): + #QToolBar.addAction(text) - add a QToolButton + self.toolbar.addAction('aaaa') + self.assertEqual(len(self.toolbar.actions()), 1) + action = self.toolbar.actions()[0] + self.assert_(isinstance(action, QAction)) + self.assertEqual(action.text(), 'aaaa') + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qtoolbox_test.py b/tests/QtGui/qtoolbox_test.py new file mode 100644 index 000000000..dd0d2c6a5 --- /dev/null +++ b/tests/QtGui/qtoolbox_test.py @@ -0,0 +1,31 @@ + +import unittest + +from PySide.QtGui import QToolBox, QWidget, QIcon + +from helper import UsesQApplication + +class OwnershipControl(UsesQApplication): + + def setUp(self): + super(OwnershipControl, self).setUp() + self.toolbox = QToolBox() + + def tearDown(self): + del self.toolbox + super(OwnershipControl, self).tearDown() + + def testAddItem(self): + # Was losing ownership of the widget. + index = self.toolbox.addItem(QWidget(), 'item') + item = self.toolbox.widget(index) + self.assert_(isinstance(item, QWidget)) + + def testAddItemWithIcon(self): + index = self.toolbox.addItem(QWidget(), QIcon(), 'item') + item = self.toolbox.widget(index) + self.assert_(isinstance(item, QWidget)) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qvariant_test.py b/tests/QtGui/qvariant_test.py new file mode 100644 index 000000000..138e43291 --- /dev/null +++ b/tests/QtGui/qvariant_test.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test cases for QVariant with QtGui types''' + +import unittest + +from PySide.QtCore import * +from PySide.QtGui import * + +from helper import UsesQApplication + +class Dummy(object): + pass + +class QVariantTypeName(unittest.TestCase): + def testQPen(self): + obj = QVariant(QPen(Qt.red)) + self.assertEqual('QPen', obj.typeName()) + + def testQColor(self): + obj = QVariant(QColor(Qt.red)) + self.assertEqual('QColor', obj.typeName()) + + def testGlobalColor(self): + obj = QVariant(Qt.red) + # XXX: PyQt4 returns int instead of QColor like the C++ version + self.assertEqual('QColor', obj.typeName()) + + def testEnums(self): + obj = QVariant(Qt.SolidLine) + self.assertEqual('int', obj.typeName()) + +class QVariantQColorImplicitlyConvertion(unittest.TestCase): + def testConversions(self): + c1 = QColor(0, 0, 0) + v = QVariant(c1) + c2 = QColor(v) + self.assertEqual(c1, c2) + +class QVariantQPixmap(UsesQApplication): + '''QVariant(QPixmap)''' + + def testBasic(self): + '''QVariant(QPixmap)''' + pixmap = QPixmap(10,20) + pixmap.fill(Qt.blue) + variant = QVariant(pixmap) + + self.assertEqual(variant.typeName(), "QPixmap") + + def testQObject(self): + obj = QObject() + v = QVariant(obj) + self.assertEqual(v.typeName(), 'QObject*') + + def testQWidget(self): + obj = QWidget() + v = QVariant(obj) + self.assertEqual(v.typeName(), 'QWidget*') + +class MyColor(QColor): + pass + +class MyPrimitive(int): + pass + +class QVariantMess(unittest.TestCase): + def testMyColor(self): + c1 = MyColor() + v = QVariant(c1) + self.assertEqual(type(v.toPyObject()), MyColor) + + def testMyPrimitive(self): + p = MyPrimitive(3) + v = QVariant(p) + self.assertNotEqual(v.type(), QVariant.Int) + self.assertTrue(v.toPyObject() is p) + + def testMatrix2x2(self): + m = QMatrix2x2() + v = QVariant(m) + self.assertEqual('QMatrix2x2', v.typeName()) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qwidget_setlayout_test.py b/tests/QtGui/qwidget_setlayout_test.py new file mode 100644 index 000000000..c715396ed --- /dev/null +++ b/tests/QtGui/qwidget_setlayout_test.py @@ -0,0 +1,33 @@ +#!/usr/bin/python + +import unittest + +from PySide.QtGui import QWidget, QVBoxLayout, QPushButton, QApplication, QHBoxLayout +from helper import UsesQApplication + +class QWidgetTest(UsesQApplication): + + def test_setLayout(self): + layout = QVBoxLayout() + btn1 = QPushButton("button_v1") + layout.addWidget(btn1) + + btn2 = QPushButton("button_v2") + layout.addWidget(btn2) + + layout2 = QHBoxLayout() + + btn1 = QPushButton("button_h1") + layout2.addWidget(btn1) + + btn2 = QPushButton("button_h2") + layout2.addWidget(btn2) + + layout.addLayout(layout2) + + widget = QWidget() + widget.setLayout(layout) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/qwidget_test.py b/tests/QtGui/qwidget_test.py new file mode 100644 index 000000000..a14311c13 --- /dev/null +++ b/tests/QtGui/qwidget_test.py @@ -0,0 +1,30 @@ + +import unittest + +from PySide.QtGui import QWidget, QMainWindow +from helper import UsesQApplication + +class QWidgetInherit(QMainWindow): + def __init__(self): + QWidget.__init__(self) + +class QWidgetTest(UsesQApplication): + + def testInheritance(self): + newobj = QWidgetInherit() + widget = QWidget() + newobj.setCentralWidget(widget) + self.assertEqual(widget, newobj.centralWidget()) + +class QWidgetVisible(UsesQApplication): + + def testBasic(self): + # Also related to bug #244, on existence of setVisible''' + widget = QWidget() + self.assert_(not widget.isVisible()) + widget.setVisible(True) + self.assert_(widget.isVisible()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/reference_count_test.py b/tests/QtGui/reference_count_test.py new file mode 100644 index 000000000..b54986821 --- /dev/null +++ b/tests/QtGui/reference_count_test.py @@ -0,0 +1,71 @@ + +'''Test cases for Reference count when the object is created in c++ side''' + +import unittest + +import sys +import weakref +import gc + + +from PySide.QtCore import Qt, QPointF +from PySide.QtGui import QApplication, QGraphicsScene, QGraphicsRectItem, QPolygonF, QGraphicsPolygonItem, QGraphicsRectItem + +from helper import UsesQApplication + +destroyedRect = False +destroyedPol = False + +def rect_del(o): + global destroyedRect + destroyedRect = True + +def pol_del(o): + global destroyedPol + destroyedPol = True + +class ReferenceCount(UsesQApplication): + + def setUp(self): + super(ReferenceCount, self).setUp() + self.scene = QGraphicsScene() + + def tearDown(self): + super(ReferenceCount, self).tearDown() + + def beforeTest(self): + points = [QPointF(0, 0), QPointF(100, 100), QPointF(0, 100)] + pol = self.scene.addPolygon(QPolygonF(points)) + self.assert_(isinstance(pol, QGraphicsPolygonItem)) + self.wrp = weakref.ref(pol, pol_del) + + #refcount need be 3 because one ref for QGraphicsScene, and one to rect obj + self.assertEqual(sys.getrefcount(pol), 3) + + def testReferenceCount(self): + global destroyedRect + global destroyedPol + + self.beforeTest() + + rect = self.scene.addRect(10.0, 10.0, 10.0, 10.0) + self.assert_(isinstance(rect, QGraphicsRectItem)) + + self.wrr = weakref.ref(rect, rect_del) + + #refcount need be 3 because one ref for QGraphicsScene, and one to rect obj + self.assertEqual(sys.getrefcount(rect), 3) + + del rect + #not destroyed because one ref continue in QGraphicsScene + self.assertEqual(destroyedRect, False) + self.assertEqual(destroyedPol, False) + + del self.scene + + #QGraphicsScene was destroyed and this destroy internal ref to rect + self.assertEqual(destroyedRect, True) + self.assertEqual(destroyedPol, True) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/sample.png b/tests/QtGui/sample.png new file mode 100644 index 000000000..60450f0dc Binary files /dev/null and b/tests/QtGui/sample.png differ diff --git a/tests/QtGui/standardpixmap_test.py b/tests/QtGui/standardpixmap_test.py new file mode 100644 index 000000000..65bd3220a --- /dev/null +++ b/tests/QtGui/standardpixmap_test.py @@ -0,0 +1,15 @@ + +import unittest + +from PySide.QtGui import QPixmap, QStyle + +from helper import UsesQApplication + +class StandardPixmapTest(UsesQApplication): + def testDefaultOptions(self): # Bug 253 + pixmap = self.app.style().standardPixmap(QStyle.SP_DirClosedIcon) + self.assert_(isinstance(pixmap, QPixmap)) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/timed_app_test.py b/tests/QtGui/timed_app_test.py new file mode 100644 index 000000000..4af9a0130 --- /dev/null +++ b/tests/QtGui/timed_app_test.py @@ -0,0 +1,14 @@ + +import unittest + +from helper import TimedQApplication + +class TestTimedApp(TimedQApplication): + '''Simple test case for TimedQApplication''' + + def testFoo(self): + #Simple test of TimedQApplication + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/virtual_protected_inheritance_test.py b/tests/QtGui/virtual_protected_inheritance_test.py new file mode 100644 index 000000000..15de37dfb --- /dev/null +++ b/tests/QtGui/virtual_protected_inheritance_test.py @@ -0,0 +1,70 @@ + +'''Test cases for overriding inherited protected virtual methods''' + +import unittest + +from PySide.QtCore import QTimerEvent +from PySide.QtGui import QApplication, QSpinBox + +from helper import UsesQApplication + +class MySpinButton(QSpinBox): + '''Simple example class of overriding QObject.timerEvent''' + + def __init__(self, max_runs=5, app=None): + #Creates a new spinbox that will run and quit + super(MySpinButton, self).__init__() + + if app is None: + app = QApplication([]) + + self.app = app + self.max_runs = max_runs + self.runs = 0 + + def timerEvent(self, event): + #Timer event method + self.runs += 1 + + self.setValue(self.runs) + + if self.runs == self.max_runs: + self.app.quit() + + if not isinstance(event, QTimerEvent): + raise TypeError('Invalid event type. Must be TimerEvent') + +class TimerEventTest(UsesQApplication): + '''Test case for running QObject.timerEvent from inherited class''' + + qapplication = True + + def setUp(self): + #Acquire resources + super(TimerEventTest, self).setUp() + self.widget = MySpinButton(app=self.app) + + def tearDown(self): + #Release resources + del self.widget + super(TimerEventTest, self).tearDown() + + def testMethod(self): + #QWidget.timerEvent overrinding (protected inherited) + timer_id = self.widget.startTimer(0) + + self.app.exec_() + + self.widget.killTimer(timer_id) + + self.assertEqual(self.widget.runs, 5) + + +if __name__ == '__main__': + unittest.main() + #app = QApplication([]) + #widget = MySpinButton(app=app) + #widget.startTimer(500) + #widget.show() + #app.exec_() + diff --git a/tests/QtGui/virtual_pure_override.py b/tests/QtGui/virtual_pure_override.py new file mode 100644 index 000000000..c496e4907 --- /dev/null +++ b/tests/QtGui/virtual_pure_override.py @@ -0,0 +1,48 @@ +#!/usr/bin/python + +import unittest + +from PySide.QtGui import QGraphicsScene, QGraphicsRectItem, QGraphicsView, QApplication, QBrush, QColor +from PySide.QtCore import QTimer +from helper import UsesQApplication + +qgraphics_item_painted = False + +class RoundRectItem(QGraphicsRectItem): + + def __init__(self, x, y, w, h): + QGraphicsRectItem.__init__(self, x, y, w, h) + + def paint(self, painter, qstyleoptiongraphicsitem, qwidget): + global qgraphics_item_painted + qgraphics_item_painted = True + + +class QGraphicsItemTest(UsesQApplication): + + def createRoundRect(self, scene): + item = RoundRectItem(10, 10, 100, 100) + item.setBrush(QBrush(QColor(255, 0, 0))) + scene.addItem(item) + return item + + def quit_app(self): + self.app.quit() + + def test_setParentItem(self): + global qgraphics_item_painted + + scene = QGraphicsScene() + scene.addText("test") + view = QGraphicsView(scene) + + rect = self.createRoundRect(scene) + view.show() + QTimer.singleShot(1000, self.quit_app) + self.app.exec_() + self.assert_(qgraphics_item_painted) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtGui/wrong_return_test.py b/tests/QtGui/wrong_return_test.py new file mode 100644 index 000000000..d14ac9e98 --- /dev/null +++ b/tests/QtGui/wrong_return_test.py @@ -0,0 +1,23 @@ +'''Test cases for Virtual functions with wrong return type''' + +import unittest + +from PySide import QtCore, QtGui + +from helper import UsesQApplication + +class MyWidget(QtGui.QWidget): + def __init__(self, parent=None): + super(MyWidget, self).__init__(parent) + + def sizeHint(self): + pass + +class testCase(UsesQApplication): + + def testVirtualReturn(self): + w = MyWidget() + self.assertRaises(TypeError, w.show) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/x11_symbols.py b/tests/QtGui/x11_symbols.py new file mode 100644 index 000000000..29cce150e --- /dev/null +++ b/tests/QtGui/x11_symbols.py @@ -0,0 +1,17 @@ + +''' Test the presence of X11 symbols in QtGui''' + +import unittest + +from PySide.QtGui import QPixmap + +class X11Test(unittest.TestCase): + + def test(self): + self.assert_('handle' in dir(QPixmap)) + self.assert_('x11Info' in dir(QPixmap)) + self.assert_('x11PictureHandle' in dir(QPixmap)) + self.assert_('x11SetDefaultScreen' in dir(QPixmap)) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtHelp/CMakeLists.txt b/tests/QtHelp/CMakeLists.txt new file mode 100644 index 000000000..d0ba2d80c --- /dev/null +++ b/tests/QtHelp/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(help_test.py) diff --git a/tests/QtHelp/help_test.py b/tests/QtHelp/help_test.py new file mode 100644 index 000000000..e2ff532a6 --- /dev/null +++ b/tests/QtHelp/help_test.py @@ -0,0 +1,14 @@ + +import unittest + +from PySide.QtHelp import QHelpEngine + +from helper import UsesQApplication + +class QHelpEngineCreation(UsesQApplication): + + def testConstructor(self): + helpEngine = QHelpEngine('mycollection.qch') + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtMaemo5/CMakeLists.txt b/tests/QtMaemo5/CMakeLists.txt new file mode 100644 index 000000000..73bb316f5 --- /dev/null +++ b/tests/QtMaemo5/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(pickselector_test.py) +PYSIDE_TEST(qmaemo5import_test.py) diff --git a/tests/QtMaemo5/pickselector_test.py b/tests/QtMaemo5/pickselector_test.py new file mode 100644 index 000000000..013c1d40b --- /dev/null +++ b/tests/QtMaemo5/pickselector_test.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +import unittest +from PySide.QtMaemo5 import QMaemo5ListPickSelector, QMaemo5ValueButton + +from helper import UsesQApplication + +class PickSelectorTest(UsesQApplication): + def testOwnership(self): + pickselector = QMaemo5ListPickSelector() + button = QMaemo5ValueButton("test") + button.setPickSelector(pickselector) + del pickselector + self.assert_(button.pickSelector()) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtMaemo5/qmaemo5import_test.py b/tests/QtMaemo5/qmaemo5import_test.py new file mode 100644 index 000000000..a003f056a --- /dev/null +++ b/tests/QtMaemo5/qmaemo5import_test.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import unittest +from PySide.QtMaemo5 import * +from PySide import QtGui + +from helper import UsesQApplication + +class QtMamo5Test(UsesQApplication): + + def testObjectCreate(self): + bar = QMaemo5EditBar() + self.assert_(isinstance(bar, QMaemo5EditBar)) + + def testGui(self): + getattr(QtGui, 'QAbstractKineticScroller') + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtMultimedia/CMakeLists.txt b/tests/QtMultimedia/CMakeLists.txt new file mode 100644 index 000000000..62150eb79 --- /dev/null +++ b/tests/QtMultimedia/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(audio_test.py) diff --git a/tests/QtMultimedia/audio_test.py b/tests/QtMultimedia/audio_test.py new file mode 100644 index 000000000..04d0a1e05 --- /dev/null +++ b/tests/QtMultimedia/audio_test.py @@ -0,0 +1,32 @@ + +'''Test cases for QHttp''' + +import unittest + +from PySide.QtCore import * +from PySide.QtMultimedia import * + +class testAudioDevices(unittest.TestCase): + + def testListDevices(self): + for devInfo in QAudioDeviceInfo.availableDevices(QAudio.AudioOutput): + fmt = QAudioFormat() + for codec in devInfo.supportedCodecs(): + fmt.setCodec(codec) + for frequency in devInfo.supportedFrequencies(): + fmt.setFrequency(frequency) + for channels in devInfo.supportedChannels(): + fmt.setChannels(channels) + for sampleType in devInfo.supportedSampleTypes(): + fmt.setSampleType(sampleType) + for sampleSize in devInfo.supportedSampleSizes(): + fmt.setSampleSize(sampleSize) + for endian in devInfo.supportedByteOrders(): + fmt.setByteOrder(endian) + if devInfo.isFormatSupported(fmt): + return + self.assert_(False) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtNetwork/CMakeLists.txt b/tests/QtNetwork/CMakeLists.txt new file mode 100644 index 000000000..cae147080 --- /dev/null +++ b/tests/QtNetwork/CMakeLists.txt @@ -0,0 +1,4 @@ +PYSIDE_TEST(accessManager_test.py) +PYSIDE_TEST(http_test.py) +PYSIDE_TEST(tcpserver_test.py) +PYSIDE_TEST(udpsocket_test.py) diff --git a/tests/QtNetwork/accessManager_test.py b/tests/QtNetwork/accessManager_test.py new file mode 100644 index 000000000..9a00e7e79 --- /dev/null +++ b/tests/QtNetwork/accessManager_test.py @@ -0,0 +1,23 @@ + +'''Test cases for QHttp''' + +import unittest + +from PySide.QtCore import * +from PySide.QtNetwork import * + +from helper import UsesQApplication + +class AccessManagerCase(UsesQApplication): + def slot_replyFinished(self, reply): + self.assertEqual(type(reply), QNetworkReply) + self.app.quit() + + def testNetworkRequest(self): + manager = QNetworkAccessManager() + manager.finished.connect(self.slot_replyFinished) + manager.get(QNetworkRequest(QUrl("http://qt.nokia.com"))) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtNetwork/http_test.py b/tests/QtNetwork/http_test.py new file mode 100644 index 000000000..379ff5dfb --- /dev/null +++ b/tests/QtNetwork/http_test.py @@ -0,0 +1,67 @@ + +'''Test cases for QHttp''' + +import unittest + +from PySide.QtCore import * +from PySide.QtNetwork import * + +from helper import UsesQApplication + +""" +class HttpSignalsCase(UsesQApplication): + '''Test case for launching QHttp signals''' + + def setUp(self): + super(HttpSignalsCase, self).setUp() + + self.http = QHttp() + self.url = QUrl('http://www.google.com') + self.timer = QTimer.singleShot(250, self.app.quit) + + def tearDown(self): + del self.http + super(HttpSignalsCase, self).tearDown() + + def callback(self, ident): + self.called = True + + def testDefaultArgs(self): + #QHttp signal requestStarted signal + # @bug 114 + QObject.connect(self.http, SIGNAL('requestStarted(int)'), self.callback) + self.http.get(self.url.path()) + + self.app.exec_() + self.assert_(self.called) + +class testHttp(UsesQApplication): + def testRead(self): + header = QHttpRequestHeader("GET", QString(QUrl.toPercentEncoding("/index.html"))) + header.setValue("Host", "qtsoftware.com"); + http = QHttp() + http.setHost("qtsoftware.com") + http.request(header) + data = http.read(100) +""" + +class testAuthenticationSignal(UsesQApplication): + def onAuthRequest(self, hostname, port, auth): + self.assert_(isinstance(auth, QAuthenticator)) + print auth.realm() + self._resultOk = True + self.app.exit() + + def testwaitSignal(self): + self._resultOk = False + http = QHttp() + http.setHost("projects.maemo.org", QHttp.ConnectionModeHttps, 0) + http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest) + path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/") + print http.get(path) + self.app.exec_() + self.assert_(self._resultOk) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtNetwork/tcpserver_test.py b/tests/QtNetwork/tcpserver_test.py new file mode 100644 index 000000000..77f830e36 --- /dev/null +++ b/tests/QtNetwork/tcpserver_test.py @@ -0,0 +1,25 @@ + +'''Test cases for QTCPServer''' + +import unittest + +from PySide.QtNetwork import QTcpServer + +class ListenDefaultArgsCase(unittest.TestCase): + '''Test case for TcpServer.listen with default args''' + + def setUp(self): + #Acquire resources + self.server = QTcpServer() + + def tearDown(self): + #Release resources + del self.server + + def testDefaultArgs(self): + # @bug 108 + #Default arguments for QTcpServer.listen + self.server.listen() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtNetwork/udpsocket_test.py b/tests/QtNetwork/udpsocket_test.py new file mode 100644 index 000000000..26cff7f65 --- /dev/null +++ b/tests/QtNetwork/udpsocket_test.py @@ -0,0 +1,54 @@ + +'''Test cases for QUdpSocket''' + +import unittest + +from PySide.QtCore import QUrl, QObject, SIGNAL, QCoreApplication, QTimer +from PySide.QtNetwork import QUdpSocket, QHostAddress + +class HttpSignalsCase(unittest.TestCase): + '''Test case for bug #124 - readDatagram signature + + QUdpSocket.readDatagram must return a tuple with the datagram, host and + port, while receiving only the max payload size.''' + + def setUp(self): + #Acquire resources + self.app = QCoreApplication([]) + self.socket = QUdpSocket() + self.socket.bind(45454) + self.server = QUdpSocket() + self.timer = QTimer.singleShot(1000, self.app.quit) + self.a = QTimer.singleShot(100, self.broadcast) + #self.a = QTimer() + #self.a.setInterval(100) + #QObject.connect(self.a, SIGNAL('timeout()'), self.broadcast) + #self.a.start() + + def tearDown(self): + #Release resources + del self.socket + del self.server + del self.app + + def broadcast(self): + addr = QHostAddress(QHostAddress.Broadcast) + self.server.writeDatagram('datagram', addr, 45454) + + def callback(self): + while self.socket.hasPendingDatagrams(): + datagram, host, port = self.socket.readDatagram( + self.socket.pendingDatagramSize()) + self.called = True + self.app.quit() + + def testDefaultArgs(self): + #QUdpSocket.readDatagram pythonic return + # @bug 124 + QObject.connect(self.socket, SIGNAL('readyRead()'), self.callback) + self.app.exec_() + + self.assert_(self.called) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtOpenGL/CMakeLists.txt b/tests/QtOpenGL/CMakeLists.txt new file mode 100644 index 000000000..3064edfbc --- /dev/null +++ b/tests/QtOpenGL/CMakeLists.txt @@ -0,0 +1,3 @@ +if(${QTVERSION} VERSION_GREATER 4.6.9) + PYSIDE_TEST(qglbuffer_test.py) +endif() diff --git a/tests/QtOpenGL/qglbuffer_test.py b/tests/QtOpenGL/qglbuffer_test.py new file mode 100644 index 000000000..ae23fbdf3 --- /dev/null +++ b/tests/QtOpenGL/qglbuffer_test.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +'''Unit tests for QGLBuffer''' + +import unittest + +from PySide.QtCore import QByteArray +from PySide.QtOpenGL import QGLBuffer, QGLWidget + +from helper import UsesQApplication + +class QGLBufferTest(UsesQApplication): + def usageCheck(self, t): + w = QGLWidget() + w.makeCurrent() + + b = QGLBuffer(t) + self.assertEqual(b.usagePattern(), QGLBuffer.StaticDraw) + b.setUsagePattern(QGLBuffer.DynamicDraw) + + self.assert_(b.create()) + self.assert_(b.bufferId() != 0) + self.assert_(b.bind()) + + data = QByteArray("12345") + b.allocate(data) + self.assertEqual(b.size(), data.size()) + + m = b.map(QGLBuffer.ReadOnly) + self.assertEqual(m.data(), data.data()) + b.unmap() + + other_data = QByteArray("67") + b.write(0, other_data) + m = b.map(QGLBuffer.ReadOnly) + self.assertEqual(m.mid(0, other_data.size()).data(), other_data.data()) + b.unmap() + + result, rdata = b.read(0, other_data.size()) + print result, rdata + self.assert_(result) + self.assertEqual(other_data.data(), rdata.data()) + + b.release() + + def testUsage(self): + self.usageCheck(QGLBuffer.IndexBuffer) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtScript/CMakeLists.txt b/tests/QtScript/CMakeLists.txt new file mode 100644 index 000000000..b76a26299 --- /dev/null +++ b/tests/QtScript/CMakeLists.txt @@ -0,0 +1,3 @@ +PYSIDE_TEST(base_test.py) +PYSIDE_TEST(engine_test.py) +PYSIDE_TEST(test_base.py) diff --git a/tests/QtScript/base_test.py b/tests/QtScript/base_test.py new file mode 100644 index 000000000..6ad27e007 --- /dev/null +++ b/tests/QtScript/base_test.py @@ -0,0 +1,4 @@ +from PySide import QtScript + + +#only test if the module import works fine bug #278 diff --git a/tests/QtScript/engine_test.py b/tests/QtScript/engine_test.py new file mode 100644 index 000000000..074d3df40 --- /dev/null +++ b/tests/QtScript/engine_test.py @@ -0,0 +1,13 @@ +import unittest + +from PySide.QtCore import QObject +from PySide.QtScript import QScriptEngine + +class QScriptEngineTest(unittest.TestCase): + + def testQScriptEngine(self): + engine = QScriptEngine() + obj = engine.evaluate("({ unitName: 'Celsius', toKelvin: function(x) { return x + 273; } })") + toKelvin = obj.property("toKelvin") + result = toKelvin.call(obj, [100]) + self.assertEqual(result.toNumber(), 373) diff --git a/tests/QtScript/test_base.py b/tests/QtScript/test_base.py new file mode 100644 index 000000000..6ad27e007 --- /dev/null +++ b/tests/QtScript/test_base.py @@ -0,0 +1,4 @@ +from PySide import QtScript + + +#only test if the module import works fine bug #278 diff --git a/tests/QtScriptTools/CMakeLists.txt b/tests/QtScriptTools/CMakeLists.txt new file mode 100644 index 000000000..ee22737c6 --- /dev/null +++ b/tests/QtScriptTools/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(debugger_test.py) diff --git a/tests/QtScriptTools/debugger_test.py b/tests/QtScriptTools/debugger_test.py new file mode 100644 index 000000000..e5253610a --- /dev/null +++ b/tests/QtScriptTools/debugger_test.py @@ -0,0 +1,41 @@ + +import unittest + +from PySide.QtCore import SIGNAL +from PySide.QtScript import QScriptEngine +from PySide.QtScriptTools import QScriptEngineDebugger + +from helper import UsesQApplication + +class DebuggerTest(UsesQApplication): + + def setUp(self): + UsesQApplication.setUp(self) + self.engine = QScriptEngine() + self.debugger = QScriptEngineDebugger() + self.has_suspended = False + self.has_resumed = False + + def suspended(self): + self.has_suspended = True + self.debugger.action(QScriptEngineDebugger.ContinueAction).trigger() + + def resumed(self): + self.has_resumed = True + + def testBasic(self): + '''Interrupt and resume evaluation with QScriptEngineDebugger''' + self.debugger.attachTo(self.engine) + self.debugger.setAutoShowStandardWindow(False) + self.debugger.connect(SIGNAL('evaluationSuspended()'), self.suspended) + self.debugger.connect(SIGNAL('evaluationResumed()'), self.resumed) + + self.debugger.action(QScriptEngineDebugger.InterruptAction).trigger() + self.engine.evaluate("3+4") + self.debugger.action(QScriptEngineDebugger.ContinueAction).trigger() + self.assert_(self.has_resumed) + self.assert_(self.has_suspended) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtSql/CMakeLists.txt b/tests/QtSql/CMakeLists.txt new file mode 100644 index 000000000..a94469109 --- /dev/null +++ b/tests/QtSql/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(qsqldatabaseandqueries_test.py) diff --git a/tests/QtSql/qsqldatabaseandqueries_test.py b/tests/QtSql/qsqldatabaseandqueries_test.py new file mode 100755 index 000000000..49f220937 --- /dev/null +++ b/tests/QtSql/qsqldatabaseandqueries_test.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +'''Test cases for QtSql database creation, destruction and queries''' + +import sys +import unittest + +from PySide import QtSql +from PySide.QtCore import QVariant, QString + +class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase): + '''Test cases for QtSql database creation, destruction and queries''' + + def setUp(self): + #Acquire resources + self.assertFalse(QtSql.QSqlDatabase.drivers().isEmpty(), "installed Qt has no DB drivers") + self.assertTrue("QSQLITE" in QtSql.QSqlDatabase.drivers(), "\"QSQLITE\" driver not available in this Qt version") + self.db = QtSql.QSqlDatabase.addDatabase("QSQLITE") + self.db.setDatabaseName(":memory:") + self.assertTrue(self.db.open()) + + def tearDown(self): + #Release resources + self.db.close() + QtSql.QSqlDatabase.removeDatabase(":memory:") + del self.db + + def testTableCreationAndDestruction(self): + #Test table creation and destruction + query = QtSql.QSqlQuery() + query.exec_("CREATE TABLE dummy(id int primary key, dummyfield varchar(20))") + query.exec_("DROP TABLE dummy") + query.clear() + + def testTableInsertionAndRetrieval(self): + #Test table creation, insertion and retrieval + query = QtSql.QSqlQuery() + query.exec_("CREATE TABLE person(id int primary key, " + "firstname varchar(20), lastname varchar(20))") + query.exec_("INSERT INTO person VALUES(101, 'George', 'Harrison')") + query.prepare("INSERT INTO person (id, firstname, lastname) " + "VALUES (:id, :firstname, :lastname)") + query.bindValue(":id", QVariant(102)) + query.bindValue(":firstname", QVariant("John")) + query.bindValue(":lastname", QVariant("Lennon")) + query.exec_() + + lastname = '' + query.exec_("SELECT lastname FROM person where id=101") + self.assertTrue(query.isActive()) + query.next() + lastname = query.value(0).toString() + self.assertEqual(lastname, 'Harrison') + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtSvg/CMakeLists.txt b/tests/QtSvg/CMakeLists.txt new file mode 100644 index 000000000..6a9c9d562 --- /dev/null +++ b/tests/QtSvg/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(qsvggenerator_test.py) diff --git a/tests/QtSvg/qsvggenerator_test.py b/tests/QtSvg/qsvggenerator_test.py new file mode 100644 index 000000000..cec7fdaff --- /dev/null +++ b/tests/QtSvg/qsvggenerator_test.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +import unittest +from sys import getrefcount +from PySide.QtCore import QBuffer +from PySide.QtSvg import QSvgGenerator + +class QSvgGeneratorTest(unittest.TestCase): + + def testRefCountOfTOutputDevice(self): + generator = QSvgGenerator() + iodevice1 = QBuffer() + refcount1 = getrefcount(iodevice1) + + generator.setOutputDevice(iodevice1) + + self.assertEqual(generator.outputDevice(), iodevice1) + self.assertEqual(getrefcount(generator.outputDevice()), refcount1 + 1) + + iodevice2 = QBuffer() + refcount2 = getrefcount(iodevice2) + + generator.setOutputDevice(iodevice2) + + self.assertEqual(generator.outputDevice(), iodevice2) + self.assertEqual(getrefcount(generator.outputDevice()), refcount2 + 1) + self.assertEqual(getrefcount(iodevice1), refcount1) + + del generator + + self.assertEqual(getrefcount(iodevice2), refcount2) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtTest/CMakeLists.txt b/tests/QtTest/CMakeLists.txt new file mode 100644 index 000000000..b1bdac0a6 --- /dev/null +++ b/tests/QtTest/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(click_test.py) +PYSIDE_TEST(eventfilter_test.py) diff --git a/tests/QtTest/click_test.py b/tests/QtTest/click_test.py new file mode 100644 index 000000000..e295cee68 --- /dev/null +++ b/tests/QtTest/click_test.py @@ -0,0 +1,28 @@ + +'''QtTest mouse click functionalities''' + +import unittest + +from PySide.QtCore import Qt, QObject +from PySide.QtGui import QPushButton, QLineEdit +from PySide.QtTest import QTest + +from helper import UsesQApplication + +class MouseClickTest(UsesQApplication): + + def testBasic(self): + '''QTest.mouseClick with QCheckBox''' + button = QPushButton() + button.setCheckable(True) + button.setChecked(False) + + QTest.mouseClick(button, Qt.LeftButton) + self.assert_(button.isChecked()) + + QTest.mouseClick(button, Qt.LeftButton) + self.assertFalse(button.isChecked()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtTest/eventfilter_test.py b/tests/QtTest/eventfilter_test.py new file mode 100644 index 000000000..382460ee7 --- /dev/null +++ b/tests/QtTest/eventfilter_test.py @@ -0,0 +1,47 @@ + +'''Tests for QKeyEvent''' + +import unittest + +from PySide.QtCore import * +from PySide.QtGui import * +from PySide.QtTest import QTest + +from helper import UsesQApplication + + +class KeyEventFilter(QObject): + + def __init__(self, widget, eventType, key): + QObject.__init__(self) + + self.widget = widget + self.eventType = eventType + self.key = key + + self.processed = False + + def eventFilter(self, obj, event): + if self.widget == obj and event.type() == self.eventType and \ + isinstance(event, QKeyEvent) and event.key() == self.key: + self.processed = True + return True + + return False + +class EventFilterTest(UsesQApplication): + + def testKeyEvent(self): + widget = QLineEdit() + key = Qt.Key_A + eventFilter = KeyEventFilter(widget, QEvent.KeyPress, key) + widget.installEventFilter(eventFilter) + + QTest.keyClick(widget, key) + + self.assert_(eventFilter.processed) + + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtUiTools/CMakeLists.txt b/tests/QtUiTools/CMakeLists.txt new file mode 100644 index 000000000..9118b5b6c --- /dev/null +++ b/tests/QtUiTools/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(uiloader_test.py) +PYSIDE_TEST(ui_test.py) diff --git a/tests/QtUiTools/test.ui b/tests/QtUiTools/test.ui new file mode 100644 index 000000000..60afe22b3 --- /dev/null +++ b/tests/QtUiTools/test.ui @@ -0,0 +1,48 @@ + + + Form + + + + 0 + 0 + 185 + 133 + + + + Form + + + + + 0 + 0 + 181 + 131 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 50 + 60 + 80 + 25 + + + + PushButton + + + + + + + diff --git a/tests/QtUiTools/ui_test.py b/tests/QtUiTools/ui_test.py new file mode 100644 index 000000000..6f599cefb --- /dev/null +++ b/tests/QtUiTools/ui_test.py @@ -0,0 +1,14 @@ + +import unittest + +from PySide.QtUiTools import QUiLoader + +from helper import UsesQApplication + +class QUiLoaderCreation(UsesQApplication): + + def testConstructor(self): + loader = QUiLoader() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtUiTools/uiloader_test.py b/tests/QtUiTools/uiloader_test.py new file mode 100644 index 000000000..fe3725ba1 --- /dev/null +++ b/tests/QtUiTools/uiloader_test.py @@ -0,0 +1,30 @@ +import unittest +import os +from helper import UsesQApplication + +from PySide.QtGui import * +from PySide.QtUiTools import * + +def get_file_path(): + for path in file_path: + if os.path.exists(path): + return path + return "" + +class QUioaderTeste(UsesQApplication): + def testLoadFile(self): + filePath = os.path.join(os.path.dirname(__file__), 'test.ui') + loader = QUiLoader() + parent = QWidget() + w = loader.load(filePath, parent) + self.assertNotEqual(w, None) + + self.assertEqual(len(parent.children()), 1) + + child = w.findChild(QWidget, "child_object") + self.assertNotEqual(child, None) + self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object")) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtWebKit/CMakeLists.txt b/tests/QtWebKit/CMakeLists.txt new file mode 100644 index 000000000..54728656f --- /dev/null +++ b/tests/QtWebKit/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(webpage_test.py) +PYSIDE_TEST(webview_test.py) diff --git a/tests/QtWebKit/fox.html b/tests/QtWebKit/fox.html new file mode 100644 index 000000000..e7691eb66 --- /dev/null +++ b/tests/QtWebKit/fox.html @@ -0,0 +1,6 @@ + +Title + +

The quick brown fox jumps over the lazy dog.

+ + diff --git a/tests/QtWebKit/webpage_test.py b/tests/QtWebKit/webpage_test.py new file mode 100644 index 000000000..20796971f --- /dev/null +++ b/tests/QtWebKit/webpage_test.py @@ -0,0 +1,61 @@ + +'''Test cases for QWebPage''' + +import unittest + +from PySide.QtCore import QObject, SIGNAL, QUrl +from PySide.QtWebKit import QWebPage +from PySide.QtNetwork import QNetworkAccessManager + +from helper import adjust_filename, TimedQApplication + +#Define a global timeout because TimedQApplication uses a singleton! +#Use a value big enough to run all the tests. +TIMEOUT = 1000 + +class TestFindText(TimedQApplication): + '''Test cases for finding text''' + + def setUp(self): + TimedQApplication.setUp(self, timeout=TIMEOUT) + self.page = QWebPage() + QObject.connect(self.page, SIGNAL('loadFinished(bool)'), + self.load_finished) + self.called = False + + def tearDown(self): + #Release resources + del self.page + self.called = False + TimedQApplication.tearDown(self) + + def testFindSelectText(self): + url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) + self.page.mainFrame().load(url) + self.app.exec_() + self.assert_(self.called) + + def load_finished(self, ok): + #Callback to check if load was successful + if ok: + self.called = True + self.assert_(self.page.findText('fox')) + self.assertEqual(self.page.selectedText(), 'fox') + self.app.quit() + +class SetNetworkAccessManagerCase(TimedQApplication): + + def setUp(self): + TimedQApplication.setUp(self, timeout=TIMEOUT) + + def testSetNetworkAccessManager(self): + page = QWebPage() + manager = QNetworkAccessManager() + page.setNetworkAccessManager(manager) + + def testNetWorkAccessManager(self): + page = QWebPage() + a = page.networkAccessManager() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtWebKit/webview_test.py b/tests/QtWebKit/webview_test.py new file mode 100644 index 000000000..c06e437c3 --- /dev/null +++ b/tests/QtWebKit/webview_test.py @@ -0,0 +1,43 @@ + +'''Test cases for QWebView''' + +import unittest + +from PySide.QtCore import QObject, SIGNAL, QUrl +from PySide.QtWebKit import QWebView + +from helper import adjust_filename, TimedQApplication + + +class TestLoadFinished(TimedQApplication): + '''Test case for signal QWebView.loadFinished(bool)''' + + def setUp(self): + #Acquire resources + TimedQApplication.setUp(self, timeout=1000) + self.view = QWebView() + QObject.connect(self.view, SIGNAL('loadFinished(bool)'), + self.load_finished) + self.called = False + + def tearDown(self): + #Release resources + del self.view + self.called = False + TimedQApplication.tearDown(self) + + def testLoadFinishedFromFile(self): + url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) + self.view.setUrl(url) + self.app.exec_() + + self.assert_(self.called) + + def load_finished(self, ok): + #Callback to check if load was successful + self.app.quit() + if ok: + self.called = True + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtXml/CMakeLists.txt b/tests/QtXml/CMakeLists.txt new file mode 100644 index 000000000..2c21bf87d --- /dev/null +++ b/tests/QtXml/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(qdomdocument_test.py) +PYSIDE_TEST(qxmlsimplereader_test.py) diff --git a/tests/QtXml/qdomdocument_test.py b/tests/QtXml/qdomdocument_test.py new file mode 100644 index 000000000..86aece7ba --- /dev/null +++ b/tests/QtXml/qdomdocument_test.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +import unittest +from PySide.QtCore import QByteArray +from PySide.QtXml import QDomDocument, QDomElement + +class QDomDocumentTest(unittest.TestCase): + + def setUp(self): + self.dom = QDomDocument() + + self.goodXmlData = QByteArray(''' + + + + + ''') + + self.badXmlData = QByteArray(''' + + + + ''') + + def tearDown(self): + del self.dom + del self.goodXmlData + del self.badXmlData + + def testQDomDocumentSetContentWithBadXmlData(self): + '''Sets invalid xml as the QDomDocument contents.''' + ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.badXmlData, True) + self.assertFalse(ok) + self.assertEqual(errorStr, 'tag mismatch') + self.assertEqual(errorLine, 4) + self.assertEqual(errorColumn, 21) + + def testQDomDocumentSetContentWithGoodXmlData(self): + '''Sets valid xml as the QDomDocument contents.''' + ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.goodXmlData, True) + self.assert_(ok) + self.assertEqual(errorStr, '') + self.assertEqual(errorLine, 0) + self.assertEqual(errorColumn, 0) + + def testQDomDocumentData(self): + '''Checks the QDomDocument elements for the valid xml contents.''' + + def checkAttribute(element, attribute, value): + self.assert_(isinstance(root, QDomElement)) + self.assertFalse(element.isNull()) + self.assert_(element.hasAttribute(attribute)) + self.assertEqual(element.attribute(attribute), value) + + ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.goodXmlData, True) + root = self.dom.documentElement() + self.assertEqual(root.tagName(), 'typesystem') + checkAttribute(root, 'package', 'PySide.QtXml') + + child = root.firstChildElement('value-type') + checkAttribute(child, 'name', 'QDomDocument') + + child = child.nextSiblingElement('value-type') + checkAttribute(child, 'name', 'QDomElement') + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtXml/qxmlsimplereader_test.py b/tests/QtXml/qxmlsimplereader_test.py new file mode 100644 index 000000000..6c4d3f4ea --- /dev/null +++ b/tests/QtXml/qxmlsimplereader_test.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +import unittest +from PySide.QtXml import QXmlSimpleReader + +class QXmlSimpleReaderTest(unittest.TestCase): + + def testQXmlSimpleReaderInstatiation(self): + '''QXmlSimpleReader must be a concrete class not an abstract one.''' + reader = QXmlSimpleReader() + + def testQXmlSimpleReaderFeatures(self): + '''Calls the QXmlSimpleReader.features method. The features checked + (at least the first two) can be found in the QXmlSimpleReader documentation: + http://qt.nokia.com/doc/4.6/qxmlsimplereader.html#setFeature + ''' + reader = QXmlSimpleReader() + hasFeature, ok = reader.feature('http://xml.org/sax/features/namespaces') + self.assertEqual((hasFeature, ok), (True, True)) + + hasFeature, ok = reader.feature('http://xml.org/sax/features/namespace-prefixes') + self.assertEqual((hasFeature, ok), (False, True)) + + hasFeature, ok = reader.feature('foobar') + self.assertEqual((hasFeature, ok), (False, False)) + + def testQXmlSimpleReaderProperty(self): + '''Tries to get a non existent property.''' + reader = QXmlSimpleReader() + prop, ok = reader.property('foo') + self.assertEqual((prop, ok), (None, False)) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtXmlPatterns/CMakeLists.txt b/tests/QtXmlPatterns/CMakeLists.txt new file mode 100644 index 000000000..7f570f156 --- /dev/null +++ b/tests/QtXmlPatterns/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(import_test.py) diff --git a/tests/QtXmlPatterns/import_test.py b/tests/QtXmlPatterns/import_test.py new file mode 100644 index 000000000..5bab9755c --- /dev/null +++ b/tests/QtXmlPatterns/import_test.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import unittest +from PySide.QtCore import * +from PySide.QtXmlPatterns import QXmlSchema +from helper import UsesQCoreApplication + +class QXmlPatternsTest(UsesQCoreApplication): + + def testSchema(self): + data = QByteArray(''' + + ''') + + buf = QBuffer(data) + buf.open(QIODevice.ReadOnly) + + schema = QXmlSchema() + schema.load(buf) + self.assert_(schema.isValid()) + + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/phonon/CMakeLists.txt b/tests/phonon/CMakeLists.txt new file mode 100644 index 000000000..1174709a2 --- /dev/null +++ b/tests/phonon/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(basic_playing_test.py) +PYSIDE_TEST(capabilities_test.py) diff --git a/tests/qtcore/blocking_signals_test.py b/tests/qtcore/blocking_signals_test.py deleted file mode 100644 index 96582f6cc..000000000 --- a/tests/qtcore/blocking_signals_test.py +++ /dev/null @@ -1,107 +0,0 @@ - -''' Test case for QObject.signalsBlocked() and blockSignal()''' - -import unittest -import os -from tempfile import mkstemp - -from PySide.QtCore import QObject, SIGNAL, QFile - -class TestSignalsBlockedBasic(unittest.TestCase): - '''Basic test case for signalsBlocked''' - - def testBasic(self): - '''QObject.signalsBlocked() and blockSignals() - The signals aren't blocked by default. - blockSignals returns the previous value''' - obj = QObject() - self.assert_(not obj.signalsBlocked()) - self.assert_(not obj.blockSignals(True)) - self.assert_(obj.signalsBlocked()) - self.assert_(obj.blockSignals(False)) - -class TestSignalsBlocked(unittest.TestCase): - '''Test case to check if the signals are really blocked''' - - def setUp(self): - #Set up the basic resources needed - self.obj = QObject() - self.args = tuple() - self.called = False - - def tearDown(self): - #Delete used resources - del self.obj - del self.args - - def callback(self, *args): - #Default callback - if args == self.args: - self.called = True - else: - raise TypeError("Invalid arguments") - - def testShortCircuitSignals(self): - #Blocking of Python short-circuit signals - QObject.connect(self.obj, SIGNAL('mysignal'), self.callback) - - self.obj.emit(SIGNAL('mysignal')) - self.assert_(self.called) - - self.called = False - self.obj.blockSignals(True) - self.obj.emit(SIGNAL('mysignal')) - self.assert_(not self.called) - - def testPythonSignals(self): - #Blocking of Python typed signals - QObject.connect(self.obj, SIGNAL('mysignal(int,int)'), self.callback) - self.args = (1, 3) - - self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) - self.assert_(self.called) - - self.called = False - self.obj.blockSignals(True) - self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) - self.assert_(not self.called) - -class TestQFileSignalBlocking(unittest.TestCase): - '''Test case for blocking the signal QIODevice.aboutToClose()''' - - def setUp(self): - #Set up the needed resources - A temp file and a QFile - self.called = False - handle, self.filename = mkstemp() - os.close(handle) - - self.qfile = QFile(self.filename) - - def tearDown(self): - #Release acquired resources - os.remove(self.filename) - del self.qfile - - def callback(self): - #Default callback - self.called = True - - def testAboutToCloseBlocking(self): - #QIODevice.aboutToClose() blocking - - QObject.connect(self.qfile, SIGNAL('aboutToClose()'), self.callback) - - self.assert_(self.qfile.open(QFile.ReadOnly)) - self.qfile.close() - self.assert_(self.called) - - self.called = False - self.qfile.blockSignals(True) - - self.assert_(self.qfile.open(QFile.ReadOnly)) - self.qfile.close() - self.assert_(not self.called) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/buffer_test.py b/tests/qtcore/buffer_test.py deleted file mode 100644 index 2917232a1..000000000 --- a/tests/qtcore/buffer_test.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/python - -import unittest -from PySide.QtCore import QString - -class BufferTest(unittest.TestCase): - def testQByteArray(self): - data = buffer("PySide") - str = QString(data) - self.assertEqual(data, str) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/child_event_test.py b/tests/qtcore/child_event_test.py deleted file mode 100644 index ccc27c848..000000000 --- a/tests/qtcore/child_event_test.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -'''Test case for QObject.childEvent and QTimer.childEvent overloading''' - -import unittest -from time import sleep -from PySide.QtCore import QObject, QTimer, QCoreApplication - -from helper import UsesQCoreApplication - -class ExtQObject(QObject): - def __init__(self): - QObject.__init__(self) - self.child_event_received = False - - def childEvent(self, event): - QObject.childEvent(self, event) - self.child_event_received = True - -class ExtQTimer(QTimer): - def __init__(self): - QTimer.__init__(self) - self.child_event_received = False - - def childEvent(self, event): - QTimer.childEvent(self, event) - self.child_event_received = True - - -class TestChildEvent(UsesQCoreApplication): - '''Test case for QObject::childEvent and QTimer::childEvent''' - - def setUp(self): - UsesQCoreApplication.setUp(self) - - def tearDown(self): - UsesQCoreApplication.tearDown(self) - - def testQObject(self): - parent = ExtQObject() - child = QObject() - child.setParent(parent) - print "parent seted" - #self.assert_(parent.child_event_received) - - """ - def testQTimer(self): - parent = ExtQTimer() - child = QObject() - child.setParent(parent) - self.assert_(parent.child_event_received) - """ - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/deletelater_test.py b/tests/qtcore/deletelater_test.py deleted file mode 100644 index 3b2f7d9e3..000000000 --- a/tests/qtcore/deletelater_test.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python - -'''Test cases for QTimer.singleShot''' - -import unittest - -from PySide.QtCore import QObject, QTimer, QCoreApplication, SIGNAL -from helper import UsesQCoreApplication - -class TestDeleteLater(UsesQCoreApplication): - '''Test case for function DeleteLater''' - - def testCase(self): - o = QObject() - o.deleteLater() - del o - QTimer.singleShot(100, self.app.quit) - self.app.exec_() - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/duck_punching_test.py b/tests/qtcore/duck_punching_test.py deleted file mode 100644 index e20c0c1b1..000000000 --- a/tests/qtcore/duck_punching_test.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python - -'''Test case for duck punching new implementations of C++ virtual methods into object instances.''' - -import unittest -import types -from PySide.QtCore import QObject, QEvent -from helper import UsesQCoreApplication - -class Duck(QObject): - def __init__(self): - QObject.__init__(self) - def childEvent(self, event): - QObject.childEvent(self, event) - -class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication): - '''Test case for duck punching new implementations of C++ virtual methods into object instances.''' - - def setUp(self): - #Acquire resources - self.duck_childEvent_called = False - UsesQCoreApplication.setUp(self) - - def tearDown(self): - #Release resources - del self.duck_childEvent_called - UsesQCoreApplication.tearDown(self) - - - def testChildEventMonkeyPatch(self): - #Test if the new childEvent injected on QObject instance is called from C++ - parent = QObject() - def childEvent(obj, event): - self.duck_childEvent_called = True - QObject.childEvent(obj, event) - parent.childEvent = types.MethodType(childEvent, parent, QObject) - child = QObject() - child.setParent(parent) - self.assert_(self.duck_childEvent_called) - - def testChildEventMonkeyPatchWithInheritance(self): - #Test if the new childEvent injected on a QObject's extension class instance is called from C++ - parent = Duck() - def childEvent(obj, event): - QObject.childEvent(obj, event) - self.duck_childEvent_called = True - child = QObject() - child.setParent(parent) - parent.childEvent = types.MethodType(childEvent, parent, QObject) - child = QObject() - child.setParent(parent) - self.assert_(self.duck_childEvent_called) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/missing_symbols_test.py b/tests/qtcore/missing_symbols_test.py deleted file mode 100644 index f535c53d3..000000000 --- a/tests/qtcore/missing_symbols_test.py +++ /dev/null @@ -1,16 +0,0 @@ - -'''(Very) Simple test case for missing names from QtCore''' - -import unittest -from PySide import QtCore - -class MissingClasses(unittest.TestCase): - - def testQSettings(self): # Bug 232 - getattr(QtCore, 'QSettings') - - def testQtTrNoop(self): # Bug 220 - getattr(QtCore, 'QT_TR_NOOP') - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qabs_test.py b/tests/qtcore/qabs_test.py deleted file mode 100644 index 1727ae6d5..000000000 --- a/tests/qtcore/qabs_test.py +++ /dev/null @@ -1,20 +0,0 @@ - -import unittest - -from PySide import QtCore - - -class QAbsTest(unittest.TestCase): - '''Tests for QtCore.qAbs''' - - def testBasic(self): - def check(x): - self.assertEqual(QtCore.qAbs(x), abs(x)) - - check(0) - check(-10) - check(10) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qabstracttransition_test.py b/tests/qtcore/qabstracttransition_test.py deleted file mode 100644 index 510b8ef64..000000000 --- a/tests/qtcore/qabstracttransition_test.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/python -import unittest -from sys import getrefcount -from PySide.QtCore import QObject, SIGNAL, QCoreApplication, QTimer, QVariant -from PySide.QtCore import QState, QFinalState, QStateMachine, QParallelAnimationGroup, QEventTransition - -def addStates(transition): - sx = QState() - sy = QState() - transition.setTargetStates([sx, sy]) - -def addAnimation(transition): - animation = QParallelAnimationGroup() - transition.addAnimation(animation) - -class QAbstractTransitionTest(unittest.TestCase): - - def testBasic(self): - app = QCoreApplication([]) - - o = QObject() - o.setProperty("text", QVariant("INdT")) - - machine = QStateMachine() - s1 = QState() - s1.assignProperty(o, "text", QVariant("Rocks")) - - s2 = QFinalState() - t = s1.addTransition(o, SIGNAL("change()"), s2) - - self.assertEqual(t.targetStates(), [s2]) - - addStates(t) - self.assertEqual(len(t.targetStates()), 2) - - animation = QParallelAnimationGroup() - t.addAnimation(animation) - - self.assertEqual(t.animations(), [animation]) - - addAnimation(t) - self.assertEqual(t.animations()[0].parent(), None) - - machine.addState(s1) - machine.addState(s2) - machine.setInitialState(s1) - machine.start() - - QTimer.singleShot(100, app.quit) - app.exec_() - - def testRefCountOfTargetState(self): - transition = QEventTransition() - state1 = QState() - refcount1 = getrefcount(state1) - - transition.setTargetState(state1) - - self.assertEqual(transition.targetState(), state1) - self.assertEqual(getrefcount(transition.targetState()), refcount1 + 1) - - state2 = QState() - refcount2 = getrefcount(state2) - - transition.setTargetState(state2) - - self.assertEqual(transition.targetState(), state2) - self.assertEqual(getrefcount(transition.targetState()), refcount2 + 1) - self.assertEqual(getrefcount(state1), refcount1) - - del transition - - self.assertEqual(getrefcount(state2), refcount2) - - def testRefCountOfTargetStates(self): - transition = QEventTransition() - state1 = QState() - state2 = QState() - states = [state1, state2] - refcount1 = getrefcount(state1) - refcount2 = getrefcount(state2) - - transition.setTargetStates(states) - - self.assertEqual(transition.targetStates(), states) - self.assertEqual(transition.targetState(), state1) - self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1) - self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1) - - del states - del transition - - self.assertEqual(getrefcount(state1), refcount1) - self.assertEqual(getrefcount(state2), refcount2) - - def testRefCountOfTargetStatesAfterSingleTargetState(self): - transition = QEventTransition() - state0 = QState() - refcount0 = getrefcount(state0) - - transition.setTargetState(state0) - - self.assertEqual(transition.targetState(), state0) - self.assertEqual(getrefcount(transition.targetState()), refcount0 + 1) - - state1 = QState() - state2 = QState() - states = [state1, state2] - refcount1 = getrefcount(state1) - refcount2 = getrefcount(state2) - - transition.setTargetStates(states) - - self.assertEqual(getrefcount(state0), refcount0) - self.assertEqual(transition.targetStates(), states) - self.assertEqual(transition.targetState(), state1) - self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1) - self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1) - - del states - del transition - - self.assertEqual(getrefcount(state1), refcount1) - self.assertEqual(getrefcount(state2), refcount2) - - def testRefCountOfTargetStatesBeforeSingleTargetState(self): - transition = QEventTransition() - state1 = QState() - state2 = QState() - states = [state1, state2] - refcount1 = getrefcount(state1) - refcount2 = getrefcount(state2) - - transition.setTargetStates(states) - - self.assertEqual(transition.targetStates(), states) - self.assertEqual(transition.targetState(), state1) - self.assertEqual(getrefcount(transition.targetStates()[0]), refcount1 + 1) - self.assertEqual(getrefcount(transition.targetStates()[1]), refcount2 + 1) - - state3 = QState() - refcount3 = getrefcount(state3) - - transition.setTargetState(state3) - - self.assertEqual(transition.targetState(), state3) - self.assertEqual(getrefcount(transition.targetState()), refcount3 + 1) - - del states - - self.assertEqual(getrefcount(state1), refcount1) - self.assertEqual(getrefcount(state2), refcount2) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qanimationgroup_test.py b/tests/qtcore/qanimationgroup_test.py deleted file mode 100644 index 05bd81e10..000000000 --- a/tests/qtcore/qanimationgroup_test.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide.QtCore import QObject, QState, QFinalState, SIGNAL, QCoreApplication, QTimer, QStateMachine, QSignalTransition, QVariant, QParallelAnimationGroup, QSequentialAnimationGroup, QAnimationGroup - -class QAnimationGroupTest(unittest.TestCase): - - def testBasic(self): - app = QCoreApplication([]) - - panim = QParallelAnimationGroup() - sanim = QSequentialAnimationGroup() - panim.addAnimation(sanim) - - self.assertEqual(sanim.parent(), panim) - - panim.clear() - - self.assertRaises(RuntimeError, lambda :sanim.parent()) - - QTimer.singleShot(100, app.quit) - app.exec_() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qbitarray_test.py b/tests/qtcore/qbitarray_test.py deleted file mode 100755 index 0ae6e1d2f..000000000 --- a/tests/qtcore/qbitarray_test.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/python -'''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators''' - -import unittest - -from PySide.QtCore import QBitArray - -def bool_list_from_qbitarray(qbitarray): - '''This function is used instead of a list comprehension because - the QBitArray is being tested also to check if it is providing - the iterable protocol. - ''' - qbitarray_values = [] - for i in range(qbitarray.size()): - qbitarray_values.append(qbitarray.at(i)) - return qbitarray_values - -class QBitArrayIsIterableTest(unittest.TestCase): - '''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators''' - - def setUp(self): - #Acquire resources - self.qbitarray = QBitArray(3) - self.qbitarray_values = [True, False, False] - # WARNING: do not pythonify the following loop - for i in range(len(self.qbitarray_values)): - self.qbitarray.setBit(i, self.qbitarray_values[i]) - - self.inverted_qbitarray_values = [not bit for bit in self.qbitarray_values] - - self.other_qbitarray = QBitArray(3) - self.other_qbitarray_values = [True, True, False] - # WARNING: do not pythonify the following loop - for i in range(len(self.other_qbitarray_values)): - self.other_qbitarray.setBit(i, self.other_qbitarray_values[i]) - - def tearDown(self): - #Release resources - del self.qbitarray - del self.other_qbitarray - del self.qbitarray_values - del self.other_qbitarray_values - del self.inverted_qbitarray_values - - def testQBitArrayIsIterable(self): - #Tests if QBitArray class is iterable - qbitarray_is_iterable = True - try: - bitarray = [bit for bit in self.qbitarray] - except: - qbitarray_is_iterable = False - self.assertTrue(qbitarray_is_iterable) - - def testQBitArrayInvertOperator(self): - #Tests QBitArray '~' (__invert__) operator - inverted_qbitarray = ~self.qbitarray - # WARNING: do not pythonify the following loop, the - # iterability of QBitArray class is tested in another place - inverted_qbitarray_values = bool_list_from_qbitarray(inverted_qbitarray) - self.assertEqual(self.inverted_qbitarray_values, inverted_qbitarray_values) - - def testQBitArrayOrBitwiseOperator(self): - #Tests QBitArray '|' (or) operator - has_or_bitwise_operator = True - ored_qbitarray, ored_bool_list = None, None - try: - ored_qbitarray = self.qbitarray | self.other_qbitarray - ored_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)] - except: - has_or_bitwise_operator = False - self.assertTrue(has_or_bitwise_operator) - self.assertEqual(bool_list_from_qbitarray(ored_qbitarray), ored_bool_list) - - def testQBitArrayAndBitwiseOperator(self): - #Tests QBitArray '&' (and) operator - has_and_bitwise_operator = True - anded_qbitarray, anded_bool_list = None, None - try: - anded_qbitarray = self.qbitarray | self.other_qbitarray - anded_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)] - except: - has_and_bitwise_operator = False - self.assertTrue(has_and_bitwise_operator) - self.assertEqual(bool_list_from_qbitarray(anded_qbitarray), anded_bool_list) - - def testQBitArrayXorBitwiseOperator(self): - #Tests QBitArray '^' (xor) operator - has_xor_bitwise_operator = True - xored_qbitarray, xored_bool_list = None, None - try: - xored_qbitarray = self.qbitarray | self.other_qbitarray - xored_bool_list = [b1 | b2 for b1, b2 in zip(self.qbitarray_values, self.other_qbitarray_values)] - except: - has_xor_bitwise_operator = False - self.assertTrue(has_xor_bitwise_operator) - self.assertEqual(bool_list_from_qbitarray(xored_qbitarray), xored_bool_list) - - -class QBitArrayGetItemTest(unittest.TestCase): - '''Test case for []/__getitem__ operator''' - - def create_bitarray(self, values): - '''helper function to create a bit array''' - obj = QBitArray(len(values)) - for i, value in enumerate(values): - obj.setBit(i, value) - return obj - - def testSequenceProtocol(self): - '''QBitArray sequence protocol''' - data = [True, False, True] - obj = self.create_bitarray(data) - for reference, value in zip(data, obj): - self.assertEqual(reference, value) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qbytearray_buffer_protocol_test.py b/tests/qtcore/qbytearray_buffer_protocol_test.py deleted file mode 100755 index 117e50b93..000000000 --- a/tests/qtcore/qbytearray_buffer_protocol_test.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Tests QByteArray implementation of Python buffer protocol''' - -import unittest - -from os.path import isdir -from PySide.QtCore import QByteArray - -class QByteArrayBufferProtocolTest(unittest.TestCase): - '''Tests QByteArray implementation of Python buffer protocol''' - - def testQByteArrayBufferProtocol(self): - #Tests QByteArray implementation of Python buffer protocol using the os.path.isdir - #function which an unicode object or other object implementing the Python buffer protocol - isdir(QByteArray('/tmp')) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qbytearray_concatenation_operator_test.py b/tests/qtcore/qbytearray_concatenation_operator_test.py deleted file mode 100755 index b9a01ff63..000000000 --- a/tests/qtcore/qbytearray_concatenation_operator_test.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QByteArray concatenation with '+' operator''' - -import unittest - -from PySide.QtCore import QByteArray - -class QByteArrayConcatenationOperatorTest(unittest.TestCase): - '''Test cases for QByteArray concatenation with '+' operator''' - - def testConcatQByteArrayAndPythonString(self): - #Test concatenation of a QByteArray with a Python string, in this order - qba = QByteArray('foo') - result = qba + 'bar' - self.assert_(isinstance(result, QByteArray)) - self.assertEqual(result, 'foobar') - # NOTICE: the standard behavior of PyQt is to return a QString object - # for this case. As this is a minor issue the assertion will be left commented. - #self.assertEqual(result.__class__.__name__, 'QString') - - def testConcatPythonStringAndQByteArray(self): - #Test concatenation of a Python string with a QByteArray, in this order - concat_python_string_add_qbytearray_worked = True - qba = QByteArray('foo') - result = 'bar' + qba - self.assert_(isinstance(result, QByteArray)) - self.assertEqual(result, 'barfoo') - - # NOTICE: Does not makes sense concat a unicode string with a QByteArray, because the - # user does not know nothing about the internal representation of the unicode string. - #def testConcatPythonUnicodeAndQByteArray(self): - ##Test concatenation of a Python unicode object with a QByteArray, in this order - #concat_python_unicode_add_qbytearray_worked = True - #qba = QByteArray('foo') - #result = None - #try: - #result = u'ümlaut' + qba - #except: - #concat_python_unicode_add_qbytearray_worked = False - #self.assertTrue(concat_python_unicode_add_qbytearray_worked) - #self.assertEqual(result.__class__.__name__, 'unicode') - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qbytearray_operator_iadd_test.py b/tests/qtcore/qbytearray_operator_iadd_test.py deleted file mode 100644 index 168f22de9..000000000 --- a/tests/qtcore/qbytearray_operator_iadd_test.py +++ /dev/null @@ -1,73 +0,0 @@ - -import unittest -import new - -from PySide.QtCore import QByteArray, QString -from helper.docmodifier import DocModifier - -class BaseQByteArrayOperatorIAdd(object): - '''Base class for QByteArray += operator tests. - - Implementing classes should inherit from unittest.TestCase and implement - setUp, setting self.obj and self.orig_obj to the target QByteArray and original - one, respectively''' - - __metaclass__ = DocModifier - - def testSingleString(self): - '''QByteArray += string of size 1''' - s = '0' - self.obj += s - self.assertEqual(self.obj, self.orig_obj + s) - self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s)) - - def testString(self): - '''QByteArray += string of size > 1''' - s = 'dummy' - self.obj += s - self.assertEqual(self.obj, self.orig_obj + s) - self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s)) - - def testQByteArray(self): - '''QByteArray += QByteArray''' - s = QByteArray('array') - self.obj += s - self.assertEqual(self.obj, self.orig_obj + s) - - def testChar(self): - '''QByteArray += char (number < 256)''' - s = ord('a') - self.obj += s - self.assertEqual(self.obj, self.orig_obj + s) - self.assertEqual(self.obj.size(), self.orig_obj.size() + 1) - - def testQString(self): - '''QByteArray += QString''' - s = QString('dummy') - self.obj += s - self.assertEqual(self.obj, self.orig_obj + s) - self.assertEqual(self.obj.size(), self.orig_obj.size() + s.size()) - -class NullQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd): - '''Test case for operator QByteArray += on null QByteArrays''' - - doc_prefix = 'Null object' - doc_filter = lambda x: x.startswith('test') - - def setUp(self): - self.obj = QByteArray() - self.orig_obj = QByteArray() - - -class ValidQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd): - '''Test case for operator QByteArray += on valid QByteArrays''' - - doc_prefix = 'Valid object' - doc_filter = lambda x: x.startswith('test') - - def setUp(self): - self.obj = QByteArray('some byte array') - self.orig_obj = QByteArray('some byte array') - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qbytearray_operator_test.py b/tests/qtcore/qbytearray_operator_test.py deleted file mode 100644 index 4a20c04c5..000000000 --- a/tests/qtcore/qbytearray_operator_test.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QByteArray operators''' - -import unittest - -from PySide.QtCore import QByteArray, QString - -class QByteArrayOperatorEqual(unittest.TestCase): - '''TestCase for operator QByteArray == QByteArray''' - - def testDefault(self): - #QByteArray() == QByteArray() - obj1 = QByteArray() - obj2 = QByteArray() - self.assertEqual(obj1, obj2) - - def testSimple(self): - #QByteArray(some_string) == QByteArray(some_string) - string = 'egg snakes' - self.assertEqual(QByteArray(string), QByteArray(string)) - - def testPyString(self): - #QByteArray(string) == string - string = 'my test string' - self.assertEqual(QByteArray(string), string) - - def testQString(self): - #QByteArray(string) == QString(string) - string = 'another test string' - self.assertEqual(QByteArray(string), QString(string)) - -class QByteArrayOperatorAt(unittest.TestCase): - '''TestCase for operator QByteArray[]''' - - def testInRange(self): - #QByteArray[x] where x is a valid index - string = 'abcdefgh' - obj = QByteArray(string) - - for i in range(len(string)): - self.assertEqual(obj[i], string[i]) - - def testInRangeReverse(self): - #QByteArray[x] where x is a valid index (reverse order) - string = 'abcdefgh' - obj = QByteArray(string) - - for i in range(len(string)-1, 0, -1): - self.assertEqual(obj[i], string[i]) - - - def testOutOfRange(self): - #QByteArray[x] where x is out of index - string = '1234567' - obj = QByteArray(string) - self.assertRaises(IndexError, lambda :obj[len(string)]) - - -class QByteArrayOperatorLen(unittest.TestCase): - '''Test case for __len__ operator of QByteArray''' - - def testBasic(self): - '''QByteArray __len__''' - self.assertEqual(len(QByteArray()), 0) - self.assertEqual(len(QByteArray('')), 0) - self.assertEqual(len(QByteArray(' ')), 1) - self.assertEqual(len(QByteArray('yabadaba')), 8) - - -class QByteArrayOperatorStr(unittest.TestCase): - '''Test case for __str__ operator of QByteArray''' - - def testBasic(self): - '''QByteArray __str__''' - self.assertEqual(QByteArray().__str__(), '') - self.assertEqual(QByteArray('').__str__(), '') - self.assertEqual(QByteArray('aaa').__str__(), 'aaa') - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qbytearray_test.py b/tests/qtcore/qbytearray_test.py deleted file mode 100644 index 20bba1400..000000000 --- a/tests/qtcore/qbytearray_test.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -'''Unit tests for QByteArray''' - -import unittest -import ctypes -import sys - -from PySide.QtCore import QByteArray - -class QByteArrayTestToNumber(unittest.TestCase): - def testToNumberInt(self): - obj = QByteArray('37') - self.assertEqual((37, True), obj.toInt()) - - def testToNumberUShort(self): - obj = QByteArray('37') - self.assertEqual((37, True), obj.toUShort()) - - def testToNumberFloat(self): - obj = QByteArray('37.109') - self.assertEqual((ctypes.c_float(37.109).value, True), - obj.toFloat()) - - def testToNumberDouble(self): - obj = QByteArray('37.109') - self.assertEqual((ctypes.c_double(37.109).value, True), - obj.toDouble()) - -class QByteArraySplit(unittest.TestCase): - '''Test case for QByteArray.split''' - - def testPathSeparator(self): - #QByteArray.split('/') - obj = QByteArray(unittest.__file__) - self.assertEqual(obj.split('/'), unittest.__file__.split('/')) - -class QByteArrayData(unittest.TestCase): - - '''Test case for QByteArray.data''' - - def testData(self): - url = QByteArray("http://web.openbossa.org/") - self.assertEqual(url.data(), "http://web.openbossa.org/") - -class QByteArrayOperatorAtSetter(unittest.TestCase): - '''Test case for operator QByteArray[] - __setitem__''' - - def testSetterString(self): - '''QByteArray[x] = pythonstring''' - obj = QByteArray('123456') - obj[1] = '0' - self.assertEqual(obj, QByteArray('103456')) - - def testSetterStringLarge(self): - '''QByteArray[x] = pythonstring (larget than 1 char)''' - obj = QByteArray('123456') - obj[3] = 'abba' - self.assertEqual(obj, QByteArray('123abba56')) - - def testSetterQByteArray(self): - '''QByteArray[x] = qbytearray''' - obj = QByteArray('123456') - obj[3] = QByteArray('array') - self.assertEqual(obj, QByteArray('123array56')) - - -class QByteArrayOperatorAtSetterNegativeIndex(unittest.TestCase): - '''Test case for QByteArray[] - __setitem__ - for negative index''' - - def testSetterNegativeIndex(self): - '''QByteArray[x] = string - negative index''' - obj = QByteArray('123456') - obj[-3] = 'array' - self.assertEqual(obj, QByteArray('123array56')) - - -class QByteArrayOperatorAtSetterLargeIndex(unittest.TestCase): - '''Test case for QByteArray[] - __setitem__ - for 'overflown' index''' - - def testSetterLargeIndexEmpty(self): - '''QByteArray[x] = somestring - Overflow index on empty string''' - # should pad with spaces if the index is larger - obj = QByteArray('') - obj[2] = 'a' - self.assertEqual(obj, QByteArray(' a')) - - def testSetterLargeIndexNormal(self): - '''QByteArray[x] = somestring - Overflow index on normal string''' - # should pad with spaces if the index is larger - obj = QByteArray('mystring') - obj[10] = 'normal' - self.assertEqual(obj, QByteArray('mystring normal')) - - - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qchar_test.py b/tests/qtcore/qchar_test.py deleted file mode 100644 index a40724b0e..000000000 --- a/tests/qtcore/qchar_test.py +++ /dev/null @@ -1,59 +0,0 @@ - -'''Test cases for QChar''' - -import unittest - -from PySide.QtCore import QString, QChar, QTextStream, QLatin1Char - - -class EqualTest(unittest.TestCase): - '''Tests for '__equal__''' - - def testEqualQChar(self): - '''QChar == QChar''' - self.assertEqual(QChar('a'), QChar('a')) - - def testEqualPyString(self): - '''QChar == Python string''' - self.assertEqual(QChar('a'), 'a') - - -class ImplicitConvQLatin1Char(unittest.TestCase): - '''Tests for implicit conversion from QLatin1Char to QChar''' - - def testQLatin1CharToChar(self): - '''QLatin1Char implicitly convertible to QChar''' - stream = QTextStream() - stream.setPadChar(QLatin1Char('-')) - self.assertEqual(QChar('-'), stream.padChar()) - - -class QCharCtorBigNumber(unittest.TestCase): - '''QChar constructors receiving ints''' - - def testInt(self): - '''QChar(int)''' - codepoint = 512 - qchar = QChar(codepoint) - reference = unichr(codepoint) - self.assertEqual(qchar.unicode(), codepoint) - - -class QCharCtorString(unittest.TestCase): - '''QChar constructor receiving strings''' - - def testBasic(self): - '''QChar(char)''' - reference = 'a' - qchar = QChar(reference) - self.assertEqual(ord(reference), ord(qchar.toAscii())) - - def testError(self): - '''QChar(char)''' - reference = 'aaaaaa' - self.assertRaises(TypeError, QChar, reference) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qcoreapplication_instance_test.py b/tests/qtcore/qcoreapplication_instance_test.py deleted file mode 100755 index 365148d34..000000000 --- a/tests/qtcore/qcoreapplication_instance_test.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QCoreApplication.instance static method''' - -import unittest - -from PySide.QtCore import QCoreApplication - -class QCoreApplicationInstanceTest(unittest.TestCase): - '''Test cases for QCoreApplication.instance static method''' - - def testQCoreApplicationInstance(self): - #Tests QCoreApplication.instance() - self.assertEqual(QCoreApplication.instance(), None) - app = QCoreApplication([]) - self.assertEqual(QCoreApplication.instance(), app) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qdatastream_test.py b/tests/qtcore/qdatastream_test.py deleted file mode 100644 index d71ed2f24..000000000 --- a/tests/qtcore/qdatastream_test.py +++ /dev/null @@ -1,330 +0,0 @@ -#!/usr/bin/python -'''Unit tests for QDataStream''' - -import unittest - -from PySide.QtCore import QDataStream, QString, QIODevice, QByteArray -from PySide.QtCore import QBitArray, QDate, QTime, QDateTime, QLine, QChar - -def create_bitarray(string): - array = QBitArray(len(string)) - for i, char in enumerate(string): - array.setBit(i, char != '0') - return array - -class QDataStreamWrite(unittest.TestCase): - '''Test case for QDatastream write* functions''' - - def setUp(self): - self.ba = QByteArray() - self.read = QDataStream(self.ba, QIODevice.ReadOnly) - self.write = QDataStream(self.ba, QIODevice.WriteOnly) - - def testWriteUInt8(self): - '''QDataStream.writeUInt8 (accepting str of size 1)''' - x = 0xFF - self.write.writeUInt8(chr(x)) - y = self.read.readUInt8() - self.assertEqual(x, y) - - self.assertRaises(TypeError, self.write.writeUInt8, 'aaaaa') - - def testWriteInt8(self): - '''QDataStream.writeInt8 (accepting str of size 1)''' - x = 65 - self.write.writeInt8(chr(x)) - y = self.read.readInt8() - self.assertEqual(x, y) - - self.assertRaises(TypeError, self.write.writeInt8, 'aaaaa') - - def testWriteUInt8Int(self): - '''QDataStream.writeUInt8 (accepting integer)''' - x = 0xFF - self.write.writeUInt8(x) - y = self.read.readUInt8() - self.assertEqual(x, y) - - def testWriteInt8Int(self): - '''QDataStream.writeInt8 (accepting integer)''' - x = 65 - self.write.writeInt8(x) - y = self.read.readInt8() - self.assertEqual(x, y) - - def testWriteUInt16(self): - '''QDataStream.writeUInt16''' - x = 0x4423 - self.write.writeUInt16(x) - y = int(self.read.readUInt16()) - self.assertEqual(x, y) - - def testWriteUInt32(self): - '''QDataStream.writeUInt32''' - x = 0xdeadbeef - self.write.writeUInt32(x) - y = int(self.read.readUInt32()) - self.assertEqual(x, y) - - -class QDataStreamShift(unittest.TestCase): - '''Test case for << and >> operators''' - - def setUp(self): - self.ba = QByteArray() - self.stream = QDataStream(self.ba, QIODevice.WriteOnly) - self.read_stream = QDataStream(self.ba, QIODevice.ReadOnly) - - def testQCharValid(self): - '''QDataStream <<>> QChar - valid''' - self.stream << QChar(42) - - res = QChar() - - self.read_stream >> res - self.assertEqual(res, QChar(42)) - - def testQCharNull(self): - '''QDataStream <<>> QChar - null''' - self.stream << QChar() - - res = QChar() - - self.read_stream >> res - self.assertEqual(res, QChar()) - self.assert_(res.isNull()) - - def testQByteArrayValid(self): - '''QDataStream <<>> QByteArray - valid''' - self.stream << QByteArray("hello") - - res = QByteArray() - - self.read_stream >> res - self.assertEqual(res, QByteArray("hello")) - - def testQByteArrayEmpty(self): - '''QDataStream <<>> QByteArray - empty''' - self.stream << QByteArray("") - - res = QByteArray() - - self.read_stream >> res - self.assertEqual(res, QByteArray("")) - self.assert_(res.isEmpty()) - self.assert_(not res.isNull()) - - def testQByteArrayNull(self): - '''QDataStream <<>> QByteArray - null''' - self.stream << QByteArray() - - res = QByteArray() - - self.read_stream >> res - self.assertEqual(res, QByteArray()) - self.assert_(res.isEmpty()) - self.assert_(res.isNull()) - - def testQStringValid(self): - '''QDataStream <<>> QString - valid''' - self.stream << QString('Ka-boom') - - res = QString() - - self.read_stream >> res - self.assertEqual(res, QString('Ka-boom')) - - def testQStringEmpty(self): - '''QDataStream <<>> QString - empty''' - self.stream << QString('') - - res = QString() - - self.read_stream >> res - self.assertEqual(res, QString("")) - self.assert_(res.isEmpty()) - self.assert_(not res.isNull()) - - def testQStringNull(self): - '''QDataStream <<>> QString - null''' - self.stream << QString() - - res = QString() - - self.read_stream >> res - self.assertEqual(res, QString()) - self.assert_(res.isEmpty()) - self.assert_(res.isNull()) - - - def testQBitArrayNull(self): - '''QDataStream <<>> QBitArray - null''' - self.stream << QBitArray() - - res = QBitArray() - - self.read_stream >> res - self.assertEqual(res, QBitArray()) - - def testQBitArrayValid(self): - '''QDataStream <<>> QBitArray - valid''' - self.stream << create_bitarray('01010101') - - res = QBitArray() - - self.read_stream >> res - self.assertEqual(res, create_bitarray('01010101')) - - def testQDateNull(self): - '''QDataStream <<>> QDate - null''' - self.stream << QDate() - - res = QDate() - - self.read_stream >> res - self.assertEqual(res, QDate()) - self.assert_(not res.isValid()) - self.assert_(res.isNull()) - - def testQDateValid(self): - '''QDataStream <<>> QDate - valid''' - self.stream << QDate(2012, 12, 21) - - res = QDate() - - self.read_stream >> res - self.assertEqual(res, QDate(2012, 12, 21)) - self.assert_(res.isValid()) - self.assert_(not res.isNull()) - - - def testQTimeNull(self): - '''QDataStream <<>> QTime - null''' - self.stream << QTime() - - res = QTime() - - self.read_stream >> res - self.assertEqual(res, QTime()) - self.assert_(not res.isValid()) - self.assert_(res.isNull()) - - def testQTimeValid(self): - '''QDataStream <<>> QTime - valid''' - self.stream << QTime(12, 12, 21) - - res = QTime() - - self.read_stream >> res - self.assertEqual(res, QTime(12, 12, 21)) - self.assert_(res.isValid()) - self.assert_(not res.isNull()) - - def testQDateTimeNull(self): - '''QDataStream <<>> QDateTime - null''' - - self.stream << QDateTime() - - res = QDateTime() - - self.read_stream >> res - self.assertEqual(res, QDateTime()) - self.assert_(not res.isValid()) - self.assert_(res.isNull()) - - def testQDateTimeValid(self): - '''QDataStream <<>> QDateTime - valid''' - time = QTime(23, 23, 23) - date = QDate(2009, 01, 01) - - self.stream << QDateTime(date, time) - - res = QDateTime() - - self.read_stream >> res - self.assertEqual(res, QDateTime(date, time)) - self.assert_(res.isValid()) - self.assert_(not res.isNull()) - - -class QDataStreamShiftBitArray(unittest.TestCase): - - def _check_bitarray(self, data_set): - '''Check the >> operator for the given data set''' - - for data, expectedStatus, expectedString in data_set: - stream = QDataStream(data, QIODevice.ReadOnly) - string = QBitArray() - stream >> string - - self.assertEqual(stream.status(), expectedStatus) - self.assertEqual(string.size(), expectedString.size()) - self.assertEqual(string, expectedString) - - def testOk(self): - '''QDataStream with valid QBitArray''' - data = [] - - data.append((QByteArray('\x00\x00\x00\x00'), QDataStream.Ok, - QBitArray())) - data.append((QByteArray('\x00\x00\x00\x01\x00'), QDataStream.Ok, - create_bitarray('0'))) - data.append((QByteArray('\x00\x00\x00\x01\x01'), QDataStream.Ok, - create_bitarray('1'))) - data.append((QByteArray('\x00\x00\x00\x02\x03'), QDataStream.Ok, - create_bitarray('11'))) - data.append((QByteArray('\x00\x00\x00\x03\x07'), QDataStream.Ok, - create_bitarray('111'))) - data.append((QByteArray('\x00\x00\x00\x04\x0f'), QDataStream.Ok, - create_bitarray('1111'))) - data.append((QByteArray('\x00\x00\x00\x05\x1f'), QDataStream.Ok, - create_bitarray('11111'))) - data.append((QByteArray('\x00\x00\x00\x06\x3f'), QDataStream.Ok, - create_bitarray('111111'))) - data.append((QByteArray('\x00\x00\x00\x07\x7f'), QDataStream.Ok, - create_bitarray('1111111'))) - data.append((QByteArray('\x00\x00\x00\x07\x7e'), QDataStream.Ok, - create_bitarray('0111111'))) - data.append((QByteArray('\x00\x00\x00\x07\x00'), QDataStream.Ok, - create_bitarray('0000000'))) - data.append((QByteArray('\x00\x00\x00\x07\x39'), QDataStream.Ok, - create_bitarray('1001110'))) - - self._check_bitarray(data) - - def testPastEnd(self): - '''QDataStream >> QBitArray reading past the end of the data''' - data = [] - - data.append((QByteArray(), QDataStream.ReadPastEnd, - QBitArray())) - data.append((QByteArray('\x00'), QDataStream.ReadPastEnd, - QBitArray())) - data.append((QByteArray('\x00\x00'), QDataStream.ReadPastEnd, - QBitArray())) - data.append((QByteArray('\x00\x00\x00'), QDataStream.ReadPastEnd, - QBitArray())) - data.append((QByteArray('\x00\x00\x00\x01'), QDataStream.ReadPastEnd, - QBitArray())) - data.append((QByteArray('\x00\x00\x00\x02'), QDataStream.ReadPastEnd, - QBitArray())) - data.append((QByteArray('\x00\x00\x00\x03'), QDataStream.ReadPastEnd, - QBitArray())) - data.append((QByteArray('\x00\x00\x00\x04'), QDataStream.ReadPastEnd, - QBitArray())) - - self._check_bitarray(data) - - def testCorruptData(self): - '''QDataStream reading corrupt data''' - data = [] - - data.append((QByteArray('\x00\x00\x00\x01\x02'), - QDataStream.ReadCorruptData, - QBitArray())) - - self._check_bitarray(data) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qdate_test.py b/tests/qtcore/qdate_test.py deleted file mode 100644 index 49234486f..000000000 --- a/tests/qtcore/qdate_test.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python -'''Test cases for QDate''' - -import unittest - -from PySide.QtCore import * - -class TestQDate (unittest.TestCase): - def testGetDate(self): - date = QDate(2009, 22, 9) - tuple_ = date.getDate() - self.assertEquals(tuple, tuple_.__class__) - (y, m, d) = tuple_ - self.assertEqual(date.year(), y) - self.assertEqual(date.month(), m) - self.assertEqual(date.day(), d) - - def testGetWeekNumber(self): - date = QDate(2000, 1, 1) - tuple_ = date.weekNumber() - self.assertEquals(tuple, tuple_.__class__) - (week, yearNumber) = tuple_ - self.assertEqual(week, 52) - self.assertEqual(yearNumber, 1999) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qenum_test.py b/tests/qtcore/qenum_test.py deleted file mode 100644 index e3f963869..000000000 --- a/tests/qtcore/qenum_test.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python -'''Test cases for QEnum and QFlags''' - -import unittest - -from PySide.QtCore import QIODevice, QString, Qt, QVariant - -class TestEnum(unittest.TestCase): - - def testToInt(self): - self.assertEqual(QIODevice.NotOpen, 0) - self.assertEqual(QIODevice.ReadOnly, 1) - self.assertEqual(QIODevice.WriteOnly, 2) - self.assertEqual(QIODevice.ReadWrite, 1 | 2) - self.assertEqual(QIODevice.Append, 4) - self.assertEqual(QIODevice.Truncate, 8) - self.assertEqual(QIODevice.Text, 16) - self.assertEqual(QIODevice.Unbuffered, 32) - - def testToIntInFunction(self): - self.assertEqual(QString.number(QIODevice.WriteOnly), "2") - -class TestQFlags(unittest.TestCase): - def testToItn(self): - om = QIODevice.NotOpen - - self.assertEqual(om, QIODevice.NotOpen) - self.assertTrue(om == 0) - - self.assertTrue(om != QIODevice.ReadOnly) - self.assertTrue(om != 1) - - def testToIntInFunction(self): - om = QIODevice.WriteOnly - self.assertEqual(int(om), 2) - - def testNonExtensibleEnums(self): - try: - om = QIODevice.OpenMode(QIODevice.WriteOnly) - self.assertFail() - except: - pass - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qevent_test.py b/tests/qtcore/qevent_test.py deleted file mode 100644 index 07f23f098..000000000 --- a/tests/qtcore/qevent_test.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -'''Test cases for QtCore.QEvent''' - -import unittest - -from PySide.QtCore import QEvent - -class QEventTypeFlag(unittest.TestCase): - '''Test case for usage of QEvent.Type flags''' - - def testFlagAccess(self): - #QEvent.Type flags usage - - event = QEvent(QEvent.Timer) - self.assertEqual(event.type(), QEvent.Timer) - - event = QEvent(QEvent.Close) - self.assertEqual(event.type(), QEvent.Close) - - event = QEvent(QEvent.IconTextChange) - self.assertEqual(event.type(), QEvent.IconTextChange) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qfile_test.py b/tests/qtcore/qfile_test.py deleted file mode 100644 index adbdd68b7..000000000 --- a/tests/qtcore/qfile_test.py +++ /dev/null @@ -1,31 +0,0 @@ - -import unittest - -import os -import tempfile - -from PySide.QtCore import QFile, QIODevice - -class GetCharTest(unittest.TestCase): - '''Test case for QIODevice.getChar in QFile''' - - def setUp(self): - '''Acquire resources''' - handle, self.filename = tempfile.mkstemp() - os.write(handle, 'a') - os.close(handle) - - def tearDown(self): - '''release resources''' - os.remove(self.filename) - - def testBasic(self): - '''QFile.getChar''' - obj = QFile(self.filename) - obj.open(QIODevice.ReadOnly) - self.assertEqual(obj.getChar(), (True, 'a')) - self.assert_(not obj.getChar()[0]) - obj.close() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qfileinfo_test.py b/tests/qtcore/qfileinfo_test.py deleted file mode 100644 index 580b5a7d5..000000000 --- a/tests/qtcore/qfileinfo_test.py +++ /dev/null @@ -1,17 +0,0 @@ - -import unittest - -import os -import tempfile - -from PySide.QtCore import QFile, QFileInfo - -class QFileConstructor(unittest.TestCase): - '''QFileInfo constructor with qfile''' - - def testBasic(self): - '''QFileInfo(QFile)''' - obj = QFileInfo(QFile()) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qflags_test.py b/tests/qtcore/qflags_test.py deleted file mode 100644 index 1346c11ef..000000000 --- a/tests/qtcore/qflags_test.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python -'''Test cases for QFlags''' - -import unittest -from PySide.QtCore import QIODevice, Qt, QFile - -class QFlagTest(unittest.TestCase): - '''Test case for usage of flags''' - - def testCallFunction(self): - f = QFile("/tmp/t0"); - self.assertEqual(f.open(QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite), True) - om = f.openMode() - self.assertEqual(om & QIODevice.Truncate, QIODevice.Truncate) - self.assertEqual(om & QIODevice.Text, QIODevice.Text) - self.assertEqual(om & QIODevice.ReadWrite, QIODevice.ReadWrite) - self.assert_(om == QIODevice.Truncate | QIODevice.Text | QIODevice.ReadWrite) - f.close() - - -class QFlagOperatorTest(unittest.TestCase): - '''Test case for operators in QFlags''' - - def testInvert(self): - '''QFlags ~ (invert) operator''' - self.assert_(isinstance(~QIODevice.ReadOnly, QIODevice.OpenMode)) - - def testOr(self): - '''QFlags | (or) operator''' - self.assert_(isinstance(QIODevice.ReadOnly | QIODevice.WriteOnly, QIODevice.OpenMode)) - - def testAnd(self): - '''QFlags & (and) operator''' - self.assert_(isinstance(QIODevice.ReadOnly & QIODevice.WriteOnly, QIODevice.OpenMode)) - - def testIOr(self): - '''QFlags |= (ior) operator''' - flag = Qt.WindowFlags() - self.assert_(flag & Qt.Widget == 0) - flag |= Qt.WindowMinimizeButtonHint - self.assert_(flag & Qt.WindowMinimizeButtonHint) - - def testInvertOr(self): - '''QFlags ~ (invert) operator over the result of an | (or) operator''' - self.assert_(isinstance(~(Qt.ItemIsSelectable | Qt.ItemIsEditable), Qt.ItemFlags)) - - def testEqual(self): - '''QFlags == operator''' - flags = Qt.Window - flags |= Qt.WindowMinimizeButtonHint - flag_type = (flags & Qt.WindowType_Mask) - self.assertEqual(flag_type, Qt.Window) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qhandle_test.py b/tests/qtcore/qhandle_test.py deleted file mode 100644 index bcf6dea3d..000000000 --- a/tests/qtcore/qhandle_test.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python -'''Test cases for QEnum and QFlags''' - -import unittest - -from PySide.QtCore import QThread, Qt - -class TestHANDLE(unittest.TestCase): - def testIntConversion(self): - i = 0 - h = QThread.currentThreadId() - i = 0 + int(h) - self.assertEqual(i, int(h)) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qlatin1string_test.py b/tests/qtcore/qlatin1string_test.py deleted file mode 100644 index fdcf6ec98..000000000 --- a/tests/qtcore/qlatin1string_test.py +++ /dev/null @@ -1,21 +0,0 @@ - -'''Test cases for QLatin1String''' - -import unittest - -from PySide.QtCore import QString, QLatin1String, QObject - - -class ImplicitConvQLatin1String(unittest.TestCase): - '''Tests for implicit conversion from QLatin1String to QString''' - - def testQLatin1String(self): - '''QString implicit convertion from QLatin1String''' - obj = QObject() - obj.setObjectName(QLatin1String('dummy')) - - self.assertEqual(QString('dummy'), obj.objectName()) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qlinef_test.py b/tests/qtcore/qlinef_test.py deleted file mode 100644 index 31b5db955..000000000 --- a/tests/qtcore/qlinef_test.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -'''Test cases for QLineF''' - -import unittest -import os - -from PySide.QtCore import * - -class TestQLineF (unittest.TestCase): - def testIntersect(self): - l1 = QLineF(0, 0, 1, 0) - l2 = QLineF(1, -1, 1, 1) - tuple_ = l1.intersect(l2) - self.assertEquals(tuple, tuple_.__class__) - (value, p) = tuple_ - self.assertEquals(QLineF.BoundedIntersection, value) - self.assertEqual(QPointF(1, 0), p) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qlocale_test.py b/tests/qtcore/qlocale_test.py deleted file mode 100644 index f1bff8e82..000000000 --- a/tests/qtcore/qlocale_test.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python -'''Unit tests for QLocale''' - -import unittest -import ctypes -import sys - -from PySide.QtCore import QLocale - -class QLocaleTestToNumber(unittest.TestCase): - def testToNumberInt(self): - obj = QLocale(QLocale.C) - self.assertEqual((37, True), obj.toInt('37')) - - def testToNumberFloat(self): - obj = QLocale(QLocale.C) - self.assertEqual((ctypes.c_float(37.109).value, True), - obj.toFloat('37.109')) - - def testToNumberDouble(self): - obj = QLocale(QLocale.C) - self.assertEqual((ctypes.c_double(37.109).value, True), - obj.toDouble('37.109')) - - def testToNumberShort(self): - obj = QLocale(QLocale.C) - self.assertEqual((ctypes.c_short(37).value, True), - obj.toShort('37')) - - def testToNumberULongLong(self): - obj = QLocale(QLocale.C) - self.assertEqual((ctypes.c_ulonglong(37).value, True), - obj.toULongLong('37')) - - def testToNumberULongLongNegative(self): - obj = QLocale(QLocale.C) - self.assert_(not obj.toULongLong('-37')[1]) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qmetaobject_test.py b/tests/qtcore/qmetaobject_test.py deleted file mode 100644 index 667e763ad..000000000 --- a/tests/qtcore/qmetaobject_test.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Tests for static methos conflicts with class methods''' - -import unittest - -from PySide.QtCore import * - -class Foo(QFile): - pass - -class DynObject(QObject): - def slot(self): - pass - -class qmetaobject_test(unittest.TestCase): - def test_QMetaObject(self): - qobj = QObject() - qobj_metaobj = qobj.metaObject() - self.assertEqual(qobj_metaobj.className(), "QObject") - - obj = QFile() - m = obj.metaObject() - self.assertEqual(m.className(), "QFile") - self.assertNotEqual(m.methodCount(), qobj_metaobj.methodCount()) - - obj = Foo() - m = obj.metaObject() - self.assertEqual(m.className(), "Foo") - f = QFile() - fm = f.metaObject() - self.assertEqual(m.methodCount(), fm.methodCount()) - - def test_DynamicSlotSignal(self): - o = DynObject() - o2 = QObject() - - method_count_base = o.metaObject().methodCount() - - o.connect(o2, SIGNAL("bar()"), o.slot) - slot_index = o.metaObject().indexOfMethod("slot()") - - o.connect(o, SIGNAL("foo()"), o2, SIGNAL("bar()")) - signal_index = o.metaObject().indexOfMethod("foo()"); - - self.assert_(slot_index != signal_index) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qmodelindex_internalpointer_test.py b/tests/qtcore/qmodelindex_internalpointer_test.py deleted file mode 100644 index 015d1c926..000000000 --- a/tests/qtcore/qmodelindex_internalpointer_test.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- - -''' Test case for QAbstractListModel.createIndex and QModelIndex.internalPointer''' - -import sys -import unittest -from PySide.QtCore import * - -class MyModel (QAbstractListModel): - pass - -class TestQModelIndexInternalPointer(unittest.TestCase): - ''' Test case for QAbstractListModel.createIndex and QModelIndex.internalPointer''' - - def setUp(self): - #Acquire resources - self.model = MyModel() - - def tearDown(self): - #Release resources - del self.model - - def testInternalPointer(self): - #Test QAbstractListModel.createIndex and - #QModelIndex.internalPointer with regular - #Python objects - idx = self.model.createIndex(0, 0, "Hello") - self.assertEqual("Hello", idx.internalPointer()) - a = [1, 2, 3] - idx = self.model.createIndex(0, 0, a) - self.assertEqual(a, idx.internalPointer()) - - def testReferenceCounting(self): - #Test reference counting when retrieving data with - #QModelIndex.internalPointer - a = [1, 2, 3] - a_refcnt = sys.getrefcount(a) - idx = self.model.createIndex(0, 0, a) - ptr = idx.internalPointer() - self.assertEqual(sys.getrefcount(a), a_refcnt + 1) - - def testIndexForDefaultDataArg(self): - #Test QAbstractListModel.createIndex with a default - #value for data argument - idx = self.model.createIndex(0, 0) - self.assertEqual(None, idx.internalPointer()) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qobject_children_segfault_test.py b/tests/qtcore/qobject_children_segfault_test.py deleted file mode 100644 index 930a082cf..000000000 --- a/tests/qtcore/qobject_children_segfault_test.py +++ /dev/null @@ -1,29 +0,0 @@ - -'''Test cases for parent-child relationship''' - -import unittest - -from PySide.QtCore import QObject, QCoreApplication - -class ChildrenCoreApplication(unittest.TestCase): - '''Test case for calling QObject.children after creating a QCoreApp''' - - def testQCoreAppChildren(self): - #QObject.children() after creating a QCoreApplication - # Minimal test: - # 1- Create QCoreApp - # 2- Create parent and childrens - # 3- While keeping the children alive, call parent.children() - # 4- Delete parent - app = QCoreApplication([]) - parent = QObject() - children = [QObject(parent) for x in range(25)] - # Uncomment the lines below to make the test pass - # del children - # del child2 - del parent # XXX Segfaults here - self.assert_(True) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_connect_notify_test.py b/tests/qtcore/qobject_connect_notify_test.py deleted file mode 100644 index 441037585..000000000 --- a/tests/qtcore/qobject_connect_notify_test.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- - -''' Test case for QObject::connectNotify()''' - -import unittest -from PySide.QtCore import * -from helper import UsesQCoreApplication - -def cute_slot(): - pass - -class Obj(QObject): - def __init__(self): - QObject.__init__(self) - self.con_notified = False - self.dis_notified = False - - def connectNotify(self, signal): - self.con_notified = True - - def disconnectNotify(self, signal): - self.dis_notified = True - - def reset(self): - self.con_notified = False - self.dis_notified = False - -class TestQObjectConnectNotify(UsesQCoreApplication): - '''Test case for QObject::connectNotify''' - def setUp(self): - UsesQCoreApplication.setUp(self) - self.called = False - - def tearDown(self): - UsesQCoreApplication.tearDown(self) - - def testBasic(self): - sender = Obj() - receiver = QObject() - sender.connect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) - self.assert_(sender.con_notified) - sender.disconnect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) - self.assert_(sender.dis_notified) - - def testPySignal(self): - sender = Obj() - receiver = QObject() - sender.connect(SIGNAL("foo()"), receiver, SLOT("deleteLater()")) - self.assert_(sender.con_notified) - sender.disconnect(SIGNAL("foo()"), receiver, SLOT("deleteLater()")) - self.assert_(sender.dis_notified) - - def testPySlots(self): - sender = Obj() - receiver = QObject() - sender.connect(SIGNAL("destroyed()"), cute_slot) - self.assert_(sender.con_notified) - sender.disconnect(SIGNAL("destroyed()"), cute_slot) - self.assert_(sender.dis_notified) - - def testpyAll(self): - sender = Obj() - receiver = QObject() - sender.connect(SIGNAL("foo()"), cute_slot) - self.assert_(sender.con_notified) - sender.disconnect(SIGNAL("foo()"), cute_slot) - self.assert_(sender.dis_notified) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_event_filter_test.py b/tests/qtcore/qobject_event_filter_test.py deleted file mode 100644 index 8018fcda0..000000000 --- a/tests/qtcore/qobject_event_filter_test.py +++ /dev/null @@ -1,80 +0,0 @@ - -'''Test cases for QObject.eventFilter''' - -import unittest - -from PySide.QtCore import QObject, QTimerEvent - -from helper import UsesQCoreApplication - -class FilterObject(QObject): - '''Filter object for the basic test''' - def __init__(self, obj=None, event_type=None, *args): - #Creates a new filter object - QObject.__init__(self, *args) - self.obj = obj - self.event_type = event_type - self.events_handled = 0 - self.events_bypassed = 0 - - def setTargetObject(self, obj): - #Sets the object that will be filtered - self.obj = obj - - def eventFilter(self, obj, event): - '''Just checks if is the correct object and event type - incrementing counter until reaching the limit. After that it - stops filtering the events for the object.''' - if (self.obj == obj): - if isinstance(event, self.event_type) and self.events_handled < 5: - self.events_handled += 1 - return True - else: - self.events_bypassed += 1 - return False - else: - return QObject.eventFilter(self, obj, event) - -class FilteredObject(QObject): - '''Class that will be filtered. Quits the app after 5 timer events''' - def __init__(self, app, *args): - QObject.__init__(self, *args) - self.app = app - self.times_called = 0 - - def timerEvent(self, evt): - #Overriden method - self.times_called += 1 - - if self.times_called == 5: - self.app.quit() - -class TestQObjectEventFilterPython(UsesQCoreApplication): - '''QObject.eventFilter - Reimplemented in python - Filters 5 TimerEvents and then bypasses the other events to the - timerEvent method. After 5 runs, the timerEvent method will ask - the core application to exit''' - def setUp(self): - #Acquire resources - UsesQCoreApplication.setUp(self) - self.obj_filter = FilterObject(event_type=QTimerEvent) - def tearDown(self): - #Release resources - del self.obj_filter - UsesQCoreApplication.tearDown(self) - - def testEventFilter(self): - #QObject.eventFilter reimplemented in python - filtered = FilteredObject(self.app) - filtered.installEventFilter(self.obj_filter) - self.obj_filter.setTargetObject(filtered) - - filtered.startTimer(0) - - self.app.exec_() - - self.assertEqual(filtered.times_called, 5) - self.assertEqual(self.obj_filter.events_handled, 5) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_inherits_test.py b/tests/qtcore/qobject_inherits_test.py deleted file mode 100644 index 9e02b0a46..000000000 --- a/tests/qtcore/qobject_inherits_test.py +++ /dev/null @@ -1,43 +0,0 @@ -'''Test cases for QObject methods''' - -import unittest - -from PySide.QtCore import QObject - -class InheritsCase(unittest.TestCase): - '''Test case for QObject.inherits''' - - def testCppInheritance(self): - #QObject.inherits() for c++ classes - #An class inherits itself - self.assert_(QObject().inherits('QObject')) - - def testPythonInheritance(self): - #QObject.inherits() for python classes - - class Dummy(QObject): - #Dummy class - pass - - self.assert_(Dummy().inherits('QObject')) - self.assert_(Dummy().inherits('Dummy')) - self.assert_(not Dummy().inherits('FooBar')) - - def testPythonMultiInheritance(self): - #QObject.inherits() for multiple inheritance - # QObject.inherits(classname) should fail if classname isn't a - # QObject subclass - - class Parent(object): - #Dummy parent - pass - class Dummy(QObject, Parent): - #Dummy class - pass - - self.assert_(Dummy().inherits('QObject')) - self.assert_(not Dummy().inherits('Parent')) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_parent_test.py b/tests/qtcore/qobject_parent_test.py deleted file mode 100644 index 4699fc60c..000000000 --- a/tests/qtcore/qobject_parent_test.py +++ /dev/null @@ -1,234 +0,0 @@ - -'''Test cases for parent-child relationship''' - -import unittest -from sys import getrefcount - -from PySide.QtCore import QObject, QTimer - -class ParentRefCountCase(unittest.TestCase): - '''Test case for the refcount changes of setParent''' - - def setUp(self): - #Acquire resources - self.parent = QObject() - self.child = QObject() - - def tearDown(self): - #Release resources - del self.child - del self.parent - - def testSetParent(self): - #QObject.setParent() refcount changes - self.assertEqual(getrefcount(self.child), 2) - self.child.setParent(self.parent) - self.assertEqual(getrefcount(self.child), 3) - - def testConstructor(self): - #QObject(QObject) refcount changes - child = QObject(self.parent) - self.assertEqual(getrefcount(child), 3) - -class ParentCase(unittest.TestCase): - '''Small collection of tests related to parent-child relationship''' - - def testSetParent(self): - #QObject.setParent() - parent = QObject() - child = QObject() - child.setParent(parent) - - self.assertEqual(parent, child.parent()) - - def testParentConstructor(self): - #QObject(parent) - parent = QObject() - child = QObject(parent) - - self.assertEqual(parent, child.parent()) - - orig_repr = repr(child) - del child - self.assertEqual(orig_repr, repr(parent.children()[0])) - - def testChildren(self): - #QObject.children() - parent = QObject() - children = [QObject(parent) for x in range(25)] - - self.assertEqual(parent.children(), children) - - def testFindChild(self): - #QObject.findChild() with all QObject - parent = QObject() - name = 'object%d' - children = [QObject(parent) for i in range(20)] - - for i, child in enumerate(children): - child.setObjectName(name % i) - - for i, child in enumerate(children): - self.assertEqual(child, parent.findChild(QObject, name % i)) - - def testFindChildren(self): - #QObject.findChildren() with all QObject - parent = QObject() - target_name = 'foo' - children = [QTimer(parent) for i in range(20)] - children.extend([QObject(parent) for i in range(20)]) - - for i, child in enumerate(children): - if i % 5 == 0: - child.setObjectName(target_name) - else: - child.setObjectName(str(i)) - - # Emulates findChildren with the intended outcome - target_children = [x for x in children if x.objectName() == target_name] - test_children = parent.findChildren(QObject, target_name) - - self.assertEqual(sorted(target_children), sorted(test_children)) - - def testParentEquality(self): - #QObject.parent() == parent - parent = QObject() - child = QObject(parent) - self.assertEqual(parent, child.parent()) - - -class TestParentOwnership(unittest.TestCase): - '''Test case for Parent/Child object ownership''' - - def testParentDestructor(self): - parent = QObject() - self.assertEqual(getrefcount(parent), 2) - - child = QObject(parent) - self.assertEqual(getrefcount(child), 3) - self.assertEqual(getrefcount(parent), 2) - - del parent - self.assertEqual(getrefcount(child), 2) - - # this will fail because parent deleted child cpp object - self.assertRaises(RuntimeError, lambda :child.objectName()) - - # test parent with multiples children - def testMultipleChildren(self): - o = QObject() - self.assertEqual(getrefcount(o), 2) - - c = QObject(o) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(o), 2) - - c2 = QObject(o) - self.assertEqual(getrefcount(o), 2) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(c2), 3) - - del o - self.assertEqual(getrefcount(c), 2) - self.assertEqual(getrefcount(c2), 2) - - # this will fail because parent deleted child cpp object - self.assertRaises(RuntimeError, lambda :c.objectName()) - self.assertRaises(RuntimeError, lambda :c2.objectName()) - - # test recursive parent - def testRecursiveParent(self): - o = QObject() - self.assertEqual(getrefcount(o), 2) - - c = QObject(o) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(o), 2) - - c2 = QObject(c) - self.assertEqual(getrefcount(o), 2) - self.assertEqual(getrefcount(c), 3) - self.assertEqual(getrefcount(c2), 3) - - del o - self.assertEqual(getrefcount(c), 2) - self.assertEqual(getrefcount(c2), 2) - - # this will fail because parent deleted child cpp object - self.assertRaises(RuntimeError, lambda :c.objectName()) - self.assertRaises(RuntimeError, lambda :c2.objectName()) - - # test parent transfer - def testParentTransfer(self): - o = QObject() - self.assertEqual(getrefcount(o), 2) - - c = QObject() - self.assertEqual(getrefcount(c), 2) - - c.setParent(o) - self.assertEqual(getrefcount(c), 3) - - c.setParent(None) - self.assertEqual(getrefcount(c), 2) - - del c - del o - - -class ExtQObject(QObject): - def __init__(self): - QObject.__init__(self) - -class ReparentingTest(unittest.TestCase): - '''Test cases for reparenting''' - - def testParentedQObjectIdentity(self): - object_list = [] - parent = QObject() - for i in range(3): - obj = QObject() - object_list.append(obj) - obj.setParent(parent) - for child in parent.children(): - self.assert_(child in object_list) - - def testParentedExtQObjectType(self): - object_list = [] - parent = QObject() - for i in range(3): - obj = ExtQObject() - object_list.append(obj) - obj.setParent(parent) - for orig, child in zip(object_list, parent.children()): - self.assertEqual(type(orig), type(child)) - - def testReparentedQObjectIdentity(self): - object_list = [] - old_parent = QObject() - new_parent = QObject() - for i in range(3): - obj = QObject() - object_list.append(obj) - obj.setParent(old_parent) - for obj in object_list: - obj.setParent(new_parent) - for child in new_parent.children(): - self.assert_(child in object_list) - - def testReparentedExtQObjectType(self): - object_list = [] - old_parent = QObject() - new_parent = QObject() - for i in range(3): - obj = ExtQObject() - object_list.append(obj) - obj.setParent(old_parent) - for obj in object_list: - obj.setParent(new_parent) - for orig, child in zip(object_list, new_parent.children()): - self.assertEqual(type(orig), type(child)) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_property_test.py b/tests/qtcore/qobject_property_test.py deleted file mode 100644 index 33df2ac9b..000000000 --- a/tests/qtcore/qobject_property_test.py +++ /dev/null @@ -1,71 +0,0 @@ - -'''Test cases for QObject property and setProperty''' - -import unittest - -from PySide.QtCore import QObject, QVariant, QString - -class PropertyCase(unittest.TestCase): - '''Test case for QObject properties''' - - def testObjectNameProperty(self): - #QObject.setProperty() for existing C++ property - obj = QObject() - self.assert_(obj.setProperty('objectName', QVariant('dummy'))) - self.assertEqual(obj.objectName(), 'dummy') - - self.assert_(obj.setProperty('objectName', QVariant('foobar'))) - self.assertEqual(obj.objectName(), 'foobar') - - def testDynamicProperty(self): - #QObject.setProperty() for dynamic properties - obj = QObject() - - # Should return false when creating a new dynamic property - self.assert_(not obj.setProperty('dummy', QVariant('mydata'))) - prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), 'mydata') - - self.assert_(not obj.setProperty('dummy', QVariant('zigzag'))) - prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), 'zigzag') - - self.assert_(not obj.setProperty('dummy', QVariant(42))) - prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - # QVariant.toInt has a bool* arg in C++, so returns a tuple - self.assertEqual(obj.property('dummy').toInt(), (42, True)) - - def testQStringProperty(self): - obj = QObject() - self.assert_(not obj.setProperty('dummy', QString('data'))) - prop = obj.property('dummy') - - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), QString('data')) - - def testImplicitQVariantProperty(self): - obj = QObject() - self.assert_(not obj.setProperty('dummy', 'data')) - prop = obj.property('dummy') - - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), 'data') - - def testInvalidProperty(self): - #QObject.property() for invalid properties - obj = QObject() - - prop = obj.property('dummy') - self.assert_(not prop.isValid()) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_protected_methods_test.py b/tests/qtcore/qobject_protected_methods_test.py deleted file mode 100644 index 530b870a2..000000000 --- a/tests/qtcore/qobject_protected_methods_test.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python -'''Test cases for QObject protected methods''' - -import unittest - -from PySide.QtCore import QObject, QThread, SIGNAL - -class Dummy(QObject): - '''Dummy class''' - pass - -class QObjectReceivers(unittest.TestCase): - '''Test case for QObject.receivers()''' - - def cb(self, *args): - #Dummy callback - pass - - def testQObjectReceiversExtern(self): - #QObject.receivers() - Protected method external access - - obj = Dummy() - self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0) - - QObject.connect(obj, SIGNAL("destroyed()"), self.cb) - self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0) - - def testQThreadReceiversExtern(self): - #QThread.receivers() - Inherited protected method - - obj = QThread() - self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0) - QObject.connect(obj, SIGNAL("destroyed()"), self.cb) - self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_test.py b/tests/qtcore/qobject_test.py deleted file mode 100644 index a1749babc..000000000 --- a/tests/qtcore/qobject_test.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QObject methods''' - -import unittest - -from PySide.QtCore import QObject - -class ObjectNameCase(unittest.TestCase): - '''Tests related to QObject object name''' - - def testSimple(self): - #QObject.objectName(string) - name = 'object1' - obj = QObject() - obj.setObjectName(name) - - self.assertEqual(name, obj.objectName()) - - def testEmpty(self): - #QObject.objectName('') - name = '' - obj = QObject() - obj.setObjectName(name) - - self.assertEqual(name, obj.objectName()) - - def testDefault(self): - #QObject.objectName() default - obj = QObject() - self.assertEqual('', obj.objectName()) - - def testUnicode(self): - #QObject.setObjectName(unicode) - name = u'diseño' - #FIXME Strange error on upstream when using equal(name, obj) - obj = QObject() - obj.setObjectName(name) - self.assertEqual(obj.objectName(), name) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_timer_event_test.py b/tests/qtcore/qobject_timer_event_test.py deleted file mode 100644 index b46207d88..000000000 --- a/tests/qtcore/qobject_timer_event_test.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python -'''Test case for QObject.timerEvent overloading''' - -import unittest -from time import sleep -from PySide.QtCore import QObject, QCoreApplication - -from helper import UsesQCoreApplication - -class Dummy(QObject): - - def __init__(self, app): - super(Dummy, self).__init__() - self.times_called = 0 - self.app = app - - def timerEvent(self, event): - QObject.timerEvent(self, event) - event.accept() - self.times_called += 1 - - if self.times_called == 5: - self.app.exit(0) - -class QObjectTimerEvent(UsesQCoreApplication): - - def setUp(self): - #Acquire resources - super(QObjectTimerEvent, self).setUp() - - def tearDown(self): - #Release resources - super(QObjectTimerEvent, self).tearDown() - - def testTimerEvent(self): - #QObject.timerEvent overloading - obj = Dummy(self.app) - timer_id = obj.startTimer(200) - self.app.exec_() - obj.killTimer(timer_id) - self.assertEqual(obj.times_called, 5) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qobject_tr_as_instance_test.py b/tests/qtcore/qobject_tr_as_instance_test.py deleted file mode 100644 index 5aa70530b..000000000 --- a/tests/qtcore/qobject_tr_as_instance_test.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -'''Unit tests for QObject's tr and trUtf8 static methods.''' - -import os -import unittest -from PySide.QtCore import QObject - -#from helper import UsesQCoreApplication - -class QObjectTrTest(unittest.TestCase): - '''Test case to check if QObject tr and trUtf8 static methods could be treated as instance methods.''' - - def setUp(self): - self.obj = QObject() - - def tearDown(self): - del self.obj - - def testTrCommonCase(self): - #Test common case for QObject.tr - invar1 = 'test1' - outvar1 = self.obj.tr(invar1) - invar2 = 'test2' - outvar2 = self.obj.tr(invar2, 'test comment') - self.assertEqual((invar1, invar2), (outvar1, outvar2)) - - def testTrAsInstanceMethod(self): - #Test QObject.tr as instance - invar1 = 'test1' - outvar1 = QObject.tr(self.obj, invar1) - invar2 = 'test2' - outvar2 = QObject.tr(self.obj, invar2, 'test comment') - self.assertEqual((invar1, invar2), (outvar1, outvar2)) - - def testTrUtf8CommonCase(self): - #Test common case for QObject.trUtf8 - invar1 = 'test1' - outvar1 = self.obj.trUtf8(invar1) - invar2 = 'test2' - outvar2 = self.obj.trUtf8(invar2, 'test comment') - self.assertEqual((invar1, invar2), (outvar1, outvar2)) - - def testTrUtf8AsInstanceMethod(self): - #Test QObject.trUtf8 as instance - invar1 = 'test1' - outvar1 = QObject.trUtf8(self.obj, invar1) - invar2 = 'test2' - outvar2 = QObject.trUtf8(self.obj, invar2, 'test comment') - self.assertEqual((invar1, invar2), (outvar1, outvar2)) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qpoint_test.py b/tests/qtcore/qpoint_test.py deleted file mode 100644 index dfce76939..000000000 --- a/tests/qtcore/qpoint_test.py +++ /dev/null @@ -1,21 +0,0 @@ - -'''Test cases for QPoint and QPointF''' - -import unittest - -from PySide.QtCore import QPoint, QPointF - - -class QPointTest(unittest.TestCase): - - def testQPointCtor(self): - point = QPoint(QPoint(10,20)) - -class QPointFTest(unittest.TestCase): - - def testQPointFCtor(self): - pointf = QPointF(QPoint(10,20)) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qprocess_test.py b/tests/qtcore/qprocess_test.py deleted file mode 100644 index b01c68ba3..000000000 --- a/tests/qtcore/qprocess_test.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python -'''Test cases for QProcess''' - -import unittest -import os - -from PySide.QtCore import * - -class TestQProcess (unittest.TestCase): - def testStartDetached(self): - value, pid = QProcess.startDetached("dir", [], os.getcwd()) - self.assert_(isinstance(value, bool)) - self.assert_(isinstance(pid, long)) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qrect_test.py b/tests/qtcore/qrect_test.py deleted file mode 100644 index 3c5f5be05..000000000 --- a/tests/qtcore/qrect_test.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/python -'''Test cases for QRect''' - -import unittest - -from PySide.QtCore import QPoint, QRect - -class RectConstructor(unittest.TestCase): - - def testDefault(self): - #QRect() - obj = QRect() - - self.assert_(obj.isNull()) - - def testConstructorQPoint(self): - topLeft = QPoint(3, 0) - bottomRight = QPoint(0, 3) - - rect1 = QRect(topLeft, bottomRight) - rect2 = QRect(topLeft, bottomRight) - - self.assertEqual(rect1, rect2) - -class RectOperator(unittest.TestCase): - '''Test case for QRect operators''' - - def testEqual(self): - '''QRect == QRect - Note: operator == must be working as it's the main check - for correctness''' - rect1 = QRect() - rect2 = QRect() - self.assertEqual(rect1, rect2) - - rect1 = QRect(0, 4, 100, 300) - rect2 = QRect(0, 4, 100, 300) - self.assertEqual(rect1, rect2) - - def testNullRectIntersection(self): - #QRect & QRect for null rects - rect1 = QRect() - rect2 = QRect() - rect3 = rect1 & rect2 - self.assertEqual(rect3, rect1) - self.assertEqual(rect3, rect2) - - def testNoIntersect(self): - '''QRect & QRect for non-intersecting QRects - Non-intersecting QRects return a 'null' QRect for operator &''' - rect1 = QRect(10, 10, 5, 5) - rect2 = QRect(20, 20, 5, 5) - rect3 = rect1 & rect2 - self.assertEqual(rect3, QRect()) - - def testIntersectPartial(self): - #QRect & QRect for partial intersections - rect1 = QRect(10, 10, 10, 10) - rect2 = QRect(15, 15, 10, 10) - rect3 = rect1 & rect2 - self.assertEqual(rect3, QRect(15, 15, 5, 5)) - - def testIntersetEnclosed(self): - #QRect & QRect for a qrect inside another - rect1 = QRect(10, 10, 20, 20) - rect2 = QRect(15, 15, 5, 5) - rect3 = rect1 & rect2 - self.assertEqual(rect3, rect2) - - def testNullRectIntersectBounding(self): - #QRect | QRect for null rects - rect1 = QRect() - rect2 = QRect() - rect3 = rect1 & rect2 - self.assertEqual(rect3, rect1) - self.assertEqual(rect3, rect2) - - def testNoIntersectBounding(self): - '''QRect | QRect for non-intersecting QRects - Non-intersecting QRects return a greater QRect for operator |''' - rect1 = QRect(10, 10, 5, 5) - rect2 = QRect(20, 20, 5, 5) - rect3 = rect1 | rect2 - self.assertEqual(rect3, QRect(10, 10, 15, 15)) - - def testBoundingPartialIntersection(self): - #QRect | QRect for partial intersections - rect1 = QRect(10, 10, 10, 10) - rect2 = QRect(15, 15, 10, 10) - rect3 = rect1 | rect2 - self.assertEqual(rect3, QRect(10, 10, 15, 15)) - - def testBoundingEnclosed(self): - #QRect | QRect for a qrect inside another - rect1 = QRect(10, 10, 20, 20) - rect2 = QRect(15, 15, 5, 5) - rect3 = rect1 | rect2 - self.assertEqual(rect3, rect1) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qresource_test.py b/tests/qtcore/qresource_test.py deleted file mode 100644 index 8f3350a60..000000000 --- a/tests/qtcore/qresource_test.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- - -'''Test cases for QResource usage''' - -import unittest -import os -from PySide.QtCore import QFile, QIODevice -import resources_mc - -class ResourcesUsage(unittest.TestCase): - '''Test case for resources usage''' - - def setUp(self): - f = open(os.path.join(os.path.dirname(__file__), 'quoteEnUS.txt')) - self.text = f.read() - f.close() - - def tearDown(self): - self.text = None - - def testPhrase(self): - #Test loading of quote.txt resource - f = QFile(':/quote.txt') - f.open(QIODevice.ReadOnly|QIODevice.Text) - content = f.readAll() - f.close() - self.assertEqual(self.text, content) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qsize_test.py b/tests/qtcore/qsize_test.py deleted file mode 100644 index 4fb060b74..000000000 --- a/tests/qtcore/qsize_test.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python -'''Unit tests for QSize''' - -import unittest - -from PySide.QtCore import QSize - -class QSizeOperator(unittest.TestCase): - def testOperatorMultiply(self): - #QSize operator * float - # bug 131 - a = QSize(1, 1) - x = a * 3.4 - self.assertEqual(QSize(3, 3), x) - - def testOperatorRevertedMultiply(self): - #QSize operator * float, reverted - # bug 132 - a = QSize(1, 1) - x = 3.4 * a - self.assertEqual(QSize(3, 3), x) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qslot_object_test.py b/tests/qtcore/qslot_object_test.py deleted file mode 100644 index ad0ea3a14..000000000 --- a/tests/qtcore/qslot_object_test.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide import QtCore - -global qApp - -class objTest(QtCore.QObject): - - def __init__(self, parent=None): - QtCore.QObject.__init__(self, parent) - - self.ok = False - - def slot(self): - global qApp - - self.ok = True - qApp.quit() - - - -class slotTest(unittest.TestCase): - def quit_app(self): - global qApp - - qApp.quit() - - def testBasic(self): - global qApp - timer = QtCore.QTimer() - timer.setInterval(100) - - my_obj = objTest() - my_slot = QtCore.SLOT("slot()") - QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), my_obj, my_slot) - timer.start(100) - - QtCore.QTimer.singleShot(1000, self.quit_app) - qApp.exec_() - - self.assert_(my_obj.ok) - - -if __name__ == '__main__': - global qApp - qApp = QtCore.QCoreApplication([]) - unittest.main() diff --git a/tests/qtcore/qsrand_test.py b/tests/qtcore/qsrand_test.py deleted file mode 100644 index 97d0a3b0b..000000000 --- a/tests/qtcore/qsrand_test.py +++ /dev/null @@ -1,16 +0,0 @@ -import gc -import unittest - -from PySide.QtCore import qsrand - -class OverflowExceptionCollect(unittest.TestCase): - '''Test case for OverflowError exception during garbage collection. See bug #147''' - - def testOverflow(self): - # NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError - self.assertRaises(OverflowError, qsrand, 42415335332353253) - # should not abort if bug #147 is fixed - gc.collect() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qstate_test.py b/tests/qtcore/qstate_test.py deleted file mode 100644 index d7c9a4c44..000000000 --- a/tests/qtcore/qstate_test.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide.QtCore import QObject, QState, QFinalState, SIGNAL, QCoreApplication, QTimer, QStateMachine, QSignalTransition, QVariant - - -class QStateTest(unittest.TestCase): - def testBasic(self): - app = QCoreApplication([]) - - o = QObject() - o.setProperty("text", QVariant("INdT")) - - machine = QStateMachine() - s1 = QState() - s1.assignProperty(o, "text", QVariant("Rocks")); - - s2 = QFinalState() - t = s1.addTransition(o, SIGNAL("change()"), s2); - self.assert_(isinstance(t, QSignalTransition)) - - machine.addState(s1) - machine.addState(s2) - machine.setInitialState(s1) - machine.start() - - o.emit(SIGNAL("change()")) - - QTimer.singleShot(100, app.quit) - app.exec_() - - txt = o.property("text").toString() - self.assert_(txt, "Rocks") - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qstatemachine_test.py b/tests/qtcore/qstatemachine_test.py deleted file mode 100644 index ce2449d15..000000000 --- a/tests/qtcore/qstatemachine_test.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide.QtCore import QObject, QState, QFinalState, SIGNAL -from PySide.QtCore import QTimer, QStateMachine -from PySide.QtCore import QParallelAnimationGroup - -from helper import UsesQCoreApplication - - -class StateMachineTest(unittest.TestCase): - '''Check presence of State Machine classes''' - - def testBasic(self): - '''State machine classes''' - import PySide.QtCore - PySide.QtCore.QSignalTransition - PySide.QtCore.QPropertyAnimation - - - -class QStateMachineTest(UsesQCoreApplication): - - def cb(self, *args): - self.assertEqual(self.machine.defaultAnimations(), [self.anim]) - - def testBasic(self): - self.machine = QStateMachine() - s1 = QState() - s2 = QState() - s3 = QFinalState() - - QObject.connect(self.machine, SIGNAL("started()"), self.cb) - - self.anim = QParallelAnimationGroup() - - self.machine.addState(s1) - self.machine.addState(s2) - self.machine.addState(s3) - self.machine.setInitialState(s1) - self.machine.addDefaultAnimation(self.anim) - self.machine.start() - - QTimer.singleShot(100, self.app.quit) - self.app.exec_() - - -class QSetConverterTest(UsesQCoreApplication): - '''Test converter of QSet toPython using QStateAnimation.configuration''' - - def testBasic(self): - '''QStateMachine.configuration converting QSet to python set''' - machine = QStateMachine() - s1 = QState() - machine.addState(s1) - machine.setInitialState(s1) - machine.start() - - QTimer.singleShot(100, self.app.quit) - self.app.exec_() - - configuration = machine.configuration() - - self.assert_(isinstance(configuration, set)) - self.assert_(s1 in configuration) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qstring_buffer_protocol_test.py b/tests/qtcore/qstring_buffer_protocol_test.py deleted file mode 100755 index f8475d093..000000000 --- a/tests/qtcore/qstring_buffer_protocol_test.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Tests QString implementation of Python buffer protocol''' - -import unittest - -from os.path import isdir -from PySide.QtCore import QString - -class QStringBufferProtocolTest(unittest.TestCase): - '''Tests QString implementation of Python buffer protocol''' - - def testQStringBufferProtocol(self): - #Tests QString implementation of Python buffer protocol using the os.path.isdir - #function which an unicode object or other object implementing the Python buffer protocol - isdir(QString('/tmp')) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qstring_operator_test.py b/tests/qtcore/qstring_operator_test.py deleted file mode 100644 index 6d7ae314d..000000000 --- a/tests/qtcore/qstring_operator_test.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QString operators''' - -import unittest - -from PySide.QtCore import QString, QByteArray - -class QStringOperatorEqual(unittest.TestCase): - '''TestCase for operator QString == QString''' - - def testDefault(self): - #QString() == QString() - obj1 = QString() - obj2 = QString() - self.assertEqual(obj1, obj2) - - def testSimple(self): - #QString(some_string) == QString(some_string) - string = 'egg snakes' - self.assertEqual(QString(string), QString(string)) - - def testUnicode(self): - #QString(unicode) == QString(unicode) - string = u'àâãá' - self.assertEqual(QString(string), QString(string)) - - def testPyString(self): - #QString(string) == string - string = 'my test string' - self.assertEqual(QString(string), string) - self.assertEqual(string, QString(string)) - - def testPyUnicodeString(self): - #QString(unicode) == unicode - string = u'àâãá' - self.assertEqual(QString(string), string) - self.assertEqual(string, unicode(QString(string))) - - def testQByteArray(self): - #QString(string) == QByteArray(string) - string = 'another test string' - self.assertEqual(QString(string), QByteArray(string)) - - -class QStringOperatorAtSetter(unittest.TestCase): - '''Test case for operator QString[] - __setitem__''' - - def testSetterString(self): - '''QString[x] = pythonstring''' - obj = QString('123456') - obj[1] = '0' - self.assertEqual(obj, QString('103456')) - - def testSetterStringLarge(self): - '''QString[x] = pythonstring (larget than 1 char)''' - obj = QString('123456') - obj[3] = 'abba' - self.assertEqual(obj, QString('123abba56')) - - def testSetterQString(self): - '''QString[x] = QString''' - obj = QString('123456') - obj[3] = QString('string') - self.assertEqual(obj, QString('123string56')) - - def testSetterQByteArray(self): - '''QString[x] = qbytearray''' - obj = QString('123456') - obj[3] = QByteArray('array') - self.assertEqual(obj, QString('123array56')) - - -class QStringOperatorAtSetterNegativeIndex(unittest.TestCase): - '''Test case for QString[] - __setitem__ - for negative index''' - - def testSetterNegativeIndex(self): - '''QString[x] = string - negative index''' - obj = QString('123456') - obj[-3] = 'array' - self.assertEqual(obj, QString('123array56')) - - -class QStringOperatorAtSetterLargeIndex(unittest.TestCase): - '''Test case for QString[] - __setitem__ - for 'overflown' index''' - - def testSetterLargeIndexEmpty(self): - '''QString[x] = somestring - Overflow index on empty string''' - # should pad with spaces if the index is larger - obj = QString('') - obj[2] = 'a' - self.assertEqual(obj, QString(' a')) - - def testSetterLargeIndexNormal(self): - '''QString[x] = somestring - Overflow index on normal string''' - # should pad with spaces if the index is larger - obj = QString('mystring') - obj[10] = 'normal' - self.assertEqual(obj, QString('mystring normal')) - - -class QStringOperatorAt(unittest.TestCase): - '''TestCase for operator QString[] - __getitem__''' - - def testInRange(self): - #QString[x] where x is a valid index - string = 'abcdefgh' - obj = QString(string) - - for i in range(len(string)): - self.assertEqual(obj[i], string[i]) - - def testInRangeReverse(self): - #QString[x] where x is a valid index (reverse order) - string = 'abcdefgh' - obj = QString(string) - - for i in range(len(string)-1, 0, -1): - self.assertEqual(obj[i], string[i]) - - - def testInRangeUnicode(self): - #QString[x] where x is a valid index (unicode) - string = u'àâãá' - obj = QString(string) - - for i in range(len(string)): - self.assertEqual(obj[i], string[i]) - - def testInRangeUnicodeReverse(self): - #QString[x] where x is a valid index (unicode) (reverse order) - string = u'àâãá' - obj = QString(string) - - for i in range(len(string)-1, 0, -1): - self.assertEqual(obj[i], string[i]) - - def testOutOfRange(self): - #QString[x] where x is out of index - string = '1234567' - obj = QString(string) - self.assertRaises(IndexError, lambda :obj[len(string)]) - - def testReturnQString(self): - #QString[x] must return a QString - string = QString('123456') - data = string[0] - self.assert_(isinstance(data, QString)) - -class QStringOperatorAdd(unittest.TestCase): - '''TestCase for operator QString[]''' - - def testOperatorAdd(self): - str1 = '123' - str2 = QString('456') - self.assertEquals('123456', str1 + str2) - self.assertEquals('456123', str2 + str1) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qstring_test.py b/tests/qtcore/qstring_test.py deleted file mode 100644 index 3f0fb4931..000000000 --- a/tests/qtcore/qstring_test.py +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QString''' - -import unittest -import ctypes -import sys - -from PySide.QtCore import QString, QByteArray, QObject - -class QStringToNumber(unittest.TestCase): - def testReturnValueTypes(self): - obj = QString('37') - val, ok = obj.toInt() - self.assertEqual(type(val), int) - self.assertEqual(type(ok), bool) - - def testToNumberInt(self): - obj = QString('37') - self.assertEqual((37, True), obj.toInt()) - - def testToNumberLong(self): - obj = QString('3700000') - self.assertEqual((3700000, True), obj.toInt()) - - def testToNumberShort(self): - obj = QString('33') - self.assertEqual((ctypes.c_short(33).value, True), obj.toShort()) - - def testToNumberShortNegative(self): - obj = QString('-4') - self.assertEqual((ctypes.c_short(-4).value, True), obj.toShort()) - - def testToNumberShortOverflow(self): - obj = QString('1000000') - self.assertEqual(False, obj.toShort()[1]) - - def testToNumberUInt(self): - obj = QString('33') - self.assertEqual((ctypes.c_uint(33).value, True), obj.toUInt()) - - def testToNumberUIntNegative(self): - obj = QString('-4') - self.assertEqual(False, obj.toUInt()[1]) - - def testToNumberUIntOverflow(self): - obj = QString('10000000000000') - self.assertEqual(False, obj.toUInt()[1]) - - def testToNumberULong(self): - obj = QString('33') - self.assertEqual((ctypes.c_ulong(33).value, True), obj.toULong()) - - def testToNumberULongNegative(self): - obj = QString('-4') - self.assertEqual(False, obj.toULong()[1]) - - def testToNumberUShort(self): - obj = QString('33') - self.assertEqual((ctypes.c_ushort(33).value, True), obj.toUShort()) - - def testToNumberUShortLarge(self): - obj = QString('128') - self.assertEqual((ctypes.c_ushort(128).value, True), obj.toUShort()) - - def testToNumberUShortOverflow(self): - obj = QString('205000') - self.assertEqual(False, obj.toUShort()[1]) - - def testToNumberUShortNegative(self): - obj = QString('-4') - self.assertEqual(False, obj.toUShort()[1]) - - def testToNumberIntUsingHex(self): - obj = QString('2A') - self.assertEquals((0, False), obj.toInt()) - self.assertEqual((int(str(obj), 16), True), obj.toInt(16)) - - def testToNumberIntUsingHex(self): - obj = QString('101010') - self.assertEqual((int(str(obj), 2), True), obj.toInt(2)) - - def testToNumberFloat(self): - obj = QString('37.109') - self.assertEqual(ctypes.c_float(37.109).value, - obj.toFloat()[0]) - - def testToNumberDouble(self): - obj = QString('37.109') - self.assertEqual(ctypes.c_double(37.109).value, - obj.toDouble()[0]) - - def testToULongLong(self): - obj = QString('37109') - self.assertEqual(ctypes.c_ulong(37109).value, - obj.toULongLong()[0]) - -class QStringConstructor(unittest.TestCase): - '''Test case for QString constructors''' - - def testQStringDefault(self): - #QString() - obj1 = QString() - obj2 = QString() - - self.assertEqual(obj1, obj2) - - def testNullQString(self): - s = QString(None) - self.assertTrue(s.isNull()) - - def testQStringFromPy(self): - #QString(const char*) - sample = 'a new string' - obj1 = QString(sample) - obj2 = QString(sample) - self.assertEqual(obj1, obj2) - - def testQStringFromUnicode(self): - sample = u'áâãà' - obj1 = QString(sample) - obj2 = QString(sample) - self.assertEqual(obj1, obj2) - self.assertEqual(obj1, sample) - self.assertEqual(obj2, sample) - - def testQStringFromByteArray(self): - # QByteArray(const char *) must be working - sample = QByteArray('foo') - obj1 = QString(sample) - obj2 = QString(sample) - self.assertEqual(obj1, obj2) - - def testQStringArg(self): - a = QString("%1 %2 %3").arg(1).arg("two").arg(3.14) - self.assertEquals("1 two 3.14", str(a)) - - def testQStringArgNegative(self): - a = QString("%1").arg(-20) - self.assertEquals("-20", str(a)) - - -class QStringComparison(unittest.TestCase): - '''Test case for comparison to python strings''' - - def testComparePyString(self): - #Compare QStrings and Python strings. - py = '' - qstr = QString() - self.assertEqual(py, qstr) - - py = 'The quick brown fox jumps over the lazy dog' - qstr = QString(py) - self.assertEqual(py, qstr) - -class QStringRange(unittest.TestCase): - '''Test case for ranges in python strings''' - - def testSimpleRange(self): - #Test open start and open end intervals - py = 'The quick brown fox jumps over the lazy dog' - qstr = QString(py) - self.assertEqual(py[5:], qstr[5:]) - self.assertEqual(py[:7], qstr[:7]) - -class QStringIndexOf(unittest.TestCase): - def testEmpty(self): - string = QString() - self.assertEqual(string.indexOf(QString("aaa")), -1) - self.assertEqual(string.indexOf(QString()), 0) - - def testString(self): - string = QString("the quick brown fox") - self.assertEqual(string.indexOf("quick", 0), 4) - - -class QStringImplicitConvertion(unittest.TestCase): - '''Implicit conversions for QString''' - - def testQByteArray(self): - '''QString implicitly conversion: QByteArray''' - obj = QObject() - obj.setObjectName(QByteArray('foobar')) - self.assertEqual(obj.objectName(), QString('foobar')) - -class QStringHash(unittest.TestCase): - def testHash(self): - self.assertEqual(hash("key"), hash(QString("key"))) - self.assertEqual(hash(u"aéióu"), hash(QString(u"aéióu"))) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qstringlist_test.py b/tests/qtcore/qstringlist_test.py deleted file mode 100644 index 031051684..000000000 --- a/tests/qtcore/qstringlist_test.py +++ /dev/null @@ -1,171 +0,0 @@ - -# -*- coding: utf-8 -*- - -'''Test cases for QStringList''' - -import unittest -from random import shuffle - -from PySide.QtCore import QStringList, QString - -from helper import random_string - -class UsesManyStrings(unittest.TestCase): - '''Helper class to setup a list of strings and QStrings''' - def setUp(self): - #Creates a list of strings and python strings - self.size = 10 - # List of Python strings - self.samples = [random_string() for x in range(self.size)] - # List of QStrings - self.strings = map(QString, self.samples) - - self.obj = QStringList(self.strings) - - -class TestConstructorBasic(unittest.TestCase): - '''Basic constructor test''' - - def testEmpty(self): - #QStringList() - default constructor - obj = QStringList() - self.assert_(isinstance(obj, QStringList)) - - def testQString(self): - #QStringList(QString) - qstr = QString('aaaa') - obj = QStringList(qstr) - self.assert_(isinstance(obj, QStringList)) - - def testPyString(self): - #QStringList(python_string) constructor - string = 'forty two' - obj = QStringList(string) - self.assert_(isinstance(obj, QStringList)) - - def testPyStringUnicode(self): - #QStringList(unicode python_string) constructor - string = 'Nação Zumbi' - obj = QStringList(string) - self.assert_(isinstance(obj, QStringList)) - - -class TestConstructorList(UsesManyStrings): - '''Test case for QStringList(List) constructor''' - - def testListQString(self): - #QStringList([QString]) constructor - obj = QStringList(self.strings) - self.assert_(isinstance(obj, QStringList)) - - def testListPyString(self): - #QStringList([python_string]) constructor - obj = QStringList(self.samples) - self.assert_(isinstance(obj, QStringList)) - - def testListMixed(self): - #QStringList([python_string and QString]) mixed constructor - mixed = self.samples + self.strings - shuffle(mixed) - obj = QStringList(mixed) - self.assert_(isinstance(obj, QStringList)) - - def testCopyList(self): - #QStringList(QStringList(list)) - copy constructor - obj = QStringList(self.strings) - obj2 = QStringList(obj) - self.assert_(isinstance(obj2, QStringList)) - self.assertEqual(obj, obj2) - - -class TestComparison(unittest.TestCase): - '''Test case for comparison of QStringLists''' - - def testEqual(self): - #QStringList == QStringList - string = QString('aaaabvbbcccedde') - obj1 = QStringList(string) - obj2 = QStringList(string) - self.assertEqual(obj1, obj2) - - -class TestIndexing(unittest.TestCase): - '''Test case for indexing through []''' - def testInvalidIndexEmpty(self): - #QStringList[x] for empty list - obj = QStringList() - self.assertRaises(IndexError, lambda:obj[0]) - - def testInvalidIndexQString(self): - #QStringList[1] raising IndexError for QStringList(QString) - obj = QStringList(QString('aaaaa')) - self.assertRaises(IndexError, lambda:obj[1]) - - def testValidIndexQString(self): - #QStringList[0] not raising IndexError for QStringList(QString) - string = QString('abcdefg') - obj = QStringList(string) - self.assertEqual(obj[0], string) - - def testNegativeIndexing(self): - #QStringList[-1] not raising IndexError for QStringList(QString) - string = QString('abcdefg') - obj = QStringList(string) - self.assertEqual(obj[-1], string) - - -class TestListIndexing(UsesManyStrings): - '''Test case for indexing QStringList longer than 1 string''' - - def testValid(self): - #QStringList[] for valid indexes - for i in range(self.size): - self.assertEqual(self.strings[i], self.obj[i]) - - def testNegativeValid(self): - #QStringList[] for valid indexes - for i in range(-1, -self.size, -1): - self.assertEqual(self.strings[i], self.obj[i]) - - def testInvalid(self): - #QStringList[] for invalid negative indexes - self.assertRaises(IndexError, lambda : self.obj[self.size]) - self.assertRaises(IndexError, lambda : self.obj[-(self.size+1)]) - - -class TestSlicing(UsesManyStrings): - '''Test case for slicing a QStringList''' - - def testSlicing(self): - #QStringList slicing - for i in range(self.size): - self.assertEqual(self.obj[i:], self.strings[i:]) - self.assertEqual(self.obj[:i], self.strings[:i]) - for j in range(i): - self.assertEqual(self.obj[j:i], self.strings[j:i]) - - for i in range(-1, -self.size, -1): - self.assertEqual(self.obj[:i], self.strings[:i]) - - -class TestShiftOperator(UsesManyStrings): - '''Test case for QStringList lshift operator''' - - def testShiftOperator(self): - #QStringList lshift - a = QStringList() - a << "a" << "b" << "c"; - self.assertEquals(3, a.count()) - b = ["1", "2", "3"] - c = ["4", "5", "6"] - a << b << c - self.assertEquals(9, a.count()) - - def testShiftOperator(self): - #QStringList lshift - a = QStringList() - b = ["1", 2, "3"] - self.assertRaises(TypeError, a.__lshift__, b) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qtext_codec_test.py b/tests/qtcore/qtext_codec_test.py deleted file mode 100644 index 2bd7f8139..000000000 --- a/tests/qtcore/qtext_codec_test.py +++ /dev/null @@ -1,20 +0,0 @@ -import gc -import unittest - -from PySide.QtCore import QTextCodec - -class TestCodecGetters(unittest.TestCase): - - def testCodecsNames(self): - for codec_name in QTextCodec.availableCodecs(): - codec = QTextCodec.codecForName(codec_name) - self.assert_(type(codec), QTextCodec) - - def testCodecsMibs(self): - for codec_num in QTextCodec.availableMibs(): - codec = QTextCodec.codecForMib(codec_num) - self.assert_(type(codec), QTextCodec) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qtextstream_test.py b/tests/qtcore/qtextstream_test.py deleted file mode 100644 index 13dc6516c..000000000 --- a/tests/qtcore/qtextstream_test.py +++ /dev/null @@ -1,95 +0,0 @@ - -'''Unit tests for QTextStream''' - -import unittest - -from PySide.QtCore import QTextStream, QIODevice, QString, QByteArray -from PySide.QtCore import QTextCodec, QFile - -class QTextStreamShiftTest(unittest.TestCase): - - def setUp(self): - self.ba = QByteArray() - self.read = QTextStream(self.ba, QIODevice.ReadOnly) - self.write = QTextStream(self.ba, QIODevice.WriteOnly) - - def testNumber(self): - '''QTextStream << number''' - - self.write << QString('4') - self.write.flush() - res = self.read.readLine() - self.assert_(isinstance(res, QString)) - self.assertEqual(res, QString('4')) - - def testString(self): - self.write << QString('Test_it!') - self.write.flush() - res = QString() - self.read >> res - self.assertEqual(res, QString('Test_it!')) - -class QTextStreamGetSet(unittest.TestCase): - - def setUp(self): - self.obj = QTextStream() - - - def testCodec(self): - '''QTextStream set/get Codec''' - - codec = QTextCodec.codecForName('ISO8859-1') - self.obj.setCodec(codec) - self.assertEqual(codec, self.obj.codec()) - - def testDevice(self): - '''QTextStream get/set Device''' - device = QFile() - self.obj.setDevice(device) - self.assertEqual(device, self.obj.device()) - self.obj.setDevice(None) - self.assertEqual(None, self.obj.device()) - -class QTextStreamInitialization(unittest.TestCase): - - def testConstruction(self): - '''QTextStream construction''' - obj = QTextStream() - - self.assertEqual(obj.codec(), QTextCodec.codecForLocale()) - self.assertEqual(obj.device(), None) - self.assertEqual(obj.string(), None) - - self.assert_(obj.atEnd()) - self.assertEqual(obj.readAll(), '') - -class QTextStreamReadLinesFromDevice(unittest.TestCase): - - def _check_data(self, data_set): - - for data, lines in data_set: - stream = QTextStream(data) - - res = [] - while not stream.atEnd(): - res.append(stream.readLine()) - - self.assertEqual(res, lines) - - def testLatin1(self): - '''QTextStream readLine for simple Latin1 strings''' - - data = [] - - data.append((QByteArray(), [])) - data.append((QByteArray('\n'), [''])) - data.append((QByteArray('\r\n'), [''])) - data.append((QByteArray('ole'), ['ole'])) - data.append((QByteArray('ole\n'), ['ole'])) - data.append((QByteArray('ole\r\n'), ['ole'])) - data.append((QByteArray('ole\r\ndole\r\ndoffen'), ['ole', 'dole', 'doffen'])) - - self._check_data(data) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qthread_prod_cons_test.py b/tests/qtcore/qthread_prod_cons_test.py deleted file mode 100644 index fc634dd88..000000000 --- a/tests/qtcore/qthread_prod_cons_test.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/python -'''Producer-Consumer test/example with QThread''' - -import unittest -from random import random -import logging - -logging.basicConfig(level=logging.WARNING) - -from PySide.QtCore import QThread, QCoreApplication, QObject, SIGNAL - -class Bucket(QObject): - '''Dummy class to hold the produced values''' - def __init__(self, max_size=10, *args): - #Constructor which receives the max number of produced items - super(Bucket, self).__init__(*args) - self.data = [] - self.max_size = 10 - - def pop(self): - #Retrieves an item - return self.data.pop(0) - - def push(self, data): - #Pushes an item - self.data.append(data) - -class Producer(QThread): - '''Producer thread''' - - def __init__(self, bucket, *args): - #Constructor. Receives the bucket - super(Producer, self).__init__(*args) - self.runs = 0 - self.bucket = bucket - self.production_list = [] - - def run(self): - #Produces at most bucket.max_size items - while self.runs < self.bucket.max_size: - value = int(random()*10) % 10 - self.bucket.push(value) - self.production_list.append(value) - logging.debug('PRODUCER - pushed %d' % value) - self.runs += 1 - self.msleep(5) - - - -class Consumer(QThread): - '''Consumer thread''' - def __init__(self, bucket, *args): - #Constructor. Receives the bucket - super(Consumer, self).__init__(*args) - self.runs = 0 - self.bucket = bucket - self.consumption_list = [] - - def run(self): - #Consumes at most bucket.max_size items - while self.runs < self.bucket.max_size: - try: - value = self.bucket.pop() - self.consumption_list.append(value) - logging.debug('CONSUMER - got %d' % value) - self.runs += 1 - except IndexError: - logging.debug('CONSUMER - empty bucket') - self.msleep(5) - -class ProducerConsumer(unittest.TestCase): - '''Basic test case for producer-consumer QThread''' - - def setUp(self): - #Create fixtures - self.app = QCoreApplication([]) - - def tearDown(self): - #Destroy fixtures - del self.app - - def finishCb(self): - #Quits the application - self.app.exit(0) - - def testProdCon(self): - #QThread producer-consumer example - bucket = Bucket() - prod = Producer(bucket) - cons = Consumer(bucket) - - prod.start() - cons.start() - - QObject.connect(prod, SIGNAL('finished()'), self.finishCb) - QObject.connect(cons, SIGNAL('finished()'), self.finishCb) - - self.app.exec_() - - prod.wait() - cons.wait() - - self.assertEqual(prod.production_list, cons.consumption_list) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qthread_signal_test.py b/tests/qtcore/qthread_signal_test.py deleted file mode 100755 index edd7d77f4..000000000 --- a/tests/qtcore/qthread_signal_test.py +++ /dev/null @@ -1,64 +0,0 @@ - -'''Test cases for connecting signals between threads''' - -import unittest - -from PySide.QtCore import QThread, QObject, SIGNAL, QCoreApplication - -thread_run = False - -class Source(QObject): - def __init__(self, *args): - QObject.__init__(self, *args) - - def emit_sig(self): - self.emit(SIGNAL('source()')) - -class Target(QObject): - def __init__(self, *args): - QObject.__init__(self, *args) - self.called = False - - def myslot(self): - self.called = True - -class ThreadJustConnects(QThread): - def __init__(self, source, *args): - QThread.__init__(self, *args) - self.source = source - self.target = Target() - - def run(self): - global thread_run - thread_run = True - QObject.connect(self.source, SIGNAL('source()'), self.target.myslot) - - while not self.target.called: - pass - - - -class BasicConnection(unittest.TestCase): - - def testEmitOutsideThread(self): - global thread_run - - app = QCoreApplication([]) - source = Source() - thread = ThreadJustConnects(source) - - QObject.connect(thread, SIGNAL('finished()'), lambda: app.exit(0)) - thread.start() - - while not thread_run: - pass - - source.emit_sig() - - app.exec_() - thread.wait() - - self.assert_(thread.target.called) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qthread_test.py b/tests/qtcore/qthread_test.py deleted file mode 100644 index 410afb908..000000000 --- a/tests/qtcore/qthread_test.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/python -'''Test cases for QThread''' - -import unittest -from PySide.QtCore import QThread, QCoreApplication, QObject, SIGNAL, QMutex, QTimer -from PySide.QtCore import QEventLoop - -from helper import UsesQCoreApplication - -mutex = QMutex() - -class Dummy(QThread): - '''Dummy thread''' - def __init__(self, *args): - super(Dummy, self).__init__(*args) - self.called = False - - def run(self): - #Start-quit sequence - mutex.lock() - self.called = True - mutex.unlock() - -class QThreadSimpleCase(UsesQCoreApplication): - - def setUp(self): - UsesQCoreApplication.setUp(self) - self.called = False - - def tearDown(self): - UsesQCoreApplication.tearDown(self) - - def testThread(self): - #Basic QThread test - obj = Dummy() - obj.start() - obj.wait() - - self.assert_(obj.called) - - def cb(self, *args): - self.called = True - #self.exit_app_cb() - - def abort_application(self): - self._thread.terminate() - self.app.quit() - - def testSignalFinished(self): - #QThread.finished() (signal) - obj = Dummy() - QObject.connect(obj, SIGNAL('finished()'), self.cb) - mutex.lock() - obj.start() - mutex.unlock() - - self._thread = obj - QTimer.singleShot(1000, self.abort_application) - self.app.exec_() - - self.assert_(self.called) - - def testSignalStarted(self): - #QThread.started() (signal) - obj = Dummy() - QObject.connect(obj, SIGNAL('started()'), self.cb) - obj.start() - - self._thread = obj - QTimer.singleShot(1000, self.abort_application) - self.app.exec_() - - self.assert_(self.called) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qtimer_singleshot_test.py b/tests/qtcore/qtimer_singleshot_test.py deleted file mode 100644 index 96107ecce..000000000 --- a/tests/qtcore/qtimer_singleshot_test.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -'''Test cases for QTimer.singleShot''' - -import unittest - -from PySide.QtCore import QObject, QTimer, QCoreApplication, SIGNAL -from helper import UsesQCoreApplication - -class WatchDog(QObject): - '''Exits the QCoreApplication main loop after sometime.''' - - def __init__(self, watched): - QObject.__init__(self) - self.times_called = 0 - self.watched = watched - - def timerEvent(self, evt): - self.times_called += 1 - if self.times_called == 20: - self.watched.exit_app_cb() - -class TestSingleShot(UsesQCoreApplication): - '''Test case for QTimer.singleShot''' - - def setUp(self): - #Acquire resources - UsesQCoreApplication.setUp(self) - self.watchdog = WatchDog(self) - self.called = False - - def tearDown(self): - #Release resources - del self.watchdog - del self.called - UsesQCoreApplication.tearDown(self) - - def callback(self): - self.called = True - self.app.quit() - - def testSingleShot(self): - timer = QTimer.singleShot(100, self.callback) - self.app.exec_() - self.assert_(self.called) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qtimer_timeout_test.py b/tests/qtcore/qtimer_timeout_test.py deleted file mode 100644 index 8dfe39529..000000000 --- a/tests/qtcore/qtimer_timeout_test.py +++ /dev/null @@ -1,57 +0,0 @@ - -'''Test case for timeout() signals from QTimer object.''' - -import unittest -import os -from tempfile import mkstemp -from PySide.QtCore import QObject, QTimer, SIGNAL -from helper import UsesQCoreApplication - -class WatchDog(QObject): - '''Exits the QCoreApplication main loop after sometime.''' - - def __init__(self, watched): - QObject.__init__(self) - self.times_called = 0 - self.watched = watched - - def timerEvent(self, evt): - self.times_called += 1 - if self.times_called == 20: - self.watched.exit_app_cb() - - -class TestTimeoutSignal(UsesQCoreApplication): - '''Test case to check if the signals are really being caught''' - - def setUp(self): - #Acquire resources - UsesQCoreApplication.setUp(self) - self.watchdog = WatchDog(self) - self.timer = QTimer() - self.called = False - - def tearDown(self): - #Release resources - del self.watchdog - del self.timer - del self.called - UsesQCoreApplication.tearDown(self) - - def callback(self, *args): - #Default callback - self.called = True - - def testTimeoutSignal(self): - #Test the QTimer timeout() signal - QObject.connect(self.timer, SIGNAL('timeout()'), self.callback) - self.timer.start(4) - self.watchdog.startTimer(10) - - self.app.exec_() - - self.assert_(self.called) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/qtnamespace_test.py b/tests/qtcore/qtnamespace_test.py deleted file mode 100644 index 3343a276b..000000000 --- a/tests/qtcore/qtnamespace_test.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/python -'''Test suite for QtCore.Qt namespace''' - -import unittest - -from PySide.QtCore import Qt - -class QtNamespace(unittest.TestCase): - '''Test case for accessing attributes from Qt namespace''' - - def testBasic(self): - #Access to Qt namespace - getattr(Qt, 'Horizontal') - getattr(Qt, 'WindowMaximizeButtonHint') - self.assert_(True) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/quoteEnUS.txt b/tests/qtcore/quoteEnUS.txt deleted file mode 100644 index 909b4fa17..000000000 --- a/tests/qtcore/quoteEnUS.txt +++ /dev/null @@ -1 +0,0 @@ -Fine! Dishonor! Dishonor on you, dishonor on ya cow! diff --git a/tests/qtcore/qurl_test.py b/tests/qtcore/qurl_test.py deleted file mode 100644 index 14243a11a..000000000 --- a/tests/qtcore/qurl_test.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python -'''Test suite for QtCore.QUrl''' - -import unittest - -from PySide.QtCore import QUrl - -class QUrlBasicConstructor(unittest.TestCase): - '''Tests the basic constructors''' - - def testBasic(self): - #Default constructor for QUrl - url = QUrl() - self.assertEqual(url.toString(), "") - - def testSetAttributes(self): - #Construct QUrl by set* methods - url = QUrl() - - url.setScheme('ftp') - self.assertEqual(url.toString(), 'ftp:') - - url.setHost('www.google.com') - self.assertEqual(url.toString(), 'ftp://www.google.com') - - url.setPort(8080) - self.assertEqual(url.toString(), 'ftp://www.google.com:8080') - - url.setPath('mail/view') - self.assertEqual(url.toString(), - 'ftp://www.google.com:8080/mail/view') - - url.setUserName('john') - self.assertEqual(url.toString(), - 'ftp://john@www.google.com:8080/mail/view') - - url.setPassword('abc123') - self.assertEqual(url.toString(), - 'ftp://john:abc123@www.google.com:8080/mail/view') - -class QueryItemsTest(unittest.TestCase): - '''Test query item management''' - - def testQueryItems(self): - #QUrl.queryItems - url = QUrl('http://www.google.com/search?q=python&hl=en') - valid_data = [(('q'), ('python')), (('hl'), ('en'))] - - self.assertEqual(sorted(url.queryItems()), sorted(valid_data)) - - def testEncodedQueryItems(self): - #QUrl.encodedQueryItems - url = QUrl('http://www.google.com/search?q=python&hl=en') - valid_data = [(('q'), ('python')), (('hl'), ('en'))] - - self.assertEqual(sorted(url.encodedQueryItems()), sorted(valid_data)) - - def testSetQueryItems(self): - #QUrl.setQueryItems - urla = QUrl('http://www.google.com/search?q=python&hl=en') - urlb = QUrl('http://www.google.com/search') - - urlb.setQueryItems(urla.queryItems()) - - self.assertEqual(urla, urlb) - - def testAddQueryItem(self): - #QUrl.addQueryItem - url = QUrl() - valid_data = [('hl', 'en'), ('user', 'konqui')] - - url.addQueryItem(*valid_data[0]) - self.assertEqual(url.queryItems()[0], valid_data[0]) - - url.addQueryItem(*valid_data[1]) - self.assertEqual(sorted(url.queryItems()), sorted(valid_data)) - - def testAllEncodedQueryItemsValues(self): - #QUrl.allEncodedQueryItemValues - url = QUrl() - key = 'key' - valid_data = ['data', 'valid', 'test'] - - for i, data in enumerate(valid_data): - url.addQueryItem(key, data) - self.assertEqual(url.allEncodedQueryItemValues(key), - list(valid_data[:i+1])) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qvariant_pyobject_test.py b/tests/qtcore/qvariant_pyobject_test.py deleted file mode 100644 index 82da5556f..000000000 --- a/tests/qtcore/qvariant_pyobject_test.py +++ /dev/null @@ -1,71 +0,0 @@ - -'''QVariant handling of PyObjects, including pure-python or derived from Qt''' - -import unittest - -from PySide.QtCore import QSize, QVariant, QString - - -class Dummy(object): - '''Pure python sample class''' - pass - - -class MySize(QSize): - '''Extended class''' - pass - - -class QVariantPurePython(unittest.TestCase): - '''QVariant + pure python classes''' - - def testTypeNamePythonClasses(self): - '''QVariant of pure python classes''' - d = Dummy() - obj = QVariant(d) - # inherited type name from other binding - self.assertEqual('PyQt_PyObject', obj.typeName()) - - -class QVariantInheritedPython(unittest.TestCase): - '''QVariant + classes inherited from C++''' - - # This works only on PyQt4 4.5.x, not on PyQt4 4.4.x or PySide - def testSubClassConvertion(self): - '''QVariant(QSize subclass) type is UserType and returns same object''' - mysize = MySize(0, 0) - variant = QVariant(mysize) - - self.assertEqual(variant.type(), QVariant.UserType) - self.assertTrue(variant.toPyObject() is mysize) - - -class QVariantToPyObject(unittest.TestCase): - '''QVariant.toPyObject tests''' - - def testQVariantPyList(self): - '''QVariant(QVariantList).toPyObject() equals original list''' - obj = QVariant([1, 'two', 3]) - self.assertEqual(obj.toPyObject(), [1, 'two', 3]) - - def testPyObject(self): - '''QVariant(pure PyObject).toPyObject should return the same object''' - d = Dummy() - obj = QVariant(d) - self.assert_(d is obj.toPyObject()) - - def testNoneToPyObject(self): - '''QVariant().toPyObject() should return None''' - obj = QVariant() - self.assertEqual(None, obj.toPyObject()) - - def testQStringToPyObject(self): - '''QVariant(python string).toPyObject() return an equal QString''' - d = 'abc' - obj = QVariant('abc') - self.assert_(isinstance(obj.toPyObject(), QString)) - self.assertEqual(d, obj.toPyObject()) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/qvariant_test.py b/tests/qtcore/qvariant_test.py deleted file mode 100644 index 5c23b4049..000000000 --- a/tests/qtcore/qvariant_test.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QVariant''' - -import unittest -import sys - -from PySide.QtCore import QSize, QVariant, QByteArray, QStringList, QString - - -class QVariantToNumber(unittest.TestCase): - '''QVariant of number types''' - - def testToNumberInt(self): - '''QVariant(int).toInt()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toInt()) - - def testToNumberLongLong(self): - '''QVariant(int).toLongLong()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toLongLong()) - - def testToNumberUInt(self): - '''QVariant(int).toUInt()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toUInt()) - - def testToNumberUIntNegative(self): - '''QVariant(negative int).toUInt()''' - obj = QVariant('-37') - self.assert_(not obj.toUInt()[1]) - - def testToNumberULongLong(self): - '''QVariant(int).toULongLong()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toULongLong()) - - def testToNumberULongLongNegative(self): - '''QVariant(negative int).toULongLong()''' - obj = QVariant('-37') - self.assert_(not obj.toULongLong()[1]) - - def testToNumberFloat(self): - '''QVariant(double).toFloat()''' - obj = QVariant('37.109') - self.assertEqual((37.109, True), obj.toDouble()) - - -class QVariantTypeName(unittest.TestCase): - '''QVariant.typeName()''' - - def testTypeNameQString(self): - '''QVariant(QString).typeName()''' - obj = QVariant(QString('aaaa')) - self.assertEqual('QString', obj.typeName()) - - def testTypeNameString(self): - '''QVariant(PyString).typeName()''' - obj = QVariant('aaaa') - self.assertEqual('QString', obj.typeName()) - - def testTypeNameInt(self): - '''QVariant(int).typeName()''' - obj = QVariant(34) - self.assertEqual('int', obj.typeName()) - - def testTypeNameDouble(self): - '''QVariant(double).typeName()''' - obj = QVariant(3.14) - self.assertEqual('double', obj.typeName()) - - def testTypeNameBool(self): - '''QVariant(bool).typeName()''' - obj = QVariant(True) - self.assertEqual('bool', obj.typeName()) - - def testTypeNameQByteArray(self): - '''QVariant(QByteArray).typeName()''' - obj = QVariant(QByteArray('aaaa')) - self.assertEqual('QByteArray', obj.typeName()) - - def testTypeNameNone(self): - '''QVariant().typeName()''' - obj = QVariant() - self.assertEqual(None, obj.typeName()) - - def testTypeNameQVariantList(self): - '''QVariant(QVariantList).typeName()''' - obj = QVariant([1, 2, 3, 4]) - self.assertEqual('QVariantList', obj.typeName()) - - obj = QVariant([1.0, 2.2, 3.3, 4.2]) - self.assertEqual('QVariantList', obj.typeName()) - - obj = QVariant(['aaa', 'bbb', 'ccc', 'dddd']) - self.assertEqual('QVariantList', obj.typeName()) - - obj = QVariant([QString('aaa'), QString('bbb'), - QString('ccc'), QString('dddd')]) - self.assertEqual('QVariantList', obj.typeName()) - - def testTypeNameQStringList(self): - '''QVariant(QStringList).typeName()''' - obj = QVariant(QStringList()) - self.assertEqual('QStringList', obj.typeName()) - obj = QVariant(QStringList(['aaa', 'bbb', 'ccc'])) - self.assertEqual('QStringList', obj.typeName()) - - -class QVariantConstructor(unittest.TestCase): - '''More qvariant constructions''' - - def testCopyConstructor(self): - '''QVariant copy constructor''' - obj = QVariant(1) - cpy = QVariant(obj) - - self.assertEqual(obj.type(), cpy.type()) - - def testQStringConstructor(self): - '''QVariant(PyString).type == QVariant.string''' - obj = QVariant("PySide") - self.assertEqual(obj.type(), QVariant.String) - - def testQSizeConstructor(self): - '''QVariant(QSize).type == QVariant.Size''' - mysize = QSize(0, 0) - variant = QVariant(mysize) - - self.assertEqual(variant.type(), QVariant.Size) - self.assertEqual(variant.toSize(), mysize) - - def testToList(self): - v = QVariant((1,2,3)) - self.assertEqual(v.toList(), (1, 2, 3)) - v = QVariant([0,1,2]) - self.assertEqual(v.toList(), [0, 1, 2]) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/resources.qrc b/tests/qtcore/resources.qrc deleted file mode 100644 index cea17b440..000000000 --- a/tests/qtcore/resources.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - quoteEnUS.txt - - - diff --git a/tests/qtcore/resources_mc.py b/tests/qtcore/resources_mc.py deleted file mode 100644 index 132c8db12..000000000 --- a/tests/qtcore/resources_mc.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- - -# Resource object code -# -# Created: Thu Mar 26 11:08:45 2009 -# by: The Resource Compiler for PyQt (Qt v4.5.0) -# -# WARNING! All changes made in this file will be lost! - -from PySide import QtCore - -qt_resource_data = "\ -\x00\x00\x00\x35\ -\x46\ -\x69\x6e\x65\x21\x20\x44\x69\x73\x68\x6f\x6e\x6f\x72\x21\x20\x44\ -\x69\x73\x68\x6f\x6e\x6f\x72\x20\x6f\x6e\x20\x79\x6f\x75\x2c\x20\ -\x64\x69\x73\x68\x6f\x6e\x6f\x72\x20\x6f\x6e\x20\x79\x61\x20\x63\ -\x6f\x77\x21\x0a\ -" - -qt_resource_name = "\ -\x00\x09\ -\x06\xa8\xaa\x74\ -\x00\x71\ -\x00\x75\x00\x6f\x00\x74\x00\x65\x00\x2e\x00\x74\x00\x78\x00\x74\ -" - -qt_resource_struct = "\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ -\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -" - -def qInitResources(): - QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) - -def qCleanupResources(): - QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) - -qInitResources() diff --git a/tests/qtcore/static_method_test.py b/tests/qtcore/static_method_test.py deleted file mode 100755 index 1f9de78f7..000000000 --- a/tests/qtcore/static_method_test.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -'''Test cases for overloads involving static and non-static versions of a method.''' - -import os -import unittest - -from PySide.QtCore import QFile - -class StaticNonStaticMethodsTest(unittest.TestCase): - '''Test cases for overloads involving static and non-static versions of a method.''' - - def setUp(self): - filename = 'somefile%d.txt' % os.getpid() - self.existing_filename = os.path.join(os.path.curdir, filename) - self.delete_file = False - if not os.path.exists(self.existing_filename): - f = open(self.existing_filename, 'w') - for line in range(10): - f.write('sbrubbles\n') - f.close() - self.delete_file = True - - self.non_existing_filename = os.path.join(os.path.curdir, 'inexistingfile.txt') - i = 0 - while os.path.exists(self.non_existing_filename): - i += 1 - filename = 'inexistingfile-%d.txt' % i - self.non_existing_filename = os.path.join(os.path.curdir, filename) - - def tearDown(self): - if self.delete_file: - os.remove(self.existing_filename) - - def testCallingStaticMethodWithClass(self): - '''Call static method using class.''' - self.assert_(QFile.exists(self.existing_filename)) - self.assertFalse(QFile.exists(self.non_existing_filename)) - - def testCallingStaticMethodWithInstance(self): - '''Call static method using instance of class.''' - f = QFile(self.non_existing_filename) - self.assert_(f.exists(self.existing_filename)) - self.assertFalse(f.exists(self.non_existing_filename)) - - def testCallingInstanceMethod(self): - '''Call instance method.''' - f1 = QFile(self.non_existing_filename) - self.assertFalse(f1.exists()) - f2 = QFile(self.existing_filename) - self.assert_(f2.exists()) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/static_protected_methods_test.py b/tests/qtcore/static_protected_methods_test.py deleted file mode 100644 index 9d920a438..000000000 --- a/tests/qtcore/static_protected_methods_test.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python -'''Unit tests for static protected methods''' - -import unittest, time - -from PySide.QtCore import QThread - -class Test (QThread): - def run(self): - start = time.time() - self.sleep(1) - self.time_elapsed = time.time() - start - -class QStaticProtectedCall(unittest.TestCase): - '''Test case for static protected method call''' - - def setUp(self): - pass - - def tearDown(self): - pass - - def testPathSeparator(self): - thread = Test() - thread.start() - thread.wait() - self.assertTrue(thread.time_elapsed <= 1.1) # tolarance of 100ms - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/thread_signals.py b/tests/qtcore/thread_signals.py deleted file mode 100644 index e2b66730b..000000000 --- a/tests/qtcore/thread_signals.py +++ /dev/null @@ -1,39 +0,0 @@ - -''' Test case for QObject.signalsBlocked() and blockSignal()''' - -import unittest -import os -from tempfile import mkstemp - -from PySide.QtCore import QObject, SIGNAL, QFile, QThread, QTimer -from helper import UsesQCoreApplication - -class MyThread(QThread): - - def run(self): - self.emit(SIGNAL("test(const QString&)"), - "INdT - PySide"); - -class TestThreadSignal(UsesQCoreApplication): - - __called__ = True - def _callback(self, msg): - self.assertEqual(msg, "INdT - PySide") - self.__called__ = True - self._quit() - - def _quit(self): - self.app.quit() - - def testThread(self): - t = MyThread() - QObject.connect(t, SIGNAL("test(const QString&)"), - self._callback); - - t.start() - QTimer.singleShot(100, self._quit) - self.app.exec_() - self.assert_(self.__called__); - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtcore/translation_test.py b/tests/qtcore/translation_test.py deleted file mode 100644 index 870c8c50f..000000000 --- a/tests/qtcore/translation_test.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -'''Unit tests to test QTranslator and translation in general.''' - -import os -import unittest -from PySide.QtCore import QObject, QTranslator, QCoreApplication, QString - -from helper import UsesQCoreApplication - -class TranslationTest(UsesQCoreApplication): - '''Test case for Qt translation facilities.''' - - def setUp(self): - super(TranslationTest, self).setUp() - self.trdir = os.path.join(os.path.dirname(__file__), 'translations') - # os.system is probably not the best way to do it - os.system('lrelease %s/*.ts > /dev/null' % self.trdir) - - def tearDown(self): - os.system('rm %s/*.qm > /dev/null' % self.trdir) - super(TranslationTest, self).tearDown() - - def testLatin(self): - #Set string value to Latin - translator = QTranslator() - translator.load(os.path.join(self.trdir, 'trans_latin.qm')) - self.app.installTranslator(translator) - - obj = QObject() - obj.setObjectName(obj.tr('Hello World!')) - self.assertEqual(obj.objectName(), u'Orbis, te saluto!') - - def testRussian(self): - #Set string value to Russian - translator = QTranslator() - translator.load(os.path.join(self.trdir, 'trans_russian.qm')) - self.app.installTranslator(translator) - - obj = QObject() - obj.setObjectName(obj.tr('Hello World!')) - self.assertEqual(obj.objectName(), u'привет мир!') - - def testUtf8(self): - translator = QTranslator() - translator.load(os.path.join(self.trdir, 'trans_russian.qm')) - self.app.installTranslator(translator) - - obj = QObject() - obj.setObjectName(obj.trUtf8('Hello World!')) - self.assertEqual(obj.objectName(), u'привет мир!') - - def testTranslateWithNoneDisambiguation(self): - value = 'String here' - obj = QCoreApplication.translate('context', value, None, QCoreApplication.UnicodeUTF8) - self.assert_(isinstance(obj, QString)) - self.assertEqual(obj, value) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/translations/trans_latin.ts b/tests/qtcore/translations/trans_latin.ts deleted file mode 100644 index b9fcf41be..000000000 --- a/tests/qtcore/translations/trans_latin.ts +++ /dev/null @@ -1,11 +0,0 @@ - - - - - QObject - - Hello World! - Orbis, te saluto! - - - diff --git a/tests/qtcore/translations/trans_russian.ts b/tests/qtcore/translations/trans_russian.ts deleted file mode 100644 index d1ba49bd2..000000000 --- a/tests/qtcore/translations/trans_russian.ts +++ /dev/null @@ -1,11 +0,0 @@ - - - - - QObject - - Hello World! - привет мир! - - - diff --git a/tests/qtcore/unaryoperator_test.py b/tests/qtcore/unaryoperator_test.py deleted file mode 100755 index 94db1feec..000000000 --- a/tests/qtcore/unaryoperator_test.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python -'''Tests the presence of unary operator __neg__ on the QPoint class''' - -import unittest - -from PySide.QtCore import QPoint - -class NegUnaryOperatorTest(unittest.TestCase): - '''Tests the presence of unary operator __neg__ on the QPoint class''' - - def setUp(self): - #Acquire resources - self.x, self.y = 10, 20 - self.neg_x, self.neg_y = -self.x, -self.y - self.qpoint = QPoint(self.x, self.y) - - def tearDown(self): - #Release resources - del self.qpoint - del self.x - del self.y - del self.neg_x - del self.neg_y - - def testNegUnaryOperator(self): - #Test __neg__ unary operator on QPoint class - __neg__method_exists = True - try: - neg_qpoint = -self.qpoint - except: - __neg__method_exists = False - - self.assertTrue(__neg__method_exists) - self.assertEqual(self.qpoint, -neg_qpoint) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtcore/unicode_test.py b/tests/qtcore/unicode_test.py deleted file mode 100644 index f0bb883ed..000000000 --- a/tests/qtcore/unicode_test.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -'''Unit tests for QString conversion to/from Python Unicode''' - -import unittest - -from PySide.QtCore import QObject - -class UnicodeConversion(unittest.TestCase): - '''Test case for QString to/from Python Unicode conversion''' - - def setUp(self): - pass - - def tearDown(self): - pass - - def testSetRegularStringRetrieveUnicode(self): - #Set regular Python string retrieve unicode - obj = QObject() - obj.setObjectName('test') - self.assertEqual(obj.objectName(), u'test') - - def testSetUnicodeRetrieveUnicode(self): - #Set Python unicode string and retrieve unicode - obj = QObject() - obj.setObjectName(u'ümlaut') - self.assertEqual(obj.objectName(), u'ümlaut') - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtdeclarative/network.qml b/tests/qtdeclarative/network.qml deleted file mode 100644 index 4b849e071..000000000 --- a/tests/qtdeclarative/network.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -Image { - width: 100 - height: 100 - source: "http://qt.nokia.com/logo.png" -} diff --git a/tests/qtdeclarative/qdeclarativenetwork_test.py b/tests/qtdeclarative/qdeclarativenetwork_test.py deleted file mode 100644 index a03a484a0..000000000 --- a/tests/qtdeclarative/qdeclarativenetwork_test.py +++ /dev/null @@ -1,35 +0,0 @@ -'''Test cases for QDeclarativeNetwork''' - -import unittest - -from PySide.QtCore import QUrl -from PySide.QtDeclarative import QDeclarativeView, QDeclarativeNetworkAccessManagerFactory -from PySide.QtNetwork import QNetworkAccessManager - -from helper import adjust_filename, TimedQApplication - -class MyNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory): - def create(self, parent): - nam = QNetworkAccessManager(parent) - return nam - -class TestQDeclarativeNetworkFactory(TimedQApplication): - - def setUp(self): - TimedQApplication.setUp(self, timeout=1000) - - def testQDeclarativeNetworkFactory(self): - view = QDeclarativeView() - - url = QUrl.fromLocalFile(adjust_filename('network.qml', __file__)) - - view.engine().setNetworkAccessManagerFactory(MyNetworkAccessManagerFactory()) - view.setSource(url) - view.show() - - self.assertEqual(view.status(), QDeclarativeView.Ready) - - self.app.exec_() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtdeclarative/qdeclarativeview_test.py b/tests/qtdeclarative/qdeclarativeview_test.py deleted file mode 100644 index 8101c5f01..000000000 --- a/tests/qtdeclarative/qdeclarativeview_test.py +++ /dev/null @@ -1,31 +0,0 @@ -'''Test cases for QDeclarativeView''' - -import unittest - -from PySide.QtCore import QUrl, QStringList, QVariant -from PySide.QtGui import QPushButton -from PySide.QtDeclarative import QDeclarativeView - -from helper import adjust_filename, TimedQApplication - - -class TestQDeclarativeView(TimedQApplication): - - def testQDeclarativeViewList(self): - view = QDeclarativeView() - - dataList = QStringList(["Item 1", "Item 2", "Item 3", "Item 4"]) - - ctxt = view.rootContext() - ctxt.setContextProperty("myModel", dataList) - - url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__)) - view.setSource(url) - view.show() - - self.assertEqual(view.status(), QDeclarativeView.Ready) - - self.app.exec_() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtdeclarative/view.qml b/tests/qtdeclarative/view.qml deleted file mode 100644 index ec5597df7..000000000 --- a/tests/qtdeclarative/view.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - Text { text: modelData } - } - } -} diff --git a/tests/qtgui/add_action_test.py b/tests/qtgui/add_action_test.py deleted file mode 100644 index 7e20c459d..000000000 --- a/tests/qtgui/add_action_test.py +++ /dev/null @@ -1,44 +0,0 @@ - -'''Tests for QMenuBar.addAction(identifier, callback) calls''' - -import unittest - -from PySide.QtCore import SLOT -from PySide.QtGui import QMenuBar, QAction, QPushButton - -from helper import UsesQApplication - - -class AddActionTest(UsesQApplication): - '''QMenuBar addAction''' - - def tearDown(self): - try: - del self.called - except AttributeError: - pass - super(AddActionTest, self).tearDown() - - def _callback(self): - self.called = True - - def testBasic(self): - '''QMenuBar.addAction(id, callback)''' - menubar = QMenuBar() - action = menubar.addAction("Accounts", self._callback) - action.activate(QAction.Trigger) - self.assert_(self.called) - - def testWithCppSlot(self): - '''QMenuBar.addAction(id, object, slot)''' - menubar = QMenuBar() - widget = QPushButton() - widget.setCheckable(True) - widget.setChecked(False) - action = menubar.addAction("Accounts", widget, SLOT("toggle()")) - action.activate(QAction.Trigger) - self.assert_(widget.isChecked()) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/customproxywidget_test.py b/tests/qtgui/customproxywidget_test.py deleted file mode 100755 index b9ccdff7a..000000000 --- a/tests/qtgui/customproxywidget_test.py +++ /dev/null @@ -1,33 +0,0 @@ -import unittest - -from helper import UsesQApplication -from PySide.QtCore import Qt, QTimer -from PySide.QtGui import QLabel, QPainter -from PySide.QtGui import QGraphicsScene, QGraphicsView, QGraphicsItem, QGraphicsProxyWidget - -class CustomProxy(QGraphicsProxyWidget): - def __init__(self, parent=None, wFlags=0): - QGraphicsProxyWidget.__init__(self, parent, wFlags) - -class CustomProxyWidgetTest(UsesQApplication): - def testCustomProxyWidget(self): - scene = QGraphicsScene() - - proxy = CustomProxy(None, Qt.Window) - widget = QLabel('Widget') - proxy.setWidget(widget) - proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache) - scene.addItem(proxy) - scene.setSceneRect(scene.itemsBoundingRect()) - - view = QGraphicsView(scene) - view.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform) - view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate) - view.show() - - timer = QTimer.singleShot(100, self.app.quit) - self.app.exec_() - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/float_to_int_implicit_conversion_test.py b/tests/qtgui/float_to_int_implicit_conversion_test.py deleted file mode 100644 index cc7d18fd9..000000000 --- a/tests/qtgui/float_to_int_implicit_conversion_test.py +++ /dev/null @@ -1,32 +0,0 @@ - -'''Test cases for QImage''' - -import unittest - -from PySide.QtGui import QImage, qRgb - -from helper import UsesQApplication - -class SetPixelFloat(UsesQApplication): - '''Test case for calling setPixel with float as argument''' - - def setUp(self): - #Acquire resources - super(SetPixelFloat, self).setUp() - self.color = qRgb(255, 0, 0) - self.image = QImage(200, 200, QImage.Format_RGB32) - - def tearDown(self): - #Release resources - del self.color - del self.image - super(SetPixelFloat, self).tearDown() - - def testFloat(self): - #QImage.setPixel(float, float, color) - Implicit conversion - self.image.setPixel(3.14, 4.2, self.color) - self.assertEqual(self.image.pixel(3.14, 4.2), self.color) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/grandparent_method_test.py b/tests/qtgui/grandparent_method_test.py deleted file mode 100644 index 3c1829377..000000000 --- a/tests/qtgui/grandparent_method_test.py +++ /dev/null @@ -1,23 +0,0 @@ - -'''Tests for calling methods further than the direct parent''' - -import unittest - -from PySide.QtGui import QPushButton, QWidget - -from helper import UsesQApplication - -class Dummy(QPushButton): - - def show(self): - QWidget.show(self) - self.called = True - -class GrandParentMethod(UsesQApplication): - def testMethod(self): - obj = Dummy() - obj.show() - self.assert_(obj.called) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/hashabletype_test.py b/tests/qtgui/hashabletype_test.py deleted file mode 100644 index 64683a398..000000000 --- a/tests/qtgui/hashabletype_test.py +++ /dev/null @@ -1,18 +0,0 @@ -'''Test cases for __hash__''' - -import unittest - -from PySide.QtGui import QTreeWidgetItem -from helper import UsesQApplication - -class HashableTest(UsesQApplication): - - def testQTreeWidgetItemHash(self): - h = {} - obj = QTreeWidgetItem() - h[obj] = 2 - self.assert_(h.get(obj), 2) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/keep_reference_test.py b/tests/qtgui/keep_reference_test.py deleted file mode 100755 index d0962d5df..000000000 --- a/tests/qtgui/keep_reference_test.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python - -import unittest - -from sys import getrefcount -from helper import UsesQApplication -from PySide.QtCore import QAbstractTableModel, QVariant -from PySide.QtGui import QTableView - -class TestModel(QAbstractTableModel): - def __init__(self, parent=None): - QAbstractTableModel.__init__(self, parent) - def rowCount(self, parent): - return 0 - def columnCount(self, parent): - return 0 - def data(self, index, role): - return QVariant() - -class KeepReferenceTest(UsesQApplication): - - def testModelWithoutParent(self): - view = QTableView() - model = TestModel() - view.setModel(model) - samemodel = view.model() - self.assertEqual(model, samemodel) - - def testModelWithParent(self): - view = QTableView() - model = TestModel(self.app) - view.setModel(model) - samemodel = view.model() - self.assertEqual(model, samemodel) - - def testReferenceCounting(self): - '''Tests reference count of model object referred by view objects.''' - model1 = TestModel() - refcount1 = getrefcount(model1) - view1 = QTableView() - view1.setModel(model1) - self.assertEqual(getrefcount(view1.model()), refcount1 + 1) - - view2 = QTableView() - view2.setModel(model1) - self.assertEqual(getrefcount(view2.model()), refcount1 + 2) - - model2 = TestModel() - view2.setModel(model2) - self.assertEqual(getrefcount(view1.model()), refcount1 + 1) - - def testReferenceCountingWhenDeletingReferrer(self): - '''Tests reference count of model object referred by deceased view object.''' - model = TestModel() - refcount1 = getrefcount(model) - view = QTableView() - view.setModel(model) - self.assertEqual(getrefcount(view.model()), refcount1 + 1) - - del view - self.assertEqual(getrefcount(model), refcount1) - - def testReferreedObjectSurvivalAfterContextEnd(self): - '''Model object assigned to a view object must survive after getting out of context.''' - def createModelAndSetToView(view): - model = TestModel() - model.setObjectName('created model') - view.setModel(model) - view = QTableView() - createModelAndSetToView(view) - model = view.model() - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/missing_symbols_test.py b/tests/qtgui/missing_symbols_test.py deleted file mode 100644 index de23c569e..000000000 --- a/tests/qtgui/missing_symbols_test.py +++ /dev/null @@ -1,29 +0,0 @@ - -'''(Very) Simple test case for missing names from QtGui''' - -import unittest -from PySide import QtGui - -class MissingClasses(unittest.TestCase): - def testQDrag(self): # Bug 222 - getattr(QtGui, 'QDrag') - - def testQDropEvent(self): # Bug 255 - getattr(QtGui, 'QDropEvent') - -class MissingMembers(unittest.TestCase): - - def testQFontMetricsSize(self): # Bug 223 - QtGui.QFontMetrics.size - - def testQLayoutSetSpacing(self): # Bug 231 - QtGui.QLayout.setSpacing - - def testQImageLoad(self): # Bug 257 - QtGui.QImage.load - - def testQStandardItemModelinsertRow(self): # Bug 227 - QtGui.QStandardItemModel.insertRow - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/paint_event_test.py b/tests/qtgui/paint_event_test.py deleted file mode 100644 index 02253908e..000000000 --- a/tests/qtgui/paint_event_test.py +++ /dev/null @@ -1,71 +0,0 @@ - -'''Test paint event override in python''' - -import unittest - -from PySide.QtCore import QTimerEvent -from PySide.QtGui import QApplication, QWidget - -from helper import UsesQApplication - -class MyWidget(QWidget): - '''Sample widget''' - - def __init__(self, app=None): - #Creates a new widget - if app is None: - app = QApplication([]) - - super(MyWidget, self).__init__() - self.app = app - self.runs = 0 - self.max_runs = 5 - self.paint_event_called = False - - def timerEvent(self, event): - #Timer event method - self.runs += 1 - - if self.runs == self.max_runs: - self.app.quit() - - if not isinstance(event, QTimerEvent): - raise TypeError('Invalid event type. Must be QTimerEvent') - - def paintEvent(self, event): - #Empty paint event method - # XXX: should be using super here, but somehow PyQt4 - # complains about paintEvent not present in super - QWidget.paintEvent(self, event) - self.paint_event_called = True - - -class PaintEventOverride(UsesQApplication): - '''Test case for overriding QWidget.paintEvent''' - - qapplication = True - - def setUp(self): - #Acquire resources - super(PaintEventOverride, self).setUp() - self.widget = MyWidget(self.app) - - def tearDown(self): - #Release resources - del self.widget - super(PaintEventOverride, self).tearDown() - - def testPaintEvent(self): - #Test QWidget.paintEvent override - timer_id = self.widget.startTimer(100) - self.widget.show() - self.app.exec_() - - self.widget.killTimer(timer_id) - - self.assert_(self.widget.paint_event_called) - self.assertEqual(self.widget.runs, 5) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/parent_method_test.py b/tests/qtgui/parent_method_test.py deleted file mode 100644 index 8d0ba9601..000000000 --- a/tests/qtgui/parent_method_test.py +++ /dev/null @@ -1,25 +0,0 @@ - -import unittest - -from PySide.QtCore import QObject, QTimer, QThread -from PySide.QtGui import * - -class Foo(QTableView): - def __init__(self, parent=None): - QTableView.__init__(self, parent) - -from helper import UsesQApplication - -class TestParentType(UsesQApplication): - - def testParentType(self): - # Test the problem with calling QObject.parent from a QWidget - # when the parent is a python class derived from a QWidget-derived - # class. The method was returning the last C++ class in the hierarchy - parent = Foo() - w2 = QWidget(parent) - self.assert_(isinstance(w2.parentWidget(), Foo)) - self.assert_(isinstance(w2.parent(), Foo)) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/python_properties_test.py b/tests/qtgui/python_properties_test.py deleted file mode 100644 index 7d6c024e7..000000000 --- a/tests/qtgui/python_properties_test.py +++ /dev/null @@ -1,15 +0,0 @@ -import unittest -from PySide import QtGui, QtCore - -class Properties(unittest.TestCase): - - def testStaticProperty(self): - self.assertEqual(QtGui.QGraphicsItem.UserType, 65536) - - def testInstanceProperty(self): - p = QtGui.QStyleOptionViewItemV3() - self.assert_(isinstance(p.locale, QtCore.QLocale)) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qapp_test.py b/tests/qtgui/qapp_test.py deleted file mode 100644 index c371492e6..000000000 --- a/tests/qtgui/qapp_test.py +++ /dev/null @@ -1,17 +0,0 @@ - -''' Test the presence of qApp Macro''' - -import unittest - -from PySide import QtGui - -class QAppPresence(unittest.TestCase): - - def testQApp(self): - #QtGui.qApp variable is instance of QApplication - self.assert_(isinstance(QtGui.qApp, QtGui.QApplication)) - - -if __name__ == '__main__': - app = QtGui.QApplication([]) - unittest.main() diff --git a/tests/qtgui/qapplication_exit_segfault_test.py b/tests/qtgui/qapplication_exit_segfault_test.py deleted file mode 100644 index 72b810a98..000000000 --- a/tests/qtgui/qapplication_exit_segfault_test.py +++ /dev/null @@ -1,17 +0,0 @@ - -import unittest -import sys - -from PySide.QtGui import QApplication, QPushButton, QWidget, QSpinBox - -class QApplicationDelete(unittest.TestCase): - '''Test for segfault when deleting a QApplication before a QWidget''' - - def testQPushButton(self): - #QApplication deleted before QPushButton - a = QApplication([]) - b = QPushButton('aaaa') - del a - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qapplication_singleton_test.py b/tests/qtgui/qapplication_singleton_test.py deleted file mode 100644 index 9c959f9d4..000000000 --- a/tests/qtgui/qapplication_singleton_test.py +++ /dev/null @@ -1,12 +0,0 @@ - -import unittest - -from PySide.QtGui import QApplication - -class TestSingleton(unittest.TestCase): - def testBasic(self): - a = QApplication([]) - self.assertRaises(RuntimeError, QApplication, []) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qbrush_test.py b/tests/qtgui/qbrush_test.py deleted file mode 100644 index cf11652a5..000000000 --- a/tests/qtgui/qbrush_test.py +++ /dev/null @@ -1,24 +0,0 @@ - -'''Test cases for QBrush''' - -import unittest - -from PySide.QtCore import Qt -from PySide.QtGui import QApplication, QColor, QBrush - -from helper import UsesQApplication - -class Constructor(UsesQApplication): - '''Test case for constructor of QBrush''' - - def testQColor(self): - #QBrush(QColor) constructor - color = QColor('black') - obj = QBrush(color) - self.assertEqual(obj.color(), color) - - obj = QBrush(Qt.blue) - self.assertEqual(obj.color(), Qt.blue) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qcolor_test.py b/tests/qtgui/qcolor_test.py deleted file mode 100644 index 3c2f11ba0..000000000 --- a/tests/qtgui/qcolor_test.py +++ /dev/null @@ -1,68 +0,0 @@ - -import unittest -import colorsys - -from PySide.QtCore import Qt -from PySide.QtGui import QColor - - -class QColorGetTest(unittest.TestCase): - - def setUp(self): - self.color = QColor(20, 40, 60, 80) - - def testGetRgb(self): - self.assertEqual(self.color.getRgb(), (20, 40, 60, 80)) - - def testGetRgbF(self): - self.assertEqual(self.color.getRgbF(), (20.0/255, 40.0/255, 60.0/255, 80.0/255)) - - def testGetHsl(self): - self.assertEqual(self.color.getHsl(), (210, 128, 40, self.color.alpha())) - - def testGetHslF(self): - hls = colorsys.rgb_to_hls(20.0/255, 40.0/255, 60.0/255) - hsla = hls[0], hls[2], hls[1], self.color.alphaF() - for x, y in zip(self.color.getHslF(), hsla): # Due to rounding problems - self.assert_(x - y < 1/100000.0) - - def testGetHsv(self): - hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255) - hsva = int(hsv[0]*360.0), int(hsv[1]*255), int(hsv[2]*256), self.color.alpha() - self.assertEqual(self.color.getHsv(), hsva) - - def testGetHsvF(self): - hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255) - hsva = hsv[0], hsv[1], hsv[2], self.color.alphaF() - self.assertEqual(self.color.getHsvF(), hsva) - - def testGetCmyk(self): # not supported by colorsys - self.assertEqual(self.color.getCmyk(), (170, 85, 0, 195, 80)) - - def testGetCmykF(self): # not supported by colorsys - for x, y in zip(self.color.getCmykF(), (170/255.0, 85/255.0, 0, 195/255.0, 80/255.0)): - self.assert_(x - y < 1/10000.0) - - -class QColorQRgbConstructor(unittest.TestCase): - '''QColor(QRgb) constructor''' - # Affected by bug #170 - QColor(QVariant) coming before QColor(uint) - # in overload sorting - - def testBasic(self): - '''QColor(QRgb)''' - color = QColor(255, 0, 0) - #QRgb format #AARRGGBB - rgb = 0x00FF0000 - self.assertEqual(QColor(rgb), color) - - -class QColorEqualGlobalColor(unittest.TestCase): - - def testEqualGlobalColor(self): - '''QColor == Qt::GlobalColor''' - self.assertEqual(QColor(255, 0, 0), Qt.red) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qdatastream_gui_operators_test.py b/tests/qtgui/qdatastream_gui_operators_test.py deleted file mode 100644 index dbb638fd3..000000000 --- a/tests/qtgui/qdatastream_gui_operators_test.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- - -import unittest -import sys - -from PySide.QtCore import QDataStream, QByteArray, QIODevice, Qt -from PySide.QtGui import QPixmap, QColor - -from helper import UsesQApplication - -class QPixmapQDatastream(UsesQApplication): - '''QDataStream <<>> QPixmap''' - - def setUp(self): - super(QPixmapQDatastream, self).setUp() - self.source_pixmap = QPixmap(100, 100) - self.source_pixmap.fill(Qt.red) - self.output_pixmap = QPixmap() - self.buffer = QByteArray() - self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly) - self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly) - - def testStream(self): - self.write_stream << self.source_pixmap - - self.read_stream >> self.output_pixmap - - image = self.output_pixmap.toImage() - pixel = image.pixel(10,10) - self.assertEqual(pixel, QColor(Qt.red).rgba()) - self.assertEqual(self.source_pixmap.toImage(), self.output_pixmap.toImage()) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qfontdialog_test.py b/tests/qtgui/qfontdialog_test.py deleted file mode 100644 index 02bce7828..000000000 --- a/tests/qtgui/qfontdialog_test.py +++ /dev/null @@ -1,22 +0,0 @@ -import unittest -import sys - -from PySide import QtGui -from PySide import QtCore - -from helper import TimedQApplication - -class TestFontDialog(TimedQApplication): - - def testGetFont(self): - QtGui.QFontDialog.getFont() - - def testGetFontQDialog(self): - QtGui.QFontDialog.getFont(QtGui.QFont("FreeSans",10)) - - def testGetFontQDialogQString(self): - QtGui.QFontDialog.getFont(QtGui.QFont("FreeSans",10), None, "Select font") - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qfontmetrics_test.py b/tests/qtgui/qfontmetrics_test.py deleted file mode 100644 index 7964d91d4..000000000 --- a/tests/qtgui/qfontmetrics_test.py +++ /dev/null @@ -1,189 +0,0 @@ - -'''Tests for inject codes and modifications on QFontMetrics - and QFontMetricsF''' - -import unittest -from PySide.QtGui import QFont, QFontMetrics, QFontMetricsF -from PySide.QtCore import QRect, QRectF, Qt, QSize, QSizeF -from helper import UsesQApplication - - -class QFontMetricsTest(UsesQApplication): - '''Base class for QFontMetrics tests''' - - def setUp(self): - super(QFontMetricsTest, self).setUp() - self.font = QFont() - self.metrics = QFontMetrics(self.font) - - def tearDown(self): - del self.metrics - del self.font - super(QFontMetricsTest, self).tearDown() - - -class BoundingRectTest(QFontMetricsTest): - '''Tests for QFontMetrics.boundingRect inject code''' - - def testIntDefault(self): - '''QFontMetrics.boundingRect(int, int, int, int, ...) - default args''' - rect = self.metrics.boundingRect(0, 0, 0, 0, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT') - self.assert_(isinstance(rect, QRect)) - - def testIntWithArg(self): - '''QFontMetrics.boundingRect(int, int, int, int, ...) - single arg''' - rect = self.metrics.boundingRect(0, 0, 0, 0, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 2) - self.assert_(isinstance(rect, QRect)) - - def testIntWithFull(self): - '''QFontMetrics.boundingRect(int, int, int, int, ...) - all argss''' - rect = self.metrics.boundingRect(0, 0, 0, 0, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, [1, 2, 3, 4, 5]) - self.assert_(isinstance(rect, QRect)) - - def testIntTypeError(self): - '''QFontMetrics.boundingRect(int, int, int, int, ...) - type error''' - self.assertRaises(TypeError, self.metrics.boundingRect, 0, 0, 0, 0, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, ['aaaa', 'ase']) - - def testQRectDefault(self): - '''QFontMetrics.boundingRect(QRect, ...) - default args''' - arg = QRect(0, 0, 100, 200) - rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT') - self.assert_(isinstance(rect, QRect)) - - def testQRectWithArg(self): - '''QFontMetrics.boundingRect(QRect, ...) - only tabstops''' - arg = QRect(0, 0, 100, 200) - rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 2) - self.assert_(isinstance(rect, QRect)) - - def testQRectWithFull(self): - '''QFontMetrics.boundingRect(QRect, ...) - all arguments''' - arg = QRect(0, 0, 100, 200) - rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, - [1, 2, 3, 4, 5]) - self.assert_(isinstance(rect, QRect)) - - def testQRectTypeError(self): - '''QFontMetrics.boundingRect(QRect, ...) - type error''' - arg = QRect(0, 0, 100, 200) - self.assertRaises(TypeError, self.metrics.boundingRect, arg, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, ['aaaa', 'ase']) - - -class SizeTest(QFontMetricsTest): - '''Tests for QFontMetrics.size inject code''' - - def testDefault(self): - '''QFontMetrics.size - default arguments''' - size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, - 'PySide by INdT') - self.assert_(isinstance(size, QSize)) - - def testWithTabStops(self): - '''QFontMetrics.size - only tabstops''' - size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, - 'PySide by INdT', 2) - self.assert_(isinstance(size, QSize)) - - def testFull(self): - '''QFontMetrics.size - all arguments''' - size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, - 'PySide by INdT', 2, [1, 2, 3, 4]) - self.assert_(isinstance(size, QSize)) - - def testTypeError(self): - '''QFontMetrics.size - type error''' - self.assertRaises(TypeError, self.metrics.size, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, ['aaaa', 'ase']) - - -class QFontMetricsFTest(UsesQApplication): - '''Base class for QFontMetrics tests''' - - def setUp(self): - super(QFontMetricsFTest, self).setUp() - self.font = QFont() - self.metrics = QFontMetricsF(self.font) - - def tearDown(self): - del self.metrics - del self.font - super(QFontMetricsFTest, self).tearDown() - - -class FBoundingRectTest(QFontMetricsFTest): - '''Tests for QFontMetricsF.boundingRect inject code''' - - def testQRectDefault(self): - '''QFontMetricsF.boundingRect(QRectF, ...) - default args''' - arg = QRectF(0, 0, 100, 200) - rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT') - self.assert_(isinstance(rect, QRectF)) - - def testQRectWithArg(self): - '''QFontMetricsF.boundingRect(QRectF, ...) - only tabstops''' - arg = QRectF(0, 0, 100, 200) - rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 2) - self.assert_(isinstance(rect, QRectF)) - - def testQRectWithFull(self): - '''QFontMetricsF.boundingRect(QRectF, ...) - all arguments''' - arg = QRectF(0, 0, 100, 200) - rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, - [1, 2, 3, 4, 5]) - self.assert_(isinstance(rect, QRectF)) - - def testQRectTypeError(self): - '''QFontMetricsF.boundingRect(QRectF, ...) - type error''' - arg = QRectF(0, 0, 100, 200) - self.assertRaises(TypeError, self.metrics.boundingRect, arg, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, ['aaaa', 'ase']) - - -class FSizeTest(QFontMetricsFTest): - '''Tests for QFontMetricsF.size inject code''' - - def testDefault(self): - '''QFontMetricsF.size - default arguments''' - size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, - 'PySide by INdT') - self.assert_(isinstance(size, QSizeF)) - - def testWithTabStops(self): - '''QFontMetricsF.size - only tabstops''' - size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, - 'PySide by INdT', 2) - self.assert_(isinstance(size, QSizeF)) - - def testFull(self): - '''QFontMetricsF.size - all arguments''' - size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, - 'PySide by INdT', 2, [1, 2, 3, 4]) - self.assert_(isinstance(size, QSizeF)) - - def testTypeError(self): - '''QFontMetricsF.size - type error''' - self.assertRaises(TypeError, self.metrics.size, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, ['aaaa', 'ase']) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qgraphicsitem_isblocked_test.py b/tests/qtgui/qgraphicsitem_isblocked_test.py deleted file mode 100755 index b281c8a59..000000000 --- a/tests/qtgui/qgraphicsitem_isblocked_test.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python - -import unittest - -from PySide import QtCore -from PySide import QtGui -from helper import UsesQApplication - -class Item(QtGui.QGraphicsItem): - - def __init__(self): - QtGui.QGraphicsItem.__init__(self) - - def boundingRect(self): - return QtCore.QRectF(0, 0, 100, 100) - - def paint(self, painter, option, widget): - painter.setBrush(QtGui.QColor(255, 255, 255)) - painter.drawRect(0, 0, 100, 100) - - -class QGraphicsViewIsBlockedTest(UsesQApplication): - - def testIsBlockedByModalPanel(self): - (first, second) = Item().isBlockedByModalPanel() - self.assertFalse(first) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/qtgui/qgraphicsitem_test.py b/tests/qtgui/qgraphicsitem_test.py deleted file mode 100644 index 43545a431..000000000 --- a/tests/qtgui/qgraphicsitem_test.py +++ /dev/null @@ -1,35 +0,0 @@ - -''' Test cases related to QGraphicsItem and subclasses''' - -import unittest - -from PySide.QtGui import QGraphicsScene, QPolygonF, QColor, QBrush - -from helper import UsesQApplication - -class QColorOnSetBrush(UsesQApplication): - '''Test case for passing a QColor directly to setBrush''' - - def setUp(self): - #Acquire resources - super(QColorOnSetBrush, self).setUp() - - self.scene = QGraphicsScene() - poly = QPolygonF() - self.item = self.scene.addPolygon(poly) - self.color = QColor('black') - - def tearDown(self): - #Release resources - del self.color - del self.item - del self.scene - super(QColorOnSetBrush, self).tearDown() - - def testQColor(self): - #QGraphicsAbstractShapeItem.setBrush(QColor) - self.item.setBrush(self.color) - self.assertEqual(QBrush(self.color), self.item.brush()) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qgraphicsproxywidget_test.py b/tests/qtgui/qgraphicsproxywidget_test.py deleted file mode 100755 index 3a856bc7c..000000000 --- a/tests/qtgui/qgraphicsproxywidget_test.py +++ /dev/null @@ -1,29 +0,0 @@ -import unittest - -from helper import UsesQApplication -from PySide.QtCore import Qt, QTimer -from PySide.QtGui import QLabel, QPainter -from PySide.QtGui import QGraphicsScene, QGraphicsView, QGraphicsItem, QGraphicsProxyWidget - -class QGraphicsProxyWidgetTest(UsesQApplication): - def testQGraphicsProxyWidget(self): - scene = QGraphicsScene() - - proxy = QGraphicsProxyWidget(None, Qt.Window) - widget = QLabel('Widget') - proxy.setWidget(widget) - proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache) - scene.addItem(proxy) - scene.setSceneRect(scene.itemsBoundingRect()) - - view = QGraphicsView(scene) - view.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform) - view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate) - view.show() - - timer = QTimer.singleShot(100, self.app.quit) - self.app.exec_() - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qgraphicsscene_test.py b/tests/qtgui/qgraphicsscene_test.py deleted file mode 100644 index 98177e75a..000000000 --- a/tests/qtgui/qgraphicsscene_test.py +++ /dev/null @@ -1,152 +0,0 @@ - -'''Basic test cases for QGraphicsScene''' - -import unittest -import gc - -from PySide.QtCore import QPointF -from PySide.QtGui import QApplication, QPushButton, QPolygonF, QPixmap -from PySide.QtGui import QGraphicsScene, QPainterPath -from PySide.QtGui import QGraphicsEllipseItem, QGraphicsLineItem -from PySide.QtGui import QGraphicsPathItem, QGraphicsPixmapItem -from PySide.QtGui import QGraphicsPolygonItem, QGraphicsRectItem -from PySide.QtGui import QGraphicsSimpleTextItem, QGraphicsTextItem -from PySide.QtGui import QGraphicsProxyWidget - -from helper import UsesQApplication - -class Constructor(unittest.TestCase): - '''QGraphicsScene constructor''' - - def testConstructor(self): - #QGraphicsScene constructor - obj = QGraphicsScene() - self.assert_(isinstance(obj, QGraphicsScene)) - - -class ConstructorWithRect(unittest.TestCase): - '''QGraphicsScene qrect constructor and related sizes''' - - def setUp(self): - #Acquire resources - # PyQt4 doesn't accept a QRect as argument to constructor - self.scene = QGraphicsScene(0, 200, 150, 175) - - def tearDown(self): - #Release resources - del self.scene - - def testHeight(self): - #QGraphicsScene.height() - self.assertEqual(self.scene.height(), 175) - - def testWidth(self): - #QGraphicsScene.width() - self.assertEqual(self.scene.width(), 150) - - -class AddItem(UsesQApplication): - '''Tests for QGraphicsScene.add*''' - - qapplication = True - - def setUp(self): - #Acquire resources - super(AddItem, self).setUp() - self.scene = QGraphicsScene() - # While the scene does not inherits from QWidget, requires - # an application to make the internals work. - - def tearDown(self): - #Release resources - del self.scene - super(AddItem, self).tearDown() - - def testEllipse(self): - #QGraphicsScene.addEllipse - item = self.scene.addEllipse(100, 100, 100, 100) - self.assert_(isinstance(item, QGraphicsEllipseItem)) - - def testLine(self): - #QGraphicsScene.addLine - item = self.scene.addLine(100, 100, 200, 200) - self.assert_(isinstance(item, QGraphicsLineItem)) - - def testPath(self): - #QGraphicsScene.addPath - item = self.scene.addPath(QPainterPath()) - self.assert_(isinstance(item, QGraphicsPathItem)) - - def testPixmap(self): - #QGraphicsScene.addPixmap - item = self.scene.addPixmap(QPixmap()) - self.assert_(isinstance(item, QGraphicsPixmapItem)) - - def testPolygon(self): - #QGraphicsScene.addPolygon - points = [QPointF(0, 0), QPointF(100, 100), QPointF(0, 100)] - item = self.scene.addPolygon(QPolygonF(points)) - self.assert_(isinstance(item, QGraphicsPolygonItem)) - - def testRect(self): - #QGraphicsScene.addRect - item = self.scene.addRect(100, 100, 100, 100) - self.assert_(isinstance(item, QGraphicsRectItem)) - - def testSimpleText(self): - #QGraphicsScene.addSimpleText - item = self.scene.addSimpleText('Monty Python 42') - self.assert_(isinstance(item, QGraphicsSimpleTextItem)) - - def testText(self): - #QGraphicsScene.addText - item = self.scene.addText('Monty Python 42') - self.assert_(isinstance(item, QGraphicsTextItem)) - - def testWidget(self): - #QGraphicsScene.addWidget - # XXX: printing some X11 error when using under PyQt4 - item = self.scene.addWidget(QPushButton()) - self.assert_(isinstance(item, QGraphicsProxyWidget)) - - -class ItemRetrieve(UsesQApplication): - '''Tests for QGraphicsScene item retrieval methods''' - - qapplication = True - - def setUp(self): - #Acquire resources - super(ItemRetrieve, self).setUp() - self.scene = QGraphicsScene() - - self.topleft = QGraphicsRectItem(0, 0, 100, 100) - self.topright = QGraphicsRectItem(100, 0, 100, 100) - self.bottomleft = QGraphicsRectItem(0, 100, 100, 100) - self.bottomright = QGraphicsRectItem(100, 100, 100, 100) - - self.items = [self.topleft, self.topright, self.bottomleft, - self.bottomright] - - for item in self.items: - self.scene.addItem(item) - - def tearDown(self): - #Release resources - del self.scene - super(ItemRetrieve, self).tearDown() - - def testItems(self): - #QGraphicsScene.items() - items = self.scene.items() - self.assertEqual(items.sort(), self.items.sort()) - - def testItemAt(self): - #QGraphicsScene.itemAt() - self.assertEqual(self.scene.itemAt(50, 50), self.topleft) - self.assertEqual(self.scene.itemAt(150, 50), self.topright) - self.assertEqual(self.scene.itemAt(50, 150), self.bottomleft) - self.assertEqual(self.scene.itemAt(150, 150), self.bottomright) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qinputdialog_get_test.py b/tests/qtgui/qinputdialog_get_test.py deleted file mode 100644 index c75f71251..000000000 --- a/tests/qtgui/qinputdialog_get_test.py +++ /dev/null @@ -1,27 +0,0 @@ -import unittest - -from PySide import QtCore, QtGui -from helper import UsesQApplication, TimedQApplication - -class TestInputDialog(TimedQApplication): - - def testGetDouble(self): - self.assertEquals(QtGui.QInputDialog.getDouble(None, "title", "label"), (0.0, False)) - - def testGetInt(self): - self.assertEquals(QtGui.QInputDialog.getInt(None, "title", "label"), (0, False)) - - def testGetInteger(self): - self.assertEquals(QtGui.QInputDialog.getInteger(None, "title", "label"), (0, False)) - - def testGetItem(self): - (item, bool) = QtGui.QInputDialog.getItem(None, "title", "label", QtCore.QStringList(["1", "2", "3"])) - self.assertEquals(str(item), "1") - - def testGetText(self): - (text, bool) = QtGui.QInputDialog.getText(None, "title", "label") - self.assertEquals(str(text),"") - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qitemselection_test.py b/tests/qtgui/qitemselection_test.py deleted file mode 100644 index 8c6c34e03..000000000 --- a/tests/qtgui/qitemselection_test.py +++ /dev/null @@ -1,18 +0,0 @@ -import unittest - -from helper import UsesQApplication -from PySide.QtGui import QItemSelection, QStandardItemModel - -class QItemSelectionTest(UsesQApplication): - def testLen(self): - model = QStandardItemModel(2, 2) - model.insertRow(0) - model.insertRow(1) - model.insertColumn(0) - model.insertColumn(1) - selection = QItemSelection(model.index(0,0), model.index(1,1)) - self.assertEqual(len(selection), 1) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qlabel_pixmap_refcount.py b/tests/qtgui/qlabel_pixmap_refcount.py deleted file mode 100644 index db8783e98..000000000 --- a/tests/qtgui/qlabel_pixmap_refcount.py +++ /dev/null @@ -1,46 +0,0 @@ - -'''Test cases for QLabel->pixmap refcount control''' - -import unittest -import sys - - -from helper import UsesQApplication -from PySide.QtGui import QApplication, QLabel, QPixmap - -class QLabelTest(UsesQApplication): - '''Test case for constructor of QBrush''' - - def testDestroyOwner(self): - p = QPixmap() - l = QLabel() - l.setPixmap(p) - - del p - - p1 = l.pixmap() - self.assertEqual(sys.getrefcount(p1), 2) - self.assertEqual(sys.getrefcount(l), 2) - - del l - self.assertEqual(sys.getrefcount(p1), 2) - - - def testRefCount(self): - p = QPixmap() - l = QLabel() - l.setPixmap(p) - - del p - - p1 = l.pixmap() - self.assertEqual(sys.getrefcount(p1), 2) - - p2 = l.pixmap() - self.assertEqual(sys.getrefcount(p2), 3) - - p3 = l.pixmap() - self.assertEqual(sys.getrefcount(p3), 4) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qlayout_ref_test.py b/tests/qtgui/qlayout_ref_test.py deleted file mode 100644 index a6342718d..000000000 --- a/tests/qtgui/qlayout_ref_test.py +++ /dev/null @@ -1,112 +0,0 @@ - -'''Test cases for QLayout handling of child widgets references''' - -import unittest -from sys import getrefcount - -from PySide.QtGui import QHBoxLayout, QVBoxLayout, QGridLayout, QWidget -from PySide.QtGui import QStackedLayout, QFormLayout -from PySide.QtGui import QApplication, QPushButton, QLabel - -from helper import UsesQApplication - -class SaveReference(UsesQApplication): - '''Test case to check if QLayout-derived classes increment the refcount - of widgets passed to addWidget()''' - - # Adding here as nose can't see the qapplication attrib we inherit - qapplication = True - - def setUp(self): - #Acquire resources - super(SaveReference, self).setUp() - self.widget1 = QPushButton('click me') - self.widget2 = QLabel('aaa') - - def tearDown(self): - #Release resources - del self.widget2 - del self.widget1 - super(SaveReference, self).tearDown() - - def checkLayoutReference(self, layout): - #Checks the reference cound handling of layout.addWidget - self.assertEqual(getrefcount(self.widget1), 2) - layout.addWidget(self.widget1) - self.assertEqual(getrefcount(self.widget1), 3) - - self.assertEqual(getrefcount(self.widget2), 2) - layout.addWidget(self.widget2) - self.assertEqual(getrefcount(self.widget2), 3) - - # Check if doesn't mess around with previous widget refcount - self.assertEqual(getrefcount(self.widget1), 3) - - def testMoveLayout(self): - l = QHBoxLayout() - self.assertEqual(getrefcount(self.widget1), 2) - l.addWidget(self.widget1) - self.assertEqual(getrefcount(self.widget1), 2) - - w = QWidget() - w.setLayout(l) - self.assertEqual(getrefcount(self.widget1), 3) - - - def testHBoxReference(self): - #QHBoxLayout.addWidget reference count - w = QWidget() - self.checkLayoutReference(QHBoxLayout(w)) - - def testVBoxReference(self): - #QVBoxLayout.addWidget reference count - w = QWidget() - self.checkLayoutReference(QVBoxLayout(w)) - - def testGridReference(self): - #QGridLayout.addWidget reference count - w = QWidget() - self.checkLayoutReference(QGridLayout(w)) - - def testFormReference(self): - #QFormLayout.addWidget reference count - w = QWidget() - self.checkLayoutReference(QFormLayout(w)) - - def testStackedReference(self): - #QStackedLayout.addWidget reference count - w = QWidget() - self.checkLayoutReference(QStackedLayout(w)) - -class MultipleAdd(UsesQApplication): - '''Test case to check if refcount is incremented only once when multiple - calls to addWidget are made with the same widget''' - - qapplication = True - - def setUp(self): - #Acquire resources - super(MultipleAdd, self).setUp() - self.widget = QPushButton('click me') - self.win = QWidget() - self.layout = QHBoxLayout(self.win) - - def tearDown(self): - #Release resources - del self.widget - del self.layout - del self.win - super(MultipleAdd, self).tearDown() - - def testRefCount(self): - #Multiple QLayout.addWidget calls on the same widget - self.assertEqual(getrefcount(self.widget), 2) - self.layout.addWidget(self.widget) - self.assertEqual(getrefcount(self.widget), 3) - self.layout.addWidget(self.widget) - self.assertEqual(getrefcount(self.widget), 3) - self.layout.addWidget(self.widget) - self.assertEqual(getrefcount(self.widget), 3) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qlayout_test.py b/tests/qtgui/qlayout_test.py deleted file mode 100644 index ae773bb0a..000000000 --- a/tests/qtgui/qlayout_test.py +++ /dev/null @@ -1,52 +0,0 @@ -import unittest -import sys - -from helper import UsesQApplication -from PySide.QtGui import QLayout, QWidget, QPushButton, QWidgetItem - -class MyLayout(QLayout): - def __init__(self, parent=None): - QLayout.__init__(self, parent) - self._list = [] - - def addItem(self, item): - self.add(item) - - def addWidget(self, widget): - self.add(QWidgetItem(widget)) - - def itemAt(self, index): - if index < len(self._list): - return self._list[index] - - return None - - def count(self): - return len(self._list) - - def add(self, item): - self._list.append(item) - - - -#Test if a layout implemented in python, the QWidget.setLayout works -#fine because this implement som layout functions used in glue code of -#QWidget, then in c++ when call a virtual function this need call the QLayout -#function implemented in python - -class QLayoutTest(UsesQApplication): - - def testOwnershipTransfer(self): - b = QPushButton("teste") - l = MyLayout() - l.addWidget(b) - - self.assertEqual(sys.getrefcount(b), 2) - - w = QWidget() - w.setLayout(l) - - self.assertEqual(sys.getrefcount(b), 3) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qlcdnumber_test.py b/tests/qtgui/qlcdnumber_test.py deleted file mode 100644 index eb6a4f396..000000000 --- a/tests/qtgui/qlcdnumber_test.py +++ /dev/null @@ -1,16 +0,0 @@ -import unittest - -from PySide.QtGui import QApplication, QLCDNumber - -class QLCDNumberOverflow(unittest.TestCase): - '''Test case for unhandled overflow on QLCDNumber() numDigits argument (see bug #215).''' - - def setUp(self): - self.app = QApplication([]) - - def testnumDigitsOverflow(self): - # NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError - self.assertRaises(OverflowError, QLCDNumber, 840835495615213080) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qlistwidgetitem_test.py b/tests/qtgui/qlistwidgetitem_test.py deleted file mode 100644 index 8f96c518f..000000000 --- a/tests/qtgui/qlistwidgetitem_test.py +++ /dev/null @@ -1,25 +0,0 @@ - -import unittest - -from PySide import QtGui - -from helper import UsesQApplication - -class QListWidgetItemConstructor(UsesQApplication): - - def setUp(self): - super(QListWidgetItemConstructor, self).setUp() - self.widgetList = QtGui.QListWidget() - - def tearDown(self): - del self.widgetList - super(QListWidgetItemConstructor, self).tearDown() - - def testConstructorWithParent(self): - # Bug 235 - QListWidgetItem constructor not saving ownership - QtGui.QListWidgetItem(self.widgetList) - item = self.widgetList.item(0) - self.assertEqual(item.listWidget(), self.widgetList) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qmainwindow_test.py b/tests/qtgui/qmainwindow_test.py deleted file mode 100644 index fce145d53..000000000 --- a/tests/qtgui/qmainwindow_test.py +++ /dev/null @@ -1,32 +0,0 @@ -import unittest -import sys - -from PySide import QtGui -from PySide import QtCore - -from helper import UsesQApplication - -class MainWindow(QtGui.QMainWindow): - def __init__(self): - QtGui.QMainWindow.__init__(self) - - self.createToolbar() - - def createToolbar(self): - pointerButton = QtGui.QToolButton() - pointerToolbar = self.addToolBar("Pointer type") - pointerToolbar.addWidget(pointerButton) - - -class TestMainWindow(UsesQApplication): - - def testCreateToolbar(self): - w = MainWindow() - w.show() - QtCore.QTimer.singleShot(1000, self.app.quit) - self.app.exec_() - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qmatrix_test.py b/tests/qtgui/qmatrix_test.py deleted file mode 100644 index 7c87e23a4..000000000 --- a/tests/qtgui/qmatrix_test.py +++ /dev/null @@ -1,49 +0,0 @@ -import unittest - -from PySide.QtCore import QPoint -from PySide.QtGui import QMatrix, QMatrix4x4 - - -def qpointTimesQMatrix(point, matrix): - '''As seen in "QPoint QMatrix::map(const QPoint &p) const" C++ implementation.''' - return QPoint(matrix.m11() * point.x() + matrix.m21() * point.y() + matrix.dx(), - matrix.m12() * point.x() + matrix.m22() * point.y() + matrix.dy()) - -class QMatrixTest(unittest.TestCase): - - def testMatrix(self): - matrix = QMatrix(11, 12, 21, 22, 100, 200) - point = QPoint(3, 3) - self.assertEqual(point * matrix, qpointTimesQMatrix(point, matrix)) - - def testMatrixWithWrongType(self): - matrix = QMatrix(11, 12, 21, 22, 100, 200) - point = QPoint(3, 3) - self.assertRaises(TypeError, matrix.__mul__, point) - - def testMatrix4x4(self): - self.assertRaises(TypeError, QMatrix4x4, [0.0, 1.0, 2.0, 3.0]) - self.assertRaises(TypeError, QMatrix4x4, [0.0, 1.0, 2.0, 'I', - 4.0, 5.0, 6.0, 7.0, - 8.0, 9.0, 'N', 11.0, - 12.0, 'd', 14.0, 'T']) - - my_data = [0.0, 1.0, 2.0, 3.0, - 4.0, 5.0, 6.0, 7.0, - 8.0, 9.0, 10.0, 11.0, - 12.0, 13.0, 14.0, 15.0] - my_datac = [0.0, 4.0, 8.0, 12.0, - 1.0, 5.0, 9.0, 13.0, - 2.0, 6.0, 10.0, 14.0, - 3.0, 7.0, 11.0, 15.0] - - m = QMatrix4x4(my_data) - d = m.data() - self.assert_(my_datac, d) - - d = m.copyDataTo() - self.assert_(my_data == list(d)) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qmenu_test.py b/tests/qtgui/qmenu_test.py deleted file mode 100644 index 37faf1613..000000000 --- a/tests/qtgui/qmenu_test.py +++ /dev/null @@ -1,58 +0,0 @@ - -import unittest - -from PySide.QtGui import QMenu, QKeySequence, QIcon -from PySide.QtCore import SLOT - -from helper import UsesQApplication - -class QMenuAddAction(UsesQApplication): - - def setUp(self): - super(QMenuAddAction, self).setUp() - self.menu = QMenu() - - def tearDown(self): - del self.menu - super(QMenuAddAction, self).tearDown() - - def testAddActionWithoutKeySequenceCallable(self): - # bug #280 - action = self.menu.addAction(self.app.tr('aaa'), lambda : 1) - - def testAddActionKeySequenceCallable(self): - # bug #228 - action = self.menu.addAction(self.app.tr('aaa'), lambda : 1, - QKeySequence(self.app.tr('Ctrl+O'))) - - def testAddActionKeySequenceSlot(self): - action = self.menu.addAction('Quit', self.app, SLOT('quit()'), - QKeySequence('Ctrl+O')) - -class QMenuAddActionWithIcon(UsesQApplication): - - def setUp(self): - super(QMenuAddActionWithIcon, self).setUp() - self.menu = QMenu() - self.icon = QIcon() - - def tearDown(self): - del self.menu - del self.icon - super(QMenuAddActionWithIcon, self).tearDown() - - def testAddActionWithoutKeySequenceCallable(self): - # bug #280 - action = self.menu.addAction(self.icon, self.app.tr('aaa'), lambda : 1) - - def testAddActionKeySequenceCallable(self): - # bug #228 - action = self.menu.addAction(self.icon, self.app.tr('aaa'), lambda : 1, - QKeySequence(self.app.tr('Ctrl+O'))) - - def testAddActionKeySequenceSlot(self): - action = self.menu.addAction(self.icon, 'Quit', self.app, SLOT('quit()'), - QKeySequence('Ctrl+O')) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qmenuadd_test.py b/tests/qtgui/qmenuadd_test.py deleted file mode 100644 index 47b112bf1..000000000 --- a/tests/qtgui/qmenuadd_test.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -''' Test the QMenu.addAction() method''' - -import unittest -import sys - -from PySide import QtGui - -from helper import UsesQApplication - -class QMenuAddAction(UsesQApplication): - - def openFile(self, *args): - self.arg = args - - def testQMenuAddAction(self): - fileMenu = QtGui.QMenu("&File") - - addNewAction = fileMenu.addAction("&Open...", self.openFile) - addNewAction.trigger() - self.assertEquals(self.arg, ()) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qobject_mi_test.py b/tests/qtgui/qobject_mi_test.py deleted file mode 100644 index 8ccc1d35d..000000000 --- a/tests/qtgui/qobject_mi_test.py +++ /dev/null @@ -1,37 +0,0 @@ -'''Test cases for multiple inheritance from 2 QObjects''' - -import unittest - -from PySide.QtCore import QObject -from PySide.QtGui import * - -from helper import UsesQApplication - -class WidgetValidator(QWidget, QIntValidator): - def __init__(self, parent=None): - QWidget.__init__(self, parent) - QIntValidator.__init__(self, parent) - - -class DoubleQObjectInheritanceTest(UsesQApplication): - - def testDouble(self): - '''Double inheritance from QObject classes''' - - obj = WidgetValidator() - - #QObject methods - obj.setObjectName('aaaa') - self.assertEqual(obj.objectName(), 'aaaa') - - #QWidget methods - obj.setVisible(False) - self.assertFalse(obj.isVisible()) - - #QIntValidator methods - self.assertEqual(obj.validate('aaaa', 0), QValidator.Invalid) - self.assertEqual(obj.validate('33', 0), QValidator.Acceptable) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qpainter_test.py b/tests/qtgui/qpainter_test.py deleted file mode 100644 index ad1d1e471..000000000 --- a/tests/qtgui/qpainter_test.py +++ /dev/null @@ -1,49 +0,0 @@ -import unittest - -from PySide.QtGui import QPainter, QBrush, QLinearGradient -from PySide.QtCore import QRect, QRectF, Qt - -class QPainterDrawText(unittest.TestCase): - - def setUp(self): - self.painter = QPainter() - self.text = 'teste!' - - def tearDown(self): - del self.text - del self.painter - - def testDrawText(self): - # bug #254 - rect = self.painter.drawText(100, 100, 100, 100, - Qt.AlignCenter | Qt.TextWordWrap, - self.text) - self.assert_(isinstance(rect, QRect)) - - def testDrawTextWithRect(self): - # bug #225 - rect = QRect(100, 100, 100, 100) - newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, - self.text) - - self.assert_(isinstance(newRect, QRect)) - - def testDrawTextWithRectF(self): - '''QPainter.drawText(QRectF, ... ,QRectF*) inject code''' - rect = QRectF(100, 52.3, 100, 100) - newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, - self.text) - - self.assert_(isinstance(newRect, QRectF)) - -class SetBrushWithOtherArgs(unittest.TestCase): - '''Using qpainter.setBrush with args other than QBrush''' - - def testSetBrushGradient(self): - painter = QPainter() - gradient = QLinearGradient(0, 0, 0, 0) - painter.setBrush(gradient) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qpen_test.py b/tests/qtgui/qpen_test.py deleted file mode 100644 index f9e9b1861..000000000 --- a/tests/qtgui/qpen_test.py +++ /dev/null @@ -1,20 +0,0 @@ - -import unittest - -from PySide.QtCore import Qt -from PySide.QtGui import QPen - -class QPenTest(unittest.TestCase): - - def testCtorWithCreatedEnums(self): - '''A simple case of QPen creation using created enums.''' - width = 0 - style = Qt.PenStyle(0) - cap = Qt.PenCapStyle(0) - join = Qt.PenJoinStyle(0) - pen = QPen(Qt.blue, width, style, cap, join) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qpixmap_test.py b/tests/qtgui/qpixmap_test.py deleted file mode 100644 index 481409462..000000000 --- a/tests/qtgui/qpixmap_test.py +++ /dev/null @@ -1,62 +0,0 @@ -import unittest - -import os -from helper import UsesQApplication -from PySide.QtGui import * -from PySide.QtCore import * - -class QPixmapTest(UsesQApplication): - def testQVariantConstructor(self): - pixmap = QPixmap() - v = QVariant(pixmap) - pixmap_copy = QPixmap(v) - - def testQSizeConstructor(self): - pixmap = QPixmap(QSize(10,20)) - self.assert_(pixmap.size().height(), 20) - - def testQStringConstructor(self): - pixmap = QPixmap(QString("Testing!")) - - def testQVariantConstructor2(self): - v = QVariant(QPixmap()) - pixmap2 = QPixmap(v) - v = QVariant(QImage()) - pixmap2 = QPixmap(v) - - def testQPixmapLoadFromDataWithQFile(self): - f = QFile(os.path.join(os.path.dirname(__file__), 'sample.png')) - self.assert_(f.open(QIODevice.ReadOnly)) - data = f.read(f.size()) - f.close() - pixmap = QPixmap() - self.assert_(pixmap.loadFromData(data)) - - def testQPixmapLoadFromDataWithPython(self): - data = open(os.path.join(os.path.dirname(__file__),'sample.png'),'rb').read() - pixmap = QPixmap() - self.assert_(pixmap.loadFromData(data)) - - -class QPixmapToImage(UsesQApplication): - - def testFilledImage(self): - '''QPixmap.fill + toImage + image.pixel''' - pixmap = QPixmap(100, 200) - pixmap.fill(Qt.red) # Default Qt.white - - self.assertEqual(pixmap.height(), 200) - self.assertEqual(pixmap.width(), 100) - - image = pixmap.toImage() - - self.assertEqual(image.height(), 200) - self.assertEqual(image.width(), 100) - - pixel = image.pixel(10,10) - self.assertEqual(pixel, QColor(Qt.red).rgba()) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qpushbutton_test.py b/tests/qtgui/qpushbutton_test.py deleted file mode 100644 index 984960879..000000000 --- a/tests/qtgui/qpushbutton_test.py +++ /dev/null @@ -1,30 +0,0 @@ -import unittest - -from helper import UsesQApplication -from PySide.QtGui import QPushButton, QMenu, QWidget -from PySide.QtCore import QTimer - -class MyWidget(QWidget): - def __init__(self): - QWidget.__init__(self) - - m = QMenu(self) - b = QPushButton("Hello", self) - b.setMenu(m) - - -class QPushButtonTest(UsesQApplication): - def createMenu(self, button): - m = QMenu() - button.setMenu(m) - - def testSetMenu(self): - w = MyWidget() - w.show() - - timer = QTimer.singleShot(100, self.app.quit) - self.app.exec_() - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qradialgradient_test.py b/tests/qtgui/qradialgradient_test.py deleted file mode 100644 index 0c582c341..000000000 --- a/tests/qtgui/qradialgradient_test.py +++ /dev/null @@ -1,29 +0,0 @@ -import unittest - -from PySide.QtGui import QRadialGradient -from PySide.QtCore import QPointF - -class QRadialGradientConstructor(unittest.TestCase): - def _compare(self, qptf, tpl): - self.assertEqual((qptf.x(), qptf.y()), tpl) - - def _assertValues(self, grad): - self._compare(grad.center(), (1.0, 2.0)) - self._compare(grad.focalPoint(), (3.0, 4.0)) - self.assertEqual(grad.radius(), 5.0) - - def testAllInt(self): - grad = QRadialGradient(1, 2, 5, 3, 4) - self._assertValues(grad) - - def testQPointF(self): - grad = QRadialGradient(QPointF(1, 2), 5, QPointF(3, 4)) - self._assertValues(grad) - - def testSetQPointF(self): - grad = QRadialGradient() - grad.setCenter(QPointF(1, 2)) - self._compare(grad.center(), (1.0, 2.0)) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qregion_test.py b/tests/qtgui/qregion_test.py deleted file mode 100644 index 2274d5e92..000000000 --- a/tests/qtgui/qregion_test.py +++ /dev/null @@ -1,21 +0,0 @@ -import unittest -import sys - -from PySide.QtGui import QRegion -from PySide.QtCore import QPoint -from helper import UsesQApplication - -class QRegionTest(UsesQApplication): - - def testFunctionUnit(self): - r = QRegion(0, 0, 10, 10) - r2 = QRegion(5, 5, 10, 10) - - ru = r.united(r2) - self.assert_(ru.contains(QPoint(0,0))) - self.assert_(ru.contains(QPoint(5,5))) - self.assert_(ru.contains(QPoint(10,10))) - self.assert_(ru.contains(QPoint(14,14))) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qshortcut_test.py b/tests/qtgui/qshortcut_test.py deleted file mode 100644 index c9cb3bc7c..000000000 --- a/tests/qtgui/qshortcut_test.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- - -''' Test the QShortcut constructor''' - -import unittest -import sys - -from PySide import QtGui, QtCore - -class Foo(QtGui.QWidget): - def __init__(self): - QtGui.QWidget.__init__(self) - self.ok = False - self.copy = False - - def slot_of_foo(self): - self.ok = True - - def slot_of_copy(self): - self.copy = True - -class MyShortcut(QtGui.QShortcut): - def __init__(self, keys, wdg, slot): - QtGui.QShortcut.__init__(self, keys, wdg, slot) - - def emit_signal(self): - self.emit(QtCore.SIGNAL("activated()")) - -class QAppPresence(unittest.TestCase): - - def testQShortcut(self): - self.qapp = QtGui.QApplication([]) - f = Foo() - - self.sc = MyShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return), f, f.slot_of_foo) - self.scstd = MyShortcut(QtGui.QKeySequence.Copy, f, f.slot_of_copy) - QtCore.QTimer.singleShot(0, self.init); - self.qapp.exec_() - self.assertEquals(f.ok, True) - self.assertEquals(f.copy, True) - - def init(self): - self.sc.emit_signal(); - self.scstd.emit_signal(); - self.qapp.quit() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qstandarditemmodel_test.py b/tests/qtgui/qstandarditemmodel_test.py deleted file mode 100644 index d83d856da..000000000 --- a/tests/qtgui/qstandarditemmodel_test.py +++ /dev/null @@ -1,26 +0,0 @@ -import unittest - -from PySide.QtGui import * -from PySide.QtCore import * - -from helper import UsesQApplication - -class QStandardItemModelTest(UsesQApplication): - - def setUp(self): - super(QStandardItemModelTest, self).setUp() - self.window = QWidget() - self.model = QStandardItemModel(0, 3, self.window) - - def tearDown(self): - del self.window - del self.model - super(QStandardItemModelTest, self).tearDown() - - def testInsertRow(self): - # bug #227 - self.model.insertRow(0) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qstring_qkeysequence_test.py b/tests/qtgui/qstring_qkeysequence_test.py deleted file mode 100644 index 1f435e6ee..000000000 --- a/tests/qtgui/qstring_qkeysequence_test.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Tests conversions of QString to and from QKeySequence.''' - -import unittest -from helper import UsesQApplication - -from PySide.QtCore import QString -from PySide.QtGui import QKeySequence, QAction - -class QStringQKeySequenceTest(UsesQApplication): - '''Tests conversions of QString to and from QKeySequence.''' - - def testQStringFromQKeySequence(self): - '''Creates a QString from a QKeySequence.''' - keyseq = 'Ctrl+A' - a = QString(QKeySequence(keyseq)) - self.assertEqual(a, keyseq) - - def testQStringAsQKeySequence(self): - '''Passes a QString to an argument expecting a QKeySequence.''' - keyseq = QString('Ctrl+A') - action = QAction(None) - action.setShortcut(keyseq) - shortcut = action.shortcut() - self.assert_(isinstance(shortcut, QKeySequence)) - self.assertEqual(shortcut.toString(), keyseq) - - def testPythonStringAsQKeySequence(self): - '''Passes a Python string to an argument expecting a QKeySequence.''' - keyseq = 'Ctrl+A' - action = QAction(None) - action.setShortcut(keyseq) - shortcut = action.shortcut() - self.assert_(isinstance(shortcut, QKeySequence)) - self.assertEqual(shortcut.toString(), keyseq) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qstyle_test.py b/tests/qtgui/qstyle_test.py deleted file mode 100755 index da467e871..000000000 --- a/tests/qtgui/qstyle_test.py +++ /dev/null @@ -1,32 +0,0 @@ - -import unittest -from helper import UsesQApplication - -from PySide.QtGui import QWidget, QLabel, QFontComboBox, QStyleFactory - -class SetStyleTest(UsesQApplication): - '''Tests setting the same QStyle for all objects in a UI hierarchy.''' - - def testSetStyle(self): - '''All this test have to do is not break with some invalid Python wrapper.''' - - def setStyleHelper(widget, style): - widget.setStyle(style) - widget.setPalette(style.standardPalette()) - for child in widget.children(): - if isinstance(child, QWidget): - setStyleHelper(child, style) - - container = QWidget() - # QFontComboBox is used because it has an QLineEdit created in C++ inside it, - # and if the QWidget.setStyle(style) steals the ownership of the style - # for the C++ originated widget everything will break. - fontComboBox = QFontComboBox(container) - label = QLabel(container) - label.setText('Label') - style = QStyleFactory.create(QStyleFactory.keys()[0]) - setStyleHelper(container, style) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qtableview_test.py b/tests/qtgui/qtableview_test.py deleted file mode 100644 index 0ea5cab8a..000000000 --- a/tests/qtgui/qtableview_test.py +++ /dev/null @@ -1,17 +0,0 @@ - -import unittest - -from PySide.QtCore import QAbstractTableModel -from PySide.QtGui import QTableWidget -from helper import UsesQApplication - -class QPenTest(UsesQApplication): - - def testItemModel(self): - tv = QTableWidget() - - self.assertEqual(type(tv.model()), QAbstractTableModel) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qtabwidget_test.py b/tests/qtgui/qtabwidget_test.py deleted file mode 100644 index 143f99cab..000000000 --- a/tests/qtgui/qtabwidget_test.py +++ /dev/null @@ -1,21 +0,0 @@ - -import unittest - -from PySide.QtGui import QTabWidget -from helper import TimedQApplication - -class RemoveTabMethod(TimedQApplication): - def setUp(self): - TimedQApplication.setUp(self) - self.tab = QTabWidget() - - def tearDown(self): - del self.tab - TimedQApplication.tearDown(self) - - - def testRemoveTabPresence(self): - self.assert_(getattr(self.tab, 'removeTab')) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qtextedit_test.py b/tests/qtgui/qtextedit_test.py deleted file mode 100644 index 442cbe2cf..000000000 --- a/tests/qtgui/qtextedit_test.py +++ /dev/null @@ -1,32 +0,0 @@ -'''Test cases for QTextEdit and ownership problems.''' - -import unittest -from sys import getrefcount -from PySide.QtGui import QTextEdit - -from helper import UsesQApplication - -class DontTouchReference(UsesQApplication): - '''Check if the QTextTable returned by QTextCursor.insertTable() is not - referenced by the QTextCursor that returns it.''' - - def setUp(self): - super(DontTouchReference, self).setUp() - self.editor = QTextEdit() - self.cursor = self.editor.textCursor() - self.table = self.cursor.insertTable(1, 1) - - def testQTextTable(self): - # methods which return QTextTable should not increment its reference - self.assertEqual(getrefcount(self.table), 2) - f = self.cursor.currentFrame() - del f - self.assertEqual(getrefcount(self.table), 2) - # destroying the cursor should not raise any "RuntimeError: internal - # C++ object already deleted." when accessing the QTextTable - del self.cursor - self.assertEqual(getrefcount(self.table), 2) - cell = self.table.cellAt(0, 0) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/qtgui/qtoolbar_test.py b/tests/qtgui/qtoolbar_test.py deleted file mode 100644 index 1bcf566db..000000000 --- a/tests/qtgui/qtoolbar_test.py +++ /dev/null @@ -1,35 +0,0 @@ - -'''Test cases for QToolbar''' - -import unittest - -from PySide.QtGui import QToolBar, QMainWindow, QAction - -from helper import UsesQApplication - -class AddActionText(UsesQApplication): - '''Test case for calling QToolbar.addAction passing a text''' - - def setUp(self): - #Acquire resources - super(AddActionText, self).setUp() - self.window = QMainWindow() - self.toolbar = QToolBar() - self.window.addToolBar(self.toolbar) - - def tearDown(self): - #Release resources - super(AddActionText, self).tearDown() - del self.toolbar - del self.window - - def testText(self): - #QToolBar.addAction(text) - add a QToolButton - self.toolbar.addAction('aaaa') - self.assertEqual(len(self.toolbar.actions()), 1) - action = self.toolbar.actions()[0] - self.assert_(isinstance(action, QAction)) - self.assertEqual(action.text(), 'aaaa') - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qtoolbox_test.py b/tests/qtgui/qtoolbox_test.py deleted file mode 100644 index dd0d2c6a5..000000000 --- a/tests/qtgui/qtoolbox_test.py +++ /dev/null @@ -1,31 +0,0 @@ - -import unittest - -from PySide.QtGui import QToolBox, QWidget, QIcon - -from helper import UsesQApplication - -class OwnershipControl(UsesQApplication): - - def setUp(self): - super(OwnershipControl, self).setUp() - self.toolbox = QToolBox() - - def tearDown(self): - del self.toolbox - super(OwnershipControl, self).tearDown() - - def testAddItem(self): - # Was losing ownership of the widget. - index = self.toolbox.addItem(QWidget(), 'item') - item = self.toolbox.widget(index) - self.assert_(isinstance(item, QWidget)) - - def testAddItemWithIcon(self): - index = self.toolbox.addItem(QWidget(), QIcon(), 'item') - item = self.toolbox.widget(index) - self.assert_(isinstance(item, QWidget)) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qvariant_test.py b/tests/qtgui/qvariant_test.py deleted file mode 100644 index 138e43291..000000000 --- a/tests/qtgui/qvariant_test.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QVariant with QtGui types''' - -import unittest - -from PySide.QtCore import * -from PySide.QtGui import * - -from helper import UsesQApplication - -class Dummy(object): - pass - -class QVariantTypeName(unittest.TestCase): - def testQPen(self): - obj = QVariant(QPen(Qt.red)) - self.assertEqual('QPen', obj.typeName()) - - def testQColor(self): - obj = QVariant(QColor(Qt.red)) - self.assertEqual('QColor', obj.typeName()) - - def testGlobalColor(self): - obj = QVariant(Qt.red) - # XXX: PyQt4 returns int instead of QColor like the C++ version - self.assertEqual('QColor', obj.typeName()) - - def testEnums(self): - obj = QVariant(Qt.SolidLine) - self.assertEqual('int', obj.typeName()) - -class QVariantQColorImplicitlyConvertion(unittest.TestCase): - def testConversions(self): - c1 = QColor(0, 0, 0) - v = QVariant(c1) - c2 = QColor(v) - self.assertEqual(c1, c2) - -class QVariantQPixmap(UsesQApplication): - '''QVariant(QPixmap)''' - - def testBasic(self): - '''QVariant(QPixmap)''' - pixmap = QPixmap(10,20) - pixmap.fill(Qt.blue) - variant = QVariant(pixmap) - - self.assertEqual(variant.typeName(), "QPixmap") - - def testQObject(self): - obj = QObject() - v = QVariant(obj) - self.assertEqual(v.typeName(), 'QObject*') - - def testQWidget(self): - obj = QWidget() - v = QVariant(obj) - self.assertEqual(v.typeName(), 'QWidget*') - -class MyColor(QColor): - pass - -class MyPrimitive(int): - pass - -class QVariantMess(unittest.TestCase): - def testMyColor(self): - c1 = MyColor() - v = QVariant(c1) - self.assertEqual(type(v.toPyObject()), MyColor) - - def testMyPrimitive(self): - p = MyPrimitive(3) - v = QVariant(p) - self.assertNotEqual(v.type(), QVariant.Int) - self.assertTrue(v.toPyObject() is p) - - def testMatrix2x2(self): - m = QMatrix2x2() - v = QVariant(m) - self.assertEqual('QMatrix2x2', v.typeName()) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/qwidget_setlayout_test.py b/tests/qtgui/qwidget_setlayout_test.py deleted file mode 100644 index c715396ed..000000000 --- a/tests/qtgui/qwidget_setlayout_test.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/python - -import unittest - -from PySide.QtGui import QWidget, QVBoxLayout, QPushButton, QApplication, QHBoxLayout -from helper import UsesQApplication - -class QWidgetTest(UsesQApplication): - - def test_setLayout(self): - layout = QVBoxLayout() - btn1 = QPushButton("button_v1") - layout.addWidget(btn1) - - btn2 = QPushButton("button_v2") - layout.addWidget(btn2) - - layout2 = QHBoxLayout() - - btn1 = QPushButton("button_h1") - layout2.addWidget(btn1) - - btn2 = QPushButton("button_h2") - layout2.addWidget(btn2) - - layout.addLayout(layout2) - - widget = QWidget() - widget.setLayout(layout) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/qwidget_test.py b/tests/qtgui/qwidget_test.py deleted file mode 100644 index a14311c13..000000000 --- a/tests/qtgui/qwidget_test.py +++ /dev/null @@ -1,30 +0,0 @@ - -import unittest - -from PySide.QtGui import QWidget, QMainWindow -from helper import UsesQApplication - -class QWidgetInherit(QMainWindow): - def __init__(self): - QWidget.__init__(self) - -class QWidgetTest(UsesQApplication): - - def testInheritance(self): - newobj = QWidgetInherit() - widget = QWidget() - newobj.setCentralWidget(widget) - self.assertEqual(widget, newobj.centralWidget()) - -class QWidgetVisible(UsesQApplication): - - def testBasic(self): - # Also related to bug #244, on existence of setVisible''' - widget = QWidget() - self.assert_(not widget.isVisible()) - widget.setVisible(True) - self.assert_(widget.isVisible()) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/reference_count_test.py b/tests/qtgui/reference_count_test.py deleted file mode 100644 index b54986821..000000000 --- a/tests/qtgui/reference_count_test.py +++ /dev/null @@ -1,71 +0,0 @@ - -'''Test cases for Reference count when the object is created in c++ side''' - -import unittest - -import sys -import weakref -import gc - - -from PySide.QtCore import Qt, QPointF -from PySide.QtGui import QApplication, QGraphicsScene, QGraphicsRectItem, QPolygonF, QGraphicsPolygonItem, QGraphicsRectItem - -from helper import UsesQApplication - -destroyedRect = False -destroyedPol = False - -def rect_del(o): - global destroyedRect - destroyedRect = True - -def pol_del(o): - global destroyedPol - destroyedPol = True - -class ReferenceCount(UsesQApplication): - - def setUp(self): - super(ReferenceCount, self).setUp() - self.scene = QGraphicsScene() - - def tearDown(self): - super(ReferenceCount, self).tearDown() - - def beforeTest(self): - points = [QPointF(0, 0), QPointF(100, 100), QPointF(0, 100)] - pol = self.scene.addPolygon(QPolygonF(points)) - self.assert_(isinstance(pol, QGraphicsPolygonItem)) - self.wrp = weakref.ref(pol, pol_del) - - #refcount need be 3 because one ref for QGraphicsScene, and one to rect obj - self.assertEqual(sys.getrefcount(pol), 3) - - def testReferenceCount(self): - global destroyedRect - global destroyedPol - - self.beforeTest() - - rect = self.scene.addRect(10.0, 10.0, 10.0, 10.0) - self.assert_(isinstance(rect, QGraphicsRectItem)) - - self.wrr = weakref.ref(rect, rect_del) - - #refcount need be 3 because one ref for QGraphicsScene, and one to rect obj - self.assertEqual(sys.getrefcount(rect), 3) - - del rect - #not destroyed because one ref continue in QGraphicsScene - self.assertEqual(destroyedRect, False) - self.assertEqual(destroyedPol, False) - - del self.scene - - #QGraphicsScene was destroyed and this destroy internal ref to rect - self.assertEqual(destroyedRect, True) - self.assertEqual(destroyedPol, True) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/sample.png b/tests/qtgui/sample.png deleted file mode 100644 index 60450f0dc..000000000 Binary files a/tests/qtgui/sample.png and /dev/null differ diff --git a/tests/qtgui/standardpixmap_test.py b/tests/qtgui/standardpixmap_test.py deleted file mode 100644 index 65bd3220a..000000000 --- a/tests/qtgui/standardpixmap_test.py +++ /dev/null @@ -1,15 +0,0 @@ - -import unittest - -from PySide.QtGui import QPixmap, QStyle - -from helper import UsesQApplication - -class StandardPixmapTest(UsesQApplication): - def testDefaultOptions(self): # Bug 253 - pixmap = self.app.style().standardPixmap(QStyle.SP_DirClosedIcon) - self.assert_(isinstance(pixmap, QPixmap)) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/timed_app_test.py b/tests/qtgui/timed_app_test.py deleted file mode 100644 index 4af9a0130..000000000 --- a/tests/qtgui/timed_app_test.py +++ /dev/null @@ -1,14 +0,0 @@ - -import unittest - -from helper import TimedQApplication - -class TestTimedApp(TimedQApplication): - '''Simple test case for TimedQApplication''' - - def testFoo(self): - #Simple test of TimedQApplication - self.app.exec_() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/virtual_protected_inheritance_test.py b/tests/qtgui/virtual_protected_inheritance_test.py deleted file mode 100644 index 15de37dfb..000000000 --- a/tests/qtgui/virtual_protected_inheritance_test.py +++ /dev/null @@ -1,70 +0,0 @@ - -'''Test cases for overriding inherited protected virtual methods''' - -import unittest - -from PySide.QtCore import QTimerEvent -from PySide.QtGui import QApplication, QSpinBox - -from helper import UsesQApplication - -class MySpinButton(QSpinBox): - '''Simple example class of overriding QObject.timerEvent''' - - def __init__(self, max_runs=5, app=None): - #Creates a new spinbox that will run and quit - super(MySpinButton, self).__init__() - - if app is None: - app = QApplication([]) - - self.app = app - self.max_runs = max_runs - self.runs = 0 - - def timerEvent(self, event): - #Timer event method - self.runs += 1 - - self.setValue(self.runs) - - if self.runs == self.max_runs: - self.app.quit() - - if not isinstance(event, QTimerEvent): - raise TypeError('Invalid event type. Must be TimerEvent') - -class TimerEventTest(UsesQApplication): - '''Test case for running QObject.timerEvent from inherited class''' - - qapplication = True - - def setUp(self): - #Acquire resources - super(TimerEventTest, self).setUp() - self.widget = MySpinButton(app=self.app) - - def tearDown(self): - #Release resources - del self.widget - super(TimerEventTest, self).tearDown() - - def testMethod(self): - #QWidget.timerEvent overrinding (protected inherited) - timer_id = self.widget.startTimer(0) - - self.app.exec_() - - self.widget.killTimer(timer_id) - - self.assertEqual(self.widget.runs, 5) - - -if __name__ == '__main__': - unittest.main() - #app = QApplication([]) - #widget = MySpinButton(app=app) - #widget.startTimer(500) - #widget.show() - #app.exec_() - diff --git a/tests/qtgui/virtual_pure_override.py b/tests/qtgui/virtual_pure_override.py deleted file mode 100644 index c496e4907..000000000 --- a/tests/qtgui/virtual_pure_override.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python - -import unittest - -from PySide.QtGui import QGraphicsScene, QGraphicsRectItem, QGraphicsView, QApplication, QBrush, QColor -from PySide.QtCore import QTimer -from helper import UsesQApplication - -qgraphics_item_painted = False - -class RoundRectItem(QGraphicsRectItem): - - def __init__(self, x, y, w, h): - QGraphicsRectItem.__init__(self, x, y, w, h) - - def paint(self, painter, qstyleoptiongraphicsitem, qwidget): - global qgraphics_item_painted - qgraphics_item_painted = True - - -class QGraphicsItemTest(UsesQApplication): - - def createRoundRect(self, scene): - item = RoundRectItem(10, 10, 100, 100) - item.setBrush(QBrush(QColor(255, 0, 0))) - scene.addItem(item) - return item - - def quit_app(self): - self.app.quit() - - def test_setParentItem(self): - global qgraphics_item_painted - - scene = QGraphicsScene() - scene.addText("test") - view = QGraphicsView(scene) - - rect = self.createRoundRect(scene) - view.show() - QTimer.singleShot(1000, self.quit_app) - self.app.exec_() - self.assert_(qgraphics_item_painted) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtgui/wrong_return_test.py b/tests/qtgui/wrong_return_test.py deleted file mode 100644 index d14ac9e98..000000000 --- a/tests/qtgui/wrong_return_test.py +++ /dev/null @@ -1,23 +0,0 @@ -'''Test cases for Virtual functions with wrong return type''' - -import unittest - -from PySide import QtCore, QtGui - -from helper import UsesQApplication - -class MyWidget(QtGui.QWidget): - def __init__(self, parent=None): - super(MyWidget, self).__init__(parent) - - def sizeHint(self): - pass - -class testCase(UsesQApplication): - - def testVirtualReturn(self): - w = MyWidget() - self.assertRaises(TypeError, w.show) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtgui/x11_symbols.py b/tests/qtgui/x11_symbols.py deleted file mode 100644 index 29cce150e..000000000 --- a/tests/qtgui/x11_symbols.py +++ /dev/null @@ -1,17 +0,0 @@ - -''' Test the presence of X11 symbols in QtGui''' - -import unittest - -from PySide.QtGui import QPixmap - -class X11Test(unittest.TestCase): - - def test(self): - self.assert_('handle' in dir(QPixmap)) - self.assert_('x11Info' in dir(QPixmap)) - self.assert_('x11PictureHandle' in dir(QPixmap)) - self.assert_('x11SetDefaultScreen' in dir(QPixmap)) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qthelp/help_test.py b/tests/qthelp/help_test.py deleted file mode 100644 index e2ff532a6..000000000 --- a/tests/qthelp/help_test.py +++ /dev/null @@ -1,14 +0,0 @@ - -import unittest - -from PySide.QtHelp import QHelpEngine - -from helper import UsesQApplication - -class QHelpEngineCreation(UsesQApplication): - - def testConstructor(self): - helpEngine = QHelpEngine('mycollection.qch') - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtmaemo5/pickselector_test.py b/tests/qtmaemo5/pickselector_test.py deleted file mode 100644 index 013c1d40b..000000000 --- a/tests/qtmaemo5/pickselector_test.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide.QtMaemo5 import QMaemo5ListPickSelector, QMaemo5ValueButton - -from helper import UsesQApplication - -class PickSelectorTest(UsesQApplication): - def testOwnership(self): - pickselector = QMaemo5ListPickSelector() - button = QMaemo5ValueButton("test") - button.setPickSelector(pickselector) - del pickselector - self.assert_(button.pickSelector()) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtmaemo5/qmaemo5import_test.py b/tests/qtmaemo5/qmaemo5import_test.py deleted file mode 100644 index a003f056a..000000000 --- a/tests/qtmaemo5/qmaemo5import_test.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide.QtMaemo5 import * -from PySide import QtGui - -from helper import UsesQApplication - -class QtMamo5Test(UsesQApplication): - - def testObjectCreate(self): - bar = QMaemo5EditBar() - self.assert_(isinstance(bar, QMaemo5EditBar)) - - def testGui(self): - getattr(QtGui, 'QAbstractKineticScroller') - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtmultimedia/audio_test.py b/tests/qtmultimedia/audio_test.py deleted file mode 100644 index 04d0a1e05..000000000 --- a/tests/qtmultimedia/audio_test.py +++ /dev/null @@ -1,32 +0,0 @@ - -'''Test cases for QHttp''' - -import unittest - -from PySide.QtCore import * -from PySide.QtMultimedia import * - -class testAudioDevices(unittest.TestCase): - - def testListDevices(self): - for devInfo in QAudioDeviceInfo.availableDevices(QAudio.AudioOutput): - fmt = QAudioFormat() - for codec in devInfo.supportedCodecs(): - fmt.setCodec(codec) - for frequency in devInfo.supportedFrequencies(): - fmt.setFrequency(frequency) - for channels in devInfo.supportedChannels(): - fmt.setChannels(channels) - for sampleType in devInfo.supportedSampleTypes(): - fmt.setSampleType(sampleType) - for sampleSize in devInfo.supportedSampleSizes(): - fmt.setSampleSize(sampleSize) - for endian in devInfo.supportedByteOrders(): - fmt.setByteOrder(endian) - if devInfo.isFormatSupported(fmt): - return - self.assert_(False) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtnetwork/accessManager_test.py b/tests/qtnetwork/accessManager_test.py deleted file mode 100644 index 9a00e7e79..000000000 --- a/tests/qtnetwork/accessManager_test.py +++ /dev/null @@ -1,23 +0,0 @@ - -'''Test cases for QHttp''' - -import unittest - -from PySide.QtCore import * -from PySide.QtNetwork import * - -from helper import UsesQApplication - -class AccessManagerCase(UsesQApplication): - def slot_replyFinished(self, reply): - self.assertEqual(type(reply), QNetworkReply) - self.app.quit() - - def testNetworkRequest(self): - manager = QNetworkAccessManager() - manager.finished.connect(self.slot_replyFinished) - manager.get(QNetworkRequest(QUrl("http://qt.nokia.com"))) - self.app.exec_() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtnetwork/http_test.py b/tests/qtnetwork/http_test.py deleted file mode 100644 index 379ff5dfb..000000000 --- a/tests/qtnetwork/http_test.py +++ /dev/null @@ -1,67 +0,0 @@ - -'''Test cases for QHttp''' - -import unittest - -from PySide.QtCore import * -from PySide.QtNetwork import * - -from helper import UsesQApplication - -""" -class HttpSignalsCase(UsesQApplication): - '''Test case for launching QHttp signals''' - - def setUp(self): - super(HttpSignalsCase, self).setUp() - - self.http = QHttp() - self.url = QUrl('http://www.google.com') - self.timer = QTimer.singleShot(250, self.app.quit) - - def tearDown(self): - del self.http - super(HttpSignalsCase, self).tearDown() - - def callback(self, ident): - self.called = True - - def testDefaultArgs(self): - #QHttp signal requestStarted signal - # @bug 114 - QObject.connect(self.http, SIGNAL('requestStarted(int)'), self.callback) - self.http.get(self.url.path()) - - self.app.exec_() - self.assert_(self.called) - -class testHttp(UsesQApplication): - def testRead(self): - header = QHttpRequestHeader("GET", QString(QUrl.toPercentEncoding("/index.html"))) - header.setValue("Host", "qtsoftware.com"); - http = QHttp() - http.setHost("qtsoftware.com") - http.request(header) - data = http.read(100) -""" - -class testAuthenticationSignal(UsesQApplication): - def onAuthRequest(self, hostname, port, auth): - self.assert_(isinstance(auth, QAuthenticator)) - print auth.realm() - self._resultOk = True - self.app.exit() - - def testwaitSignal(self): - self._resultOk = False - http = QHttp() - http.setHost("projects.maemo.org", QHttp.ConnectionModeHttps, 0) - http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest) - path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/") - print http.get(path) - self.app.exec_() - self.assert_(self._resultOk) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtnetwork/tcpserver_test.py b/tests/qtnetwork/tcpserver_test.py deleted file mode 100644 index 77f830e36..000000000 --- a/tests/qtnetwork/tcpserver_test.py +++ /dev/null @@ -1,25 +0,0 @@ - -'''Test cases for QTCPServer''' - -import unittest - -from PySide.QtNetwork import QTcpServer - -class ListenDefaultArgsCase(unittest.TestCase): - '''Test case for TcpServer.listen with default args''' - - def setUp(self): - #Acquire resources - self.server = QTcpServer() - - def tearDown(self): - #Release resources - del self.server - - def testDefaultArgs(self): - # @bug 108 - #Default arguments for QTcpServer.listen - self.server.listen() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtnetwork/udpsocket_test.py b/tests/qtnetwork/udpsocket_test.py deleted file mode 100644 index 26cff7f65..000000000 --- a/tests/qtnetwork/udpsocket_test.py +++ /dev/null @@ -1,54 +0,0 @@ - -'''Test cases for QUdpSocket''' - -import unittest - -from PySide.QtCore import QUrl, QObject, SIGNAL, QCoreApplication, QTimer -from PySide.QtNetwork import QUdpSocket, QHostAddress - -class HttpSignalsCase(unittest.TestCase): - '''Test case for bug #124 - readDatagram signature - - QUdpSocket.readDatagram must return a tuple with the datagram, host and - port, while receiving only the max payload size.''' - - def setUp(self): - #Acquire resources - self.app = QCoreApplication([]) - self.socket = QUdpSocket() - self.socket.bind(45454) - self.server = QUdpSocket() - self.timer = QTimer.singleShot(1000, self.app.quit) - self.a = QTimer.singleShot(100, self.broadcast) - #self.a = QTimer() - #self.a.setInterval(100) - #QObject.connect(self.a, SIGNAL('timeout()'), self.broadcast) - #self.a.start() - - def tearDown(self): - #Release resources - del self.socket - del self.server - del self.app - - def broadcast(self): - addr = QHostAddress(QHostAddress.Broadcast) - self.server.writeDatagram('datagram', addr, 45454) - - def callback(self): - while self.socket.hasPendingDatagrams(): - datagram, host, port = self.socket.readDatagram( - self.socket.pendingDatagramSize()) - self.called = True - self.app.quit() - - def testDefaultArgs(self): - #QUdpSocket.readDatagram pythonic return - # @bug 124 - QObject.connect(self.socket, SIGNAL('readyRead()'), self.callback) - self.app.exec_() - - self.assert_(self.called) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtopengl/qglbuffer_test.py b/tests/qtopengl/qglbuffer_test.py deleted file mode 100644 index ae23fbdf3..000000000 --- a/tests/qtopengl/qglbuffer_test.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python -'''Unit tests for QGLBuffer''' - -import unittest - -from PySide.QtCore import QByteArray -from PySide.QtOpenGL import QGLBuffer, QGLWidget - -from helper import UsesQApplication - -class QGLBufferTest(UsesQApplication): - def usageCheck(self, t): - w = QGLWidget() - w.makeCurrent() - - b = QGLBuffer(t) - self.assertEqual(b.usagePattern(), QGLBuffer.StaticDraw) - b.setUsagePattern(QGLBuffer.DynamicDraw) - - self.assert_(b.create()) - self.assert_(b.bufferId() != 0) - self.assert_(b.bind()) - - data = QByteArray("12345") - b.allocate(data) - self.assertEqual(b.size(), data.size()) - - m = b.map(QGLBuffer.ReadOnly) - self.assertEqual(m.data(), data.data()) - b.unmap() - - other_data = QByteArray("67") - b.write(0, other_data) - m = b.map(QGLBuffer.ReadOnly) - self.assertEqual(m.mid(0, other_data.size()).data(), other_data.data()) - b.unmap() - - result, rdata = b.read(0, other_data.size()) - print result, rdata - self.assert_(result) - self.assertEqual(other_data.data(), rdata.data()) - - b.release() - - def testUsage(self): - self.usageCheck(QGLBuffer.IndexBuffer) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtscript/base_test.py b/tests/qtscript/base_test.py deleted file mode 100644 index 6ad27e007..000000000 --- a/tests/qtscript/base_test.py +++ /dev/null @@ -1,4 +0,0 @@ -from PySide import QtScript - - -#only test if the module import works fine bug #278 diff --git a/tests/qtscript/engine_test.py b/tests/qtscript/engine_test.py deleted file mode 100644 index 074d3df40..000000000 --- a/tests/qtscript/engine_test.py +++ /dev/null @@ -1,13 +0,0 @@ -import unittest - -from PySide.QtCore import QObject -from PySide.QtScript import QScriptEngine - -class QScriptEngineTest(unittest.TestCase): - - def testQScriptEngine(self): - engine = QScriptEngine() - obj = engine.evaluate("({ unitName: 'Celsius', toKelvin: function(x) { return x + 273; } })") - toKelvin = obj.property("toKelvin") - result = toKelvin.call(obj, [100]) - self.assertEqual(result.toNumber(), 373) diff --git a/tests/qtscript/test_base.py b/tests/qtscript/test_base.py deleted file mode 100644 index 6ad27e007..000000000 --- a/tests/qtscript/test_base.py +++ /dev/null @@ -1,4 +0,0 @@ -from PySide import QtScript - - -#only test if the module import works fine bug #278 diff --git a/tests/qtscripttools/debugger_test.py b/tests/qtscripttools/debugger_test.py deleted file mode 100644 index e5253610a..000000000 --- a/tests/qtscripttools/debugger_test.py +++ /dev/null @@ -1,41 +0,0 @@ - -import unittest - -from PySide.QtCore import SIGNAL -from PySide.QtScript import QScriptEngine -from PySide.QtScriptTools import QScriptEngineDebugger - -from helper import UsesQApplication - -class DebuggerTest(UsesQApplication): - - def setUp(self): - UsesQApplication.setUp(self) - self.engine = QScriptEngine() - self.debugger = QScriptEngineDebugger() - self.has_suspended = False - self.has_resumed = False - - def suspended(self): - self.has_suspended = True - self.debugger.action(QScriptEngineDebugger.ContinueAction).trigger() - - def resumed(self): - self.has_resumed = True - - def testBasic(self): - '''Interrupt and resume evaluation with QScriptEngineDebugger''' - self.debugger.attachTo(self.engine) - self.debugger.setAutoShowStandardWindow(False) - self.debugger.connect(SIGNAL('evaluationSuspended()'), self.suspended) - self.debugger.connect(SIGNAL('evaluationResumed()'), self.resumed) - - self.debugger.action(QScriptEngineDebugger.InterruptAction).trigger() - self.engine.evaluate("3+4") - self.debugger.action(QScriptEngineDebugger.ContinueAction).trigger() - self.assert_(self.has_resumed) - self.assert_(self.has_suspended) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtsql/qsqldatabaseandqueries_test.py b/tests/qtsql/qsqldatabaseandqueries_test.py deleted file mode 100755 index 49f220937..000000000 --- a/tests/qtsql/qsqldatabaseandqueries_test.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python -'''Test cases for QtSql database creation, destruction and queries''' - -import sys -import unittest - -from PySide import QtSql -from PySide.QtCore import QVariant, QString - -class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase): - '''Test cases for QtSql database creation, destruction and queries''' - - def setUp(self): - #Acquire resources - self.assertFalse(QtSql.QSqlDatabase.drivers().isEmpty(), "installed Qt has no DB drivers") - self.assertTrue("QSQLITE" in QtSql.QSqlDatabase.drivers(), "\"QSQLITE\" driver not available in this Qt version") - self.db = QtSql.QSqlDatabase.addDatabase("QSQLITE") - self.db.setDatabaseName(":memory:") - self.assertTrue(self.db.open()) - - def tearDown(self): - #Release resources - self.db.close() - QtSql.QSqlDatabase.removeDatabase(":memory:") - del self.db - - def testTableCreationAndDestruction(self): - #Test table creation and destruction - query = QtSql.QSqlQuery() - query.exec_("CREATE TABLE dummy(id int primary key, dummyfield varchar(20))") - query.exec_("DROP TABLE dummy") - query.clear() - - def testTableInsertionAndRetrieval(self): - #Test table creation, insertion and retrieval - query = QtSql.QSqlQuery() - query.exec_("CREATE TABLE person(id int primary key, " - "firstname varchar(20), lastname varchar(20))") - query.exec_("INSERT INTO person VALUES(101, 'George', 'Harrison')") - query.prepare("INSERT INTO person (id, firstname, lastname) " - "VALUES (:id, :firstname, :lastname)") - query.bindValue(":id", QVariant(102)) - query.bindValue(":firstname", QVariant("John")) - query.bindValue(":lastname", QVariant("Lennon")) - query.exec_() - - lastname = '' - query.exec_("SELECT lastname FROM person where id=101") - self.assertTrue(query.isActive()) - query.next() - lastname = query.value(0).toString() - self.assertEqual(lastname, 'Harrison') - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtsvg/qsvggenerator_test.py b/tests/qtsvg/qsvggenerator_test.py deleted file mode 100644 index cec7fdaff..000000000 --- a/tests/qtsvg/qsvggenerator_test.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python -import unittest -from sys import getrefcount -from PySide.QtCore import QBuffer -from PySide.QtSvg import QSvgGenerator - -class QSvgGeneratorTest(unittest.TestCase): - - def testRefCountOfTOutputDevice(self): - generator = QSvgGenerator() - iodevice1 = QBuffer() - refcount1 = getrefcount(iodevice1) - - generator.setOutputDevice(iodevice1) - - self.assertEqual(generator.outputDevice(), iodevice1) - self.assertEqual(getrefcount(generator.outputDevice()), refcount1 + 1) - - iodevice2 = QBuffer() - refcount2 = getrefcount(iodevice2) - - generator.setOutputDevice(iodevice2) - - self.assertEqual(generator.outputDevice(), iodevice2) - self.assertEqual(getrefcount(generator.outputDevice()), refcount2 + 1) - self.assertEqual(getrefcount(iodevice1), refcount1) - - del generator - - self.assertEqual(getrefcount(iodevice2), refcount2) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qttest/click_test.py b/tests/qttest/click_test.py deleted file mode 100644 index e295cee68..000000000 --- a/tests/qttest/click_test.py +++ /dev/null @@ -1,28 +0,0 @@ - -'''QtTest mouse click functionalities''' - -import unittest - -from PySide.QtCore import Qt, QObject -from PySide.QtGui import QPushButton, QLineEdit -from PySide.QtTest import QTest - -from helper import UsesQApplication - -class MouseClickTest(UsesQApplication): - - def testBasic(self): - '''QTest.mouseClick with QCheckBox''' - button = QPushButton() - button.setCheckable(True) - button.setChecked(False) - - QTest.mouseClick(button, Qt.LeftButton) - self.assert_(button.isChecked()) - - QTest.mouseClick(button, Qt.LeftButton) - self.assertFalse(button.isChecked()) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qttest/eventfilter_test.py b/tests/qttest/eventfilter_test.py deleted file mode 100644 index 382460ee7..000000000 --- a/tests/qttest/eventfilter_test.py +++ /dev/null @@ -1,47 +0,0 @@ - -'''Tests for QKeyEvent''' - -import unittest - -from PySide.QtCore import * -from PySide.QtGui import * -from PySide.QtTest import QTest - -from helper import UsesQApplication - - -class KeyEventFilter(QObject): - - def __init__(self, widget, eventType, key): - QObject.__init__(self) - - self.widget = widget - self.eventType = eventType - self.key = key - - self.processed = False - - def eventFilter(self, obj, event): - if self.widget == obj and event.type() == self.eventType and \ - isinstance(event, QKeyEvent) and event.key() == self.key: - self.processed = True - return True - - return False - -class EventFilterTest(UsesQApplication): - - def testKeyEvent(self): - widget = QLineEdit() - key = Qt.Key_A - eventFilter = KeyEventFilter(widget, QEvent.KeyPress, key) - widget.installEventFilter(eventFilter) - - QTest.keyClick(widget, key) - - self.assert_(eventFilter.processed) - - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtuitools/test.ui b/tests/qtuitools/test.ui deleted file mode 100644 index 60afe22b3..000000000 --- a/tests/qtuitools/test.ui +++ /dev/null @@ -1,48 +0,0 @@ - - - Form - - - - 0 - 0 - 185 - 133 - - - - Form - - - - - 0 - 0 - 181 - 131 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 50 - 60 - 80 - 25 - - - - PushButton - - - - - - - diff --git a/tests/qtuitools/ui_test.py b/tests/qtuitools/ui_test.py deleted file mode 100644 index 6f599cefb..000000000 --- a/tests/qtuitools/ui_test.py +++ /dev/null @@ -1,14 +0,0 @@ - -import unittest - -from PySide.QtUiTools import QUiLoader - -from helper import UsesQApplication - -class QUiLoaderCreation(UsesQApplication): - - def testConstructor(self): - loader = QUiLoader() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtuitools/uiloader_test.py b/tests/qtuitools/uiloader_test.py deleted file mode 100644 index fe3725ba1..000000000 --- a/tests/qtuitools/uiloader_test.py +++ /dev/null @@ -1,30 +0,0 @@ -import unittest -import os -from helper import UsesQApplication - -from PySide.QtGui import * -from PySide.QtUiTools import * - -def get_file_path(): - for path in file_path: - if os.path.exists(path): - return path - return "" - -class QUioaderTeste(UsesQApplication): - def testLoadFile(self): - filePath = os.path.join(os.path.dirname(__file__), 'test.ui') - loader = QUiLoader() - parent = QWidget() - w = loader.load(filePath, parent) - self.assertNotEqual(w, None) - - self.assertEqual(len(parent.children()), 1) - - child = w.findChild(QWidget, "child_object") - self.assertNotEqual(child, None) - self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object")) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtwebkit/fox.html b/tests/qtwebkit/fox.html deleted file mode 100644 index e7691eb66..000000000 --- a/tests/qtwebkit/fox.html +++ /dev/null @@ -1,6 +0,0 @@ - -Title - -

The quick brown fox jumps over the lazy dog.

- - diff --git a/tests/qtwebkit/webpage_test.py b/tests/qtwebkit/webpage_test.py deleted file mode 100644 index 20796971f..000000000 --- a/tests/qtwebkit/webpage_test.py +++ /dev/null @@ -1,61 +0,0 @@ - -'''Test cases for QWebPage''' - -import unittest - -from PySide.QtCore import QObject, SIGNAL, QUrl -from PySide.QtWebKit import QWebPage -from PySide.QtNetwork import QNetworkAccessManager - -from helper import adjust_filename, TimedQApplication - -#Define a global timeout because TimedQApplication uses a singleton! -#Use a value big enough to run all the tests. -TIMEOUT = 1000 - -class TestFindText(TimedQApplication): - '''Test cases for finding text''' - - def setUp(self): - TimedQApplication.setUp(self, timeout=TIMEOUT) - self.page = QWebPage() - QObject.connect(self.page, SIGNAL('loadFinished(bool)'), - self.load_finished) - self.called = False - - def tearDown(self): - #Release resources - del self.page - self.called = False - TimedQApplication.tearDown(self) - - def testFindSelectText(self): - url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) - self.page.mainFrame().load(url) - self.app.exec_() - self.assert_(self.called) - - def load_finished(self, ok): - #Callback to check if load was successful - if ok: - self.called = True - self.assert_(self.page.findText('fox')) - self.assertEqual(self.page.selectedText(), 'fox') - self.app.quit() - -class SetNetworkAccessManagerCase(TimedQApplication): - - def setUp(self): - TimedQApplication.setUp(self, timeout=TIMEOUT) - - def testSetNetworkAccessManager(self): - page = QWebPage() - manager = QNetworkAccessManager() - page.setNetworkAccessManager(manager) - - def testNetWorkAccessManager(self): - page = QWebPage() - a = page.networkAccessManager() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtwebkit/webview_test.py b/tests/qtwebkit/webview_test.py deleted file mode 100644 index c06e437c3..000000000 --- a/tests/qtwebkit/webview_test.py +++ /dev/null @@ -1,43 +0,0 @@ - -'''Test cases for QWebView''' - -import unittest - -from PySide.QtCore import QObject, SIGNAL, QUrl -from PySide.QtWebKit import QWebView - -from helper import adjust_filename, TimedQApplication - - -class TestLoadFinished(TimedQApplication): - '''Test case for signal QWebView.loadFinished(bool)''' - - def setUp(self): - #Acquire resources - TimedQApplication.setUp(self, timeout=1000) - self.view = QWebView() - QObject.connect(self.view, SIGNAL('loadFinished(bool)'), - self.load_finished) - self.called = False - - def tearDown(self): - #Release resources - del self.view - self.called = False - TimedQApplication.tearDown(self) - - def testLoadFinishedFromFile(self): - url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) - self.view.setUrl(url) - self.app.exec_() - - self.assert_(self.called) - - def load_finished(self, ok): - #Callback to check if load was successful - self.app.quit() - if ok: - self.called = True - -if __name__ == '__main__': - unittest.main() diff --git a/tests/qtxml/qdomdocument_test.py b/tests/qtxml/qdomdocument_test.py deleted file mode 100644 index 86aece7ba..000000000 --- a/tests/qtxml/qdomdocument_test.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide.QtCore import QByteArray -from PySide.QtXml import QDomDocument, QDomElement - -class QDomDocumentTest(unittest.TestCase): - - def setUp(self): - self.dom = QDomDocument() - - self.goodXmlData = QByteArray(''' - - - - - ''') - - self.badXmlData = QByteArray(''' - - - - ''') - - def tearDown(self): - del self.dom - del self.goodXmlData - del self.badXmlData - - def testQDomDocumentSetContentWithBadXmlData(self): - '''Sets invalid xml as the QDomDocument contents.''' - ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.badXmlData, True) - self.assertFalse(ok) - self.assertEqual(errorStr, 'tag mismatch') - self.assertEqual(errorLine, 4) - self.assertEqual(errorColumn, 21) - - def testQDomDocumentSetContentWithGoodXmlData(self): - '''Sets valid xml as the QDomDocument contents.''' - ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.goodXmlData, True) - self.assert_(ok) - self.assertEqual(errorStr, '') - self.assertEqual(errorLine, 0) - self.assertEqual(errorColumn, 0) - - def testQDomDocumentData(self): - '''Checks the QDomDocument elements for the valid xml contents.''' - - def checkAttribute(element, attribute, value): - self.assert_(isinstance(root, QDomElement)) - self.assertFalse(element.isNull()) - self.assert_(element.hasAttribute(attribute)) - self.assertEqual(element.attribute(attribute), value) - - ok, errorStr, errorLine, errorColumn = self.dom.setContent(self.goodXmlData, True) - root = self.dom.documentElement() - self.assertEqual(root.tagName(), 'typesystem') - checkAttribute(root, 'package', 'PySide.QtXml') - - child = root.firstChildElement('value-type') - checkAttribute(child, 'name', 'QDomDocument') - - child = child.nextSiblingElement('value-type') - checkAttribute(child, 'name', 'QDomElement') - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtxml/qxmlsimplereader_test.py b/tests/qtxml/qxmlsimplereader_test.py deleted file mode 100644 index 6c4d3f4ea..000000000 --- a/tests/qtxml/qxmlsimplereader_test.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python -import unittest -from PySide.QtXml import QXmlSimpleReader - -class QXmlSimpleReaderTest(unittest.TestCase): - - def testQXmlSimpleReaderInstatiation(self): - '''QXmlSimpleReader must be a concrete class not an abstract one.''' - reader = QXmlSimpleReader() - - def testQXmlSimpleReaderFeatures(self): - '''Calls the QXmlSimpleReader.features method. The features checked - (at least the first two) can be found in the QXmlSimpleReader documentation: - http://qt.nokia.com/doc/4.6/qxmlsimplereader.html#setFeature - ''' - reader = QXmlSimpleReader() - hasFeature, ok = reader.feature('http://xml.org/sax/features/namespaces') - self.assertEqual((hasFeature, ok), (True, True)) - - hasFeature, ok = reader.feature('http://xml.org/sax/features/namespace-prefixes') - self.assertEqual((hasFeature, ok), (False, True)) - - hasFeature, ok = reader.feature('foobar') - self.assertEqual((hasFeature, ok), (False, False)) - - def testQXmlSimpleReaderProperty(self): - '''Tries to get a non existent property.''' - reader = QXmlSimpleReader() - prop, ok = reader.property('foo') - self.assertEqual((prop, ok), (None, False)) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/qtxmlpatterns/import_test.py b/tests/qtxmlpatterns/import_test.py deleted file mode 100644 index 5bab9755c..000000000 --- a/tests/qtxmlpatterns/import_test.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python - -import unittest -from PySide.QtCore import * -from PySide.QtXmlPatterns import QXmlSchema -from helper import UsesQCoreApplication - -class QXmlPatternsTest(UsesQCoreApplication): - - def testSchema(self): - data = QByteArray(''' - - ''') - - buf = QBuffer(data) - buf.open(QIODevice.ReadOnly) - - schema = QXmlSchema() - schema.load(buf) - self.assert_(schema.isValid()) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/run_test.sh b/tests/run_test.sh index 8671ce350..363fae57b 100755 --- a/tests/run_test.sh +++ b/tests/run_test.sh @@ -1,13 +1,13 @@ -#!/usr/bin/python +#!/bin/sh # This is a nasty workaround of a CTest limitation # of setting the environment variables for the test. # $1: LD_LIBRARY_PATH -# $2: $PYTHON_PATH +# $2: $PYTHONPATH # $3: python executable # $4: test file -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$1 -export PYTHONPATH=$PYTHONPATH:$2 +export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH +export PYTHONPATH=$2:$PYTHONPATH $3 $4 diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt new file mode 100644 index 000000000..3e5968449 --- /dev/null +++ b/tests/signals/CMakeLists.txt @@ -0,0 +1,32 @@ +PYSIDE_TEST(args_dont_match_test.py) +PYSIDE_TEST(decorators_test.py) +PYSIDE_TEST(invalid_callback_test.py) +PYSIDE_TEST(lambda_gui_test.py) +PYSIDE_TEST(lambda_test.py) +PYSIDE_TEST(multiple_connections_gui_test.py) +PYSIDE_TEST(multiple_connections_test.py) +PYSIDE_TEST(pysignal_test.py) +PYSIDE_TEST(qobject_destroyed_test.py) +PYSIDE_TEST(qobject_receivers_test.py) +PYSIDE_TEST(qobject_sender_test.py) +PYSIDE_TEST(ref01_test.py) +PYSIDE_TEST(ref02_test.py) +PYSIDE_TEST(ref03_test.py) +PYSIDE_TEST(ref04_test.py) +PYSIDE_TEST(ref05_test.py) +PYSIDE_TEST(ref06_test.py) +PYSIDE_TEST(segfault_proxyparent_test.py) +PYSIDE_TEST(self_connect_test.py) +PYSIDE_TEST(short_circuit_test.py) +PYSIDE_TEST(signal2signal_connect_test.py) +PYSIDE_TEST(signal_autoconnect_test.py) +PYSIDE_TEST(signal_connectiontype_support.py) +PYSIDE_TEST(signal_emission_gui_test.py) +PYSIDE_TEST(signal_emission_test.py) +PYSIDE_TEST(signal_func_test.py) +PYSIDE_TEST(signal_manager_refcount_test.py) +PYSIDE_TEST(signal_object_test.py) +PYSIDE_TEST(signal_with_primitive_type_test.py) +PYSIDE_TEST(slot_reference_count_test.py) +PYSIDE_TEST(static_metaobject_test.py) +PYSIDE_TEST(upstream_segfault_test.py) diff --git a/tests/signals/args_dont_match_test.py b/tests/signals/args_dont_match_test.py old mode 100644 new mode 100755 index b81c5682c..25211671c --- a/tests/signals/args_dont_match_test.py +++ b/tests/signals/args_dont_match_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python import unittest from PySide.QtCore import * diff --git a/tests/signals/decorators_test.py b/tests/signals/decorators_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/invalid_callback_test.py b/tests/signals/invalid_callback_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/lambda_gui_test.py b/tests/signals/lambda_gui_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/lambda_test.py b/tests/signals/lambda_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/multiple_connections_gui_test.py b/tests/signals/multiple_connections_gui_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/multiple_connections_test.py b/tests/signals/multiple_connections_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/pysignal_test.py b/tests/signals/pysignal_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/qobject_destroyed_test.py b/tests/signals/qobject_destroyed_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/qobject_receivers_test.py b/tests/signals/qobject_receivers_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/segfault_proxyparent_test.py b/tests/signals/segfault_proxyparent_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/self_connect_test.py b/tests/signals/self_connect_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/short_circuit_test.py b/tests/signals/short_circuit_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal2signal_connect_test.py b/tests/signals/signal2signal_connect_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_autoconnect_test.py b/tests/signals/signal_autoconnect_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_connectiontype_support.py b/tests/signals/signal_connectiontype_support.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_emission_gui_test.py b/tests/signals/signal_emission_gui_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_emission_test.py b/tests/signals/signal_emission_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_func_test.py b/tests/signals/signal_func_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_manager_refcount_test.py b/tests/signals/signal_manager_refcount_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_object_test.py b/tests/signals/signal_object_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_with_primitive_type_test.py b/tests/signals/signal_with_primitive_type_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/slot_reference_count_test.py b/tests/signals/slot_reference_count_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/static_metaobject_test.py b/tests/signals/static_metaobject_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/upstream_segfault_test.py b/tests/signals/upstream_segfault_test.py old mode 100644 new mode 100755 -- cgit v1.2.3