diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | debian/changelog | 29 | ||||
-rw-r--r-- | debian/control | 6 | ||||
-rw-r--r-- | libqmenumodel/QMenuModel/CMakeLists.txt | 6 | ||||
-rw-r--r-- | libqmenumodel/src/converter.cpp | 194 | ||||
-rw-r--r-- | libqmenumodel/src/converter.h | 2 | ||||
-rw-r--r-- | libqmenumodel/src/logging.h | 23 | ||||
-rw-r--r-- | libqmenumodel/src/qdbusobject.cpp | 1 | ||||
-rw-r--r-- | libqmenumodel/src/qstateaction.cpp | 20 | ||||
-rw-r--r-- | libqmenumodel/src/qstateaction.h | 2 | ||||
-rw-r--r-- | libqmenumodel/src/unitymenumodel.cpp | 25 | ||||
-rw-r--r-- | libqmenumodel/src/unitymenumodel.h | 2 | ||||
-rw-r--r-- | tests/client/actiongrouptest.cpp | 99 | ||||
-rw-r--r-- | tests/client/cachetest.cpp | 5 | ||||
-rw-r--r-- | tests/client/convertertest.cpp | 307 | ||||
-rw-r--r-- | tests/client/modelsignalstest.cpp | 5 | ||||
-rw-r--r-- | tests/client/treetest.cpp | 5 |
17 files changed, 540 insertions, 194 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 95440ca..0aef573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32) pkg_check_modules(GIO REQUIRED gio-2.0>=2.32) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) +SET(CMAKE_CXX_FLAGS "-std=c++11") add_definitions(-DQT_NO_KEYWORDS) find_program(DBUS_RUNNER dbus-test-runner) @@ -26,7 +27,7 @@ if(ENABLE_COVERAGE) message(FATAL_ERROR "gcov command not found") endif() SET(CMAKE_C_FLAGS "-g -O0 -Wall --coverage") - SET(CMAKE_CXX_FLAGS "-g -O0 -Wall --coverage") + SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -std=c++11 --coverage") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") include(${CMAKE_SOURCE_DIR}/cmake/lcov.cmake) endif() diff --git a/debian/changelog b/debian/changelog index 6de620f..ae0f717 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,19 @@ +qmenumodel (0.2.10+17.04.20161116-0ubuntu1) zesty; urgency=medium + + [ Florian Boucault ] + * Crossbuilding fixes. + + [ Marco Trevisan (Treviño) ] + * converter: cleanup and add support for more variant types + + -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 16 Nov 2016 10:42:17 +0000 + +qmenumodel (0.2.10+17.04.20161026.2-0ubuntu1) zesty; urgency=medium + + * Add ability to activate or change state of an action by variant string + + -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 26 Oct 2016 17:28:36 +0000 + qmenumodel (0.2.10) UNRELEASED; urgency=medium [ Nick Dedekind ] @@ -5,6 +21,19 @@ qmenumodel (0.2.10) UNRELEASED; urgency=medium -- Nick Dedekind <nick.dedekind@canonical.com> Tue, 04 Oct 2016 14:11:46 +0100 +qmenumodel (0.2.9+16.04.20160329-0ubuntu1) xenial; urgency=medium + + [ Nick Dedekind ] + * Use Qt logging categories (LP: #1562992) + + -- Michał Sawicz <michal.sawicz@canonical.com> Tue, 29 Mar 2016 12:57:00 +0000 + +qmenumodel (0.2.9+15.04.20150430-0ubuntu2~gcc5.1) wily; urgency=medium + + * No-change test rebuild for g++5 ABI transition + + -- Steve Langasek <steve.langasek@ubuntu.com> Wed, 15 Jul 2015 15:58:40 +0000 + qmenumodel (0.2.9+15.04.20150430-0ubuntu1) vivid; urgency=medium [ Michael Terry ] diff --git a/debian/control b/debian/control index f8021ce..2008f64 100644 --- a/debian/control +++ b/debian/control @@ -9,9 +9,9 @@ Build-Depends: debhelper (>= 9.0.0), qt5-qmake, qtbase5-dev (>= 5.0), qtdeclarative5-dev (>= 5.0), - python3, - python3-dbus, - python3-gi, + python3:any, + python3-dbus:native, + python3-gi:native, gir1.2-glib-2.0, dbus-test-runner, libgles2-mesa-dev | libgl-dev, diff --git a/libqmenumodel/QMenuModel/CMakeLists.txt b/libqmenumodel/QMenuModel/CMakeLists.txt index 78e062b..eb4d463 100644 --- a/libqmenumodel/QMenuModel/CMakeLists.txt +++ b/libqmenumodel/QMenuModel/CMakeLists.txt @@ -24,11 +24,7 @@ qt5_use_modules(qmenumodel-qml Qml Quick) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" "${CMAKE_CURRENT_BINARY_DIR}/qmldir") -execute_process( - COMMAND qmake -query QT_INSTALL_QML - OUTPUT_VARIABLE QT_IMPORTS_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE -) +set(QT_IMPORTS_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/qml") set(QMLPLUGIN_INSTALL_PREFIX "${QT_IMPORTS_DIR}/QMenuModel") install(TARGETS qmenumodel-qml DESTINATION ${QMLPLUGIN_INSTALL_PREFIX}) install(FILES qmldir DESTINATION ${QMLPLUGIN_INSTALL_PREFIX}) diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 69e6629..459e77f 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Canonical Ltd. + * Copyright 2012-2016 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,6 +15,7 @@ * * Authors: * Renato Araujo Oliveira Filho <renato@canonical.com> + * Marco Trevisan <marco.trevisan@canonical.com> */ extern "C" { @@ -24,6 +25,7 @@ extern "C" { #include "converter.h" #include <QDebug> +#include <QString> #include <QVariant> /*! \internal */ @@ -57,6 +59,26 @@ QVariant Converter::toQVariant(GVariant *value) gsize size = 0; const gchar *v = g_variant_get_string(value, &size); result.setValue(QString::fromUtf8(v, size)); + } else if (g_variant_type_equal(type, G_VARIANT_TYPE_STRING_ARRAY)) { + gsize size = 0; + const gchar **sa = g_variant_get_strv(value, &size); + QStringList list; + for (gsize i = 0; i < size; ++i) { + list << QString::fromUtf8(sa[i]); + } + result.setValue(list); + g_free(sa); + } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING)) { + result.setValue(QByteArray(g_variant_get_bytestring(value))); + } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING_ARRAY)) { + gsize size = 0; + const gchar **bsa = g_variant_get_bytestring_array(value, &size); + QByteArrayList list; + for (gsize i = 0; i < size; ++i) { + list << bsa[i]; + } + result.setValue(list); + g_free(bsa); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_VARIANT)) { GVariant *var = g_variant_get_variant(value); result = toQVariant(var); @@ -109,32 +131,33 @@ QVariant Converter::toQVariant(GVariant *value) * G_VARIANT_TYPE_UNIT * G_VARIANT_TYPE_DICT_ENTRY * G_VARIANT_TYPE_DICTIONARY - * G_VARIANT_TYPE_STRING_ARRAY - * G_VARIANT_TYPE_BYTESTRING * G_VARIANT_TYPE_OBJECT_PATH_ARRAY - * G_VARIANT_TYPE_BYTESTRING_ARRAY */ return result; } -static GVariant* toGVariant(const QString &typeName, const QVariant &value) +QVariant Converter::toQVariantFromVariantString(const QString &variantString) { - if (typeName == "uchar") { - return g_variant_new_byte(value.value<uchar>()); - } else if (typeName == "short") { - return g_variant_new_int16(value.value<short>()); - } else if (typeName == "ushort") { - return g_variant_new_uint16(value.value<ushort>()); - } else if (typeName == "long") { - return g_variant_new_int64(value.value<long>()); - } else if (typeName == "ulong") { - return g_variant_new_uint64(value.value<ulong>()); - } else { - qWarning() << "QVariant type not supported:" << typeName; + GVariant *gvariant; + GError *error = NULL; + + if (variantString.isEmpty()) { + return QVariant(); } - return NULL; + gvariant = g_variant_parse (NULL, qUtf8Printable(variantString), NULL, NULL, &error); + + if (error) { + qWarning() << "Impossible to parse" << variantString << "as variant string:"<< error->message; + g_error_free (error); + return QVariant(); + } + + const QVariant& qvariant = Converter::toQVariant(gvariant); + g_variant_unref (gvariant); + + return qvariant; } GVariant* Converter::toGVariant(const QVariant &value) @@ -156,12 +179,33 @@ GVariant* Converter::toGVariant(const QVariant &value) case QVariant::Int: result = g_variant_new_int32(value.toInt()); break; + case QVariant::LongLong: + result = g_variant_new_int64(value.toLongLong()); + break; case QVariant::String: - result = g_variant_new_string(value.toString().toUtf8().data()); + result = g_variant_new_string(qUtf8Printable(value.toString())); break; case QVariant::UInt: result = g_variant_new_uint32(value.toUInt()); break; + case QVariant::ULongLong: + result = g_variant_new_uint64(value.toULongLong()); + break; + case QMetaType::UChar: + result = g_variant_new_byte(value.value<uchar>()); + break; + case QMetaType::Short: + result = g_variant_new_int16(value.value<short>()); + break; + case QMetaType::UShort: + result = g_variant_new_uint16(value.value<ushort>()); + break; + case QMetaType::Long: + result = g_variant_new_int64(value.value<long>()); + break; + case QMetaType::ULong: + result = g_variant_new_uint64(value.value<ulong>()); + break; case QVariant::Map: { GVariantBuilder *b; @@ -171,7 +215,19 @@ GVariant* Converter::toGVariant(const QVariant &value) QMapIterator<QString, QVariant> i(value.toMap()); while (i.hasNext()) { i.next(); - g_variant_builder_add(b, "{sv}", i.key().toUtf8().data(), toGVariant(i.value())); + g_variant_builder_add(b, "{sv}", qUtf8Printable(i.key()), toGVariant(i.value())); + } + result = g_variant_builder_end(b); + g_variant_builder_unref(b); + break; + } + case QMetaType::QByteArrayList: + { + const QByteArrayList &list = qvariant_cast<QByteArrayList>(value); + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_BYTESTRING_ARRAY); + + for (const QByteArray &ba : list) { + g_variant_builder_add_value(b, g_variant_new_bytestring(ba)); } result = g_variant_builder_end(b); g_variant_builder_unref(b); @@ -179,17 +235,28 @@ GVariant* Converter::toGVariant(const QVariant &value) } case QVariant::List: { - QVariantList lst = value.toList(); - GVariant **vars = g_new(GVariant*, lst.size()); - for (int i=0; i < lst.size(); i++) { - vars[i] = toGVariant(lst[i]); + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_TUPLE); + + for (const QVariant &v : value.toList()) { + g_variant_builder_add_value(b, toGVariant(v)); } - result = g_variant_new_tuple(vars, lst.size()); - g_free(vars); + result = g_variant_builder_end(b); + g_variant_builder_unref(b); + break; + } + case QVariant::StringList: + { + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_STRING_ARRAY); + + for (const QString &s : value.toStringList()) { + g_variant_builder_add(b, "s", qUtf8Printable(s)); + } + result = g_variant_builder_end(b); + g_variant_builder_unref(b); break; } default: - result = ::toGVariant(value.typeName(), value); + qWarning() << "QVariant type not supported:" << value.type(); } return result; @@ -202,8 +269,7 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch } GVariant* result = NULL; - const GVariantType* schema_type; - schema_type = g_variant_type_new(schema); + GVariantType* schema_type = g_variant_type_new(schema); if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_BOOLEAN)) { if (value.canConvert<bool>()) { @@ -243,80 +309,65 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch } } else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_STRING)) { if (value.canConvert<QString>()) { - result = g_variant_new_string(value.toString().toUtf8().data()); + result = g_variant_new_string(qUtf8Printable(value.toString())); } } else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_VARIANT)) { - result = Converter::toGVariant(value); + result = g_variant_new_variant(Converter::toGVariant(value)); } else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_VARDICT)) { if (value.canConvert(QVariant::Map)) { result = Converter::toGVariant(value.toMap()); } } else if (g_variant_type_is_array(schema_type)) { if (value.canConvert(QVariant::List)) { + const GVariantType* entryType = g_variant_type_element(schema_type); + const gchar* entryTypeString = g_variant_type_peek_string(entryType); - const GVariantType* entry_type; - GVariant* data; - entry_type = g_variant_type_element(schema_type); - gchar* entryTypeString = g_variant_type_dup_string(entry_type); - - QVariantList lst = value.toList(); - GVariant **vars = g_new(GVariant*, lst.size()); - + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_ARRAY); bool ok = true; - for (int i=0; i < lst.size(); i++) { - data = Converter::toGVariantWithSchema(lst[i], entryTypeString); + + for (const QVariant &v : value.toList()) { + GVariant *data = toGVariantWithSchema(v, entryTypeString); if (data) { - vars[i] = data; - } - else { + g_variant_builder_add_value(b, data); + } else { ok = false; qWarning() << "Failed to convert list to array with schema:" << schema; break; } } if (ok) { - result = g_variant_new_array(entry_type, vars, lst.size()); + result = g_variant_builder_end(b); } - g_free(entryTypeString); - g_free(vars); + g_variant_builder_unref(b); } } else if (g_variant_type_is_tuple(schema_type)) { if (value.canConvert(QVariant::List)) { - GVariant* data; - - QVariantList lst = value.toList(); - GVariant **vars = g_new(GVariant*, lst.size()); - - const GVariantType* entry_type = g_variant_type_first(schema_type); + const GVariantType* entryType = g_variant_type_first(schema_type); + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_TUPLE); bool ok = true; - for (int i=0; i < lst.size(); i++) { - - gchar* entryTypeString = g_variant_type_dup_string(entry_type); - data = Converter::toGVariantWithSchema(lst[i], entryTypeString); + for (const QVariant &v : value.toList()) { + gchar* entryTypeString = g_variant_type_dup_string(entryType); + GVariant *data = toGVariantWithSchema(v, entryTypeString); + g_free(entryTypeString); if (data) { - vars[i] = data; - } - else { + g_variant_builder_add_value(b, data); + entryType = g_variant_type_next(entryType); + if (!entryType) + break; + } else { ok = false; - qWarning() << "Failed to convert list to tuple with schema:" << schema; - g_free(entryTypeString); - break; - } - g_free(entryTypeString); - - entry_type = g_variant_type_next(entry_type); - if (!entry_type) { + qWarning() << "Failed to convert list to array with schema:" << schema; break; } } if (ok) { - result = g_variant_new_tuple(vars, lst.size()); + result = g_variant_builder_end(b); } - g_free(vars); + g_variant_builder_unref(b); } } @@ -324,6 +375,9 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch if (!result) { result = Converter::toGVariant(value); } + + g_free(schema_type); + return result; } diff --git a/libqmenumodel/src/converter.h b/libqmenumodel/src/converter.h index f47c09e..27cdcae 100644 --- a/libqmenumodel/src/converter.h +++ b/libqmenumodel/src/converter.h @@ -21,12 +21,14 @@ #define CONVERTER_H typedef struct _GVariant GVariant; +class QString; class QVariant; class Converter { public: static QVariant toQVariant(GVariant *value); + static QVariant toQVariantFromVariantString(const QString &variantString); static GVariant* toGVariant(const QVariant &value); // This converts a QVariant to a GVariant using a provided gvariant schema as diff --git a/libqmenumodel/src/logging.h b/libqmenumodel/src/logging.h new file mode 100644 index 0000000..bd7e708 --- /dev/null +++ b/libqmenumodel/src/logging.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License version 3, as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef QMENUMODEL_LOGGING_H +#define QMENUMODEL_LOGGING_H + +#include <QLoggingCategory> +Q_DECLARE_LOGGING_CATEGORY(unitymenumodel) + +#endif // QMENUMODEL_LOGGING_H diff --git a/libqmenumodel/src/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp index be9fb93..fab2df7 100644 --- a/libqmenumodel/src/qdbusobject.cpp +++ b/libqmenumodel/src/qdbusobject.cpp @@ -81,7 +81,6 @@ QDBusObject::QDBusObject(QObject* listener) m_busType(DBusEnums::None), m_status(DBusEnums::Disconnected) { - g_type_init(); qRegisterMetaType<DBusEnums::ConnectionStatus>("DBusEnums::ConnectionStatus"); } diff --git a/libqmenumodel/src/qstateaction.cpp b/libqmenumodel/src/qstateaction.cpp index 983064a..fcffa44 100644 --- a/libqmenumodel/src/qstateaction.cpp +++ b/libqmenumodel/src/qstateaction.cpp @@ -19,6 +19,7 @@ #include "qstateaction.h" +#include "converter.h" #include "qdbusactiongroup.h" /*! @@ -99,6 +100,15 @@ void QStateAction::updateState(const QVariant &state) } /*! + Request for the state of action to be changed to \a paramenter. + This call merely requests a change. The action may refuse to change its state or may change its state to something other than \a paramenter. +*/ +void QStateAction::updateStateByVariantString(const QString &state) +{ + updateState(Converter::toQVariantFromVariantString(state)); +} + +/*! Activates the action passing \a parameter. \a parameter must be the correct type of parameter for the action */ @@ -107,6 +117,16 @@ void QStateAction::activate(const QVariant ¶meter) m_group->activateAction(m_name, parameter); } +/*! + Activates the action passing \a parameter using GLib Variant String format. + \a parameter must be the correct type of parameter for the action +*/ +void QStateAction::activateByVariantString(const QString ¶meter) +{ + activate(Converter::toQVariantFromVariantString(parameter)); +} + + /*! \internal */ QString QStateAction::name() const { diff --git a/libqmenumodel/src/qstateaction.h b/libqmenumodel/src/qstateaction.h index 0fc68c2..4d05a7a 100644 --- a/libqmenumodel/src/qstateaction.h +++ b/libqmenumodel/src/qstateaction.h @@ -36,7 +36,9 @@ public: bool isValid() const; Q_INVOKABLE void activate(const QVariant ¶meter = QVariant()); + Q_INVOKABLE void activateByVariantString(const QString ¶meter = QString()); Q_INVOKABLE void updateState(const QVariant ¶meter); + Q_INVOKABLE void updateStateByVariantString(const QString ¶meter); Q_SIGNALS: void stateChanged(QVariant state); diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 6a75f40..192ee46 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -22,6 +22,7 @@ #include "unitymenumodelevents.h" #include "unitymenuaction.h" #include "unitymenuactionevents.h" +#include "logging.h" #include <QIcon> #include <QQmlComponent> @@ -34,6 +35,8 @@ extern "C" { #include "gtk/gtksimpleactionobserver.h" } +Q_LOGGING_CATEGORY(unitymenumodel, "qmenumodel.unitymenumodel", QtCriticalMsg) + G_DEFINE_QUARK (UNITY_MENU_MODEL, unity_menu_model) G_DEFINE_QUARK (UNITY_SUBMENU_MODEL, unity_submenu_model) G_DEFINE_QUARK (UNITY_MENU_ITEM_EXTENDED_ATTRIBUTES, unity_menu_item_extended_attributes) @@ -664,15 +667,15 @@ bool UnityMenuModel::loadExtendedAttributes(int position, const QVariantMap &sch GVariant *value = gtk_menu_tracker_item_get_attribute_value (item, name.toUtf8(), NULL); if (value == NULL) { - qWarning("loadExtendedAttributes: menu item does not contain '%s'", it.key().toUtf8().constData()); + qCWarning(unitymenumodel, "loadExtendedAttributes: menu item does not contain '%s'", it.key().toUtf8().constData()); continue; } - QVariant qvalue = attributeToQVariant(value, type); + const QVariant &qvalue = attributeToQVariant(value, type); if (qvalue.isValid()) extendedAttrs->insert(qtify_name (name.toUtf8()), qvalue); else - qWarning("loadExtendedAttributes: key '%s' is of type '%s' (expected '%s')", + qCWarning(unitymenumodel, "loadExtendedAttributes: key '%s' is of type '%s' (expected '%s')", name.toUtf8().constData(), g_variant_get_type_string(value), type.constData()); g_variant_unref (value); @@ -699,6 +702,8 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) { GSequenceIter *it; GtkMenuTrackerItem *item; + GVariant *value; + const GVariantType *parameter_type; it = g_sequence_get_iter_at_pos (priv->items, index); if (g_sequence_iter_is_end (it)) { @@ -714,7 +719,9 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) gchar *action; action = gtk_menu_tracker_item_get_action_name (item); - g_action_group_activate_action (G_ACTION_GROUP (priv->muxer), action, Converter::toGVariant(parameter)); + parameter_type = g_action_group_get_action_parameter_type (G_ACTION_GROUP (priv->muxer), action); + value = Converter::toGVariantWithSchema(parameter, g_variant_type_peek_string (parameter_type)); + g_action_group_activate_action (G_ACTION_GROUP (priv->muxer), action, value); g_free (action); } else { @@ -722,6 +729,16 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) } } +void UnityMenuModel::activateByVariantString(int index, const QString& parameter) +{ + activate(index, Converter::toQVariantFromVariantString(parameter)); +} + +void UnityMenuModel::changeStateByVariantString(int index, const QString& parameter) +{ + changeState(index, Converter::toQVariantFromVariantString(parameter)); +} + void UnityMenuModel::changeState(int index, const QVariant& parameter) { GSequenceIter *it; diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h index 8816d22..ed3bcd7 100644 --- a/libqmenumodel/src/unitymenumodel.h +++ b/libqmenumodel/src/unitymenumodel.h @@ -63,7 +63,9 @@ public: Q_INVOKABLE QVariant get(int row, const QByteArray &role); Q_INVOKABLE void activate(int index, const QVariant& parameter = QVariant()); + Q_INVOKABLE void activateByVariantString(int index, const QString& parameter = QString()); Q_INVOKABLE void changeState(int index, const QVariant& parameter); + Q_INVOKABLE void changeStateByVariantString(int index, const QString& parameter); void registerAction(UnityMenuAction* action); void unregisterAction(UnityMenuAction* action); diff --git a/tests/client/actiongrouptest.cpp b/tests/client/actiongrouptest.cpp index d187ea7..3ab329c 100644 --- a/tests/client/actiongrouptest.cpp +++ b/tests/client/actiongrouptest.cpp @@ -31,21 +31,23 @@ class ActionGroupTest : public QObject { Q_OBJECT private: - DBusMenuScript m_script; QDBusMenuModel m_model; QDBusActionGroup m_actionGroup; + DBusMenuScript m_script; -private Q_SLOTS: - void initTestCase() + void getMenuAction(QStateAction **act, int index) { - QVERIFY(m_script.connect()); - } + // Append 2 menus + m_script.walk(2); - void cleanupTestCase() - { - m_script.quit(); + // Get Action + QVariant action = m_model.data(m_model.index(index, 0), QMenuModel::Action); + QVERIFY(action.isValid()); + *act = m_actionGroup.action(action.toString()); + QVERIFY(act); } +private Q_SLOTS: void init() { m_model.stop(); @@ -57,6 +59,23 @@ private Q_SLOTS: m_actionGroup.setBusType(DBusEnums::SessionBus); m_actionGroup.setBusName(MENU_SERVICE_NAME); m_actionGroup.setObjectPath(MENU_OBJECT_PATH); + + // start model + m_model.start(); + m_actionGroup.start(); + + // Make menu available + m_script.publishMenu(); + } + + void initTestCase() + { + QVERIFY(m_script.connect()); + } + + void cleanupTestCase() + { + m_script.quit(); } void cleanup() @@ -88,11 +107,11 @@ private Q_SLOTS: */ void testServiceAppear() { - m_model.start(); - m_actionGroup.start(); + m_script.unpublishMenu(); QCOMPARE(m_actionGroup.status(), DBusEnums::Connecting); // Make menu available + m_script.connect(); m_script.publishMenu(); QCOMPARE(m_actionGroup.status(), DBusEnums::Connected); @@ -104,11 +123,6 @@ private Q_SLOTS: */ void testServiceDisappear() { - m_model.start(); - m_actionGroup.start(); - - // Make menu available - m_script.publishMenu(); QCOMPARE(m_actionGroup.status(), DBusEnums::Connected); // Append menus @@ -122,35 +136,42 @@ private Q_SLOTS: QCOMPARE(m_actionGroup.status(), DBusEnums::Disconnected); } + void testActionName() + { + QStateAction *act; + getMenuAction(&act, 1); + QCOMPARE(act->property("name").toString(), QString("Menu1Act")); + } + /* * Test if Action::trigger active the action over DBus */ - void testActiveAction() + void testStringActionActivation() { - // start model - m_model.start(); - m_actionGroup.start(); + QStateAction *act; + getMenuAction(&act, 1); + act->activate(QVariant("42")); - // Make menu available - m_script.publishMenu(); - m_script.walk(2); + // wait for dbus propagation + QTest::qWait(500); - // Get Action - QVariant action = m_model.data(m_model.index(1, 0), QMenuModel::Action); - QVERIFY(action.isValid()); - QStateAction *act = m_actionGroup.action(action.toString()); - QVERIFY(act); + QPair<QString, QVariant> result = m_script.popActivatedAction(); + QCOMPARE(result.first, QString("Menu1Act")); + QCOMPARE(result.second.toString(), QString("42")); + } - // test action name - QCOMPARE(act->property("name").toString(), QString("Menu1Act")); + void testStringActionActivationByVariantString() + { + QStateAction *act; + getMenuAction(&act, 1); + act->activateByVariantString("\"53\""); - act->activate(QVariant("42")); // wait for dbus propagation QTest::qWait(500); QPair<QString, QVariant> result = m_script.popActivatedAction(); QCOMPARE(result.first, QString("Menu1Act")); - QCOMPARE(result.second.toString(), QString("42")); + QCOMPARE(result.second.toString(), QString("53")); } /* @@ -158,12 +179,7 @@ private Q_SLOTS: */ void testRemoveAction() { - // start model - m_model.start(); - m_actionGroup.start(); - - // Make menu available and append 2 menus - m_script.publishMenu(); + // Append 2 menus m_script.walk(2); // Get Action @@ -183,13 +199,6 @@ private Q_SLOTS: */ void testActionIsValid() { - // start model - m_model.start(); - m_actionGroup.start(); - - // Make menu available and append 2 menus - m_script.publishMenu(); - // Get invalid Action QStateAction *act = m_actionGroup.action(QString("Menu1Act")); QVERIFY(act); @@ -204,6 +213,6 @@ private Q_SLOTS: } }; -QTEST_MAIN(ActionGroupTest) +QTEST_MAIN(ActionGroupTest); #include "actiongrouptest.moc" diff --git a/tests/client/cachetest.cpp b/tests/client/cachetest.cpp index 22fe5d3..8ad65af 100644 --- a/tests/client/cachetest.cpp +++ b/tests/client/cachetest.cpp @@ -77,11 +77,6 @@ class CacheTest : public QObject Q_OBJECT private Q_SLOTS: - void initTestCase() - { - g_type_init(); - } - // Verify that normal menu items are not cached (only sub-menus are) void testCacheContents() { diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index db2807f..43127a7 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Canonical Ltd. + * Copyright 2012-2016 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,6 +15,7 @@ * * Authors: * Renato Araujo Oliveira Filho <renato@canonical.com> + * Marco Trevisan <marco.trevisan@canonical.com> */ extern "C" { @@ -27,6 +28,34 @@ extern "C" { #include <QtTest> #include <QDebug> +class QGVariantType +{ +public: + QGVariantType() : type(NULL) {} + QGVariantType(const GVariantType *gvtype) : type(gvtype) {} + const GVariantType *getType() const { return type; } + operator const GVariantType*() const { return type; } + +private: + const GVariantType *type; +}; +Q_DECLARE_METATYPE(QGVariantType); + +class QGVariant +{ +public: + QGVariant() : variant(NULL) {} + ~QGVariant() { if (variant) g_variant_unref(variant); } + QGVariant(GVariant *gv) : variant(g_variant_ref_sink(gv)) {} + QGVariant(const QGVariant &other) : QGVariant(other.variant) {} + GVariant *gvariant() const { return variant; } + operator GVariant*() const { return variant; } + +private: + GVariant *variant; +}; +Q_DECLARE_METATYPE(QGVariant); + class ConverterTest : public QObject { Q_OBJECT @@ -39,8 +68,21 @@ private: result = g_variant_type_equal(g_variant_get_type(gv), type); if (!result) { qWarning() << "types are different: QVariant:" << qv.typeName() - << "Result:" << (const char*) g_variant_get_type(gv) - << "Expected:"<< (const char*) type; + << "Result:" << g_variant_type_peek_string(g_variant_get_type(gv)) + << "Expected:"<< g_variant_type_peek_string(type); + } + g_variant_unref(gv); + return result; + } + bool compare(GVariant *gv, const QVariant::Type type) + { + g_variant_ref_sink(gv); + const QVariant& qv = Converter::toQVariant(gv); + bool result = (qv.type() == type); + if (!result) { + qWarning() << "types are different: GVariant:" << g_variant_type_peek_string(g_variant_get_type(gv)) + << "Result:" << qv.type() + << "Expected:"<< type; } g_variant_unref(gv); return result; @@ -55,10 +97,11 @@ private: result = g_variant_type_equal(g_variant_get_type(gv), expected_type); if (!result) { qWarning() << "types are different: QVariant:" << qv.typeName() - << "Result:" << (const char*) g_variant_get_type(gv) - << "Expected:"<< (const char*) expected_type; + << "Result:" << g_variant_type_peek_string(g_variant_get_type(gv)) + << "Expected:"<< g_variant_type_peek_string(expected_type); } g_variant_unref(gv); + g_variant_type_free(expected_type); return result; } @@ -67,44 +110,59 @@ private Q_SLOTS: /* * Test converter QVariant to GVariant */ - void testToGVariant() - { - // Boolean - QVERIFY(compare(QVariant(true), G_VARIANT_TYPE_BOOLEAN)); - - // Byte - QVERIFY(compare(QVariant::fromValue<uchar>(42), G_VARIANT_TYPE_BYTE)); - // Int16 - QVERIFY(compare(QVariant::fromValue<short>(-42), G_VARIANT_TYPE_INT16)); - - // UInt16 - QVERIFY(compare(QVariant::fromValue<ushort>(-42), G_VARIANT_TYPE_UINT16)); - - // Int32 - QVERIFY(compare(QVariant(-42), G_VARIANT_TYPE_INT32)); - - // UInt32 - QVERIFY(compare(QVariant((uint)42), G_VARIANT_TYPE_UINT32)); + void testConvertToGVariant_data() + { + QTest::addColumn<QVariant>("value"); + QTest::addColumn<QGVariantType>("expectedType"); + + QTest::newRow("Boolean") << QVariant(true) << QGVariantType(G_VARIANT_TYPE_BOOLEAN); + QTest::newRow("Byte") << QVariant::fromValue<uchar>(42) << QGVariantType(G_VARIANT_TYPE_BYTE); + QTest::newRow("Int16") << QVariant::fromValue<short>(-42) << QGVariantType(G_VARIANT_TYPE_INT16); + QTest::newRow("UInt16") << QVariant::fromValue<ushort>(-42) << QGVariantType(G_VARIANT_TYPE_UINT16); + QTest::newRow("Int32") << QVariant(-42) << QGVariantType(G_VARIANT_TYPE_INT32); + QTest::newRow("UInt32") << QVariant((uint)42) << QGVariantType(G_VARIANT_TYPE_UINT32); + QTest::newRow("Int64") << QVariant::fromValue<long>(-42) << QGVariantType(G_VARIANT_TYPE_INT64); + QTest::newRow("UInt64") << QVariant::fromValue<ulong>(42) << QGVariantType(G_VARIANT_TYPE_UINT64); + QTest::newRow("Int64") << QVariant::fromValue<qlonglong>(-42) << QGVariantType(G_VARIANT_TYPE_INT64); + QTest::newRow("UInt64") << QVariant::fromValue<qulonglong>(42) << QGVariantType(G_VARIANT_TYPE_UINT64); + QTest::newRow("Double") << QVariant((double)42.42) << QGVariantType(G_VARIANT_TYPE_DOUBLE); + QTest::newRow("String") << QVariant(QString("42")) << QGVariantType(G_VARIANT_TYPE_STRING); + QTest::newRow("String List") << QVariant(QStringList({"42", "42"})) << QGVariantType(G_VARIANT_TYPE_STRING_ARRAY); + QTest::newRow("ByteArray") << QVariant(QByteArray("42")) << QGVariantType(G_VARIANT_TYPE_BYTESTRING); + QTest::newRow("Map") << QVariant(QVariantMap()) << QGVariantType(G_VARIANT_TYPE_VARDICT); + QTest::newRow("Map Filled") << QVariant(QVariantMap({{"fooBar", 0xdeadbeef}})) << QGVariantType(G_VARIANT_TYPE_VARDICT); + QTest::newRow("List") << QVariant(QVariantList()) << QGVariantType(G_VARIANT_TYPE_UNIT); + QTest::newRow("List Filled") << QVariant(QVariantList({"fooBar", 0xdeadbeef})) << QGVariantType(G_VARIANT_TYPE("(su)")); + + QVariant result; + result.setValue(QByteArrayList({"42", "53"})); + QTest::newRow("ByteArrayList") << result << QGVariantType(G_VARIANT_TYPE_BYTESTRING_ARRAY); + } - // Int64 - QVERIFY(compare(QVariant::fromValue<long>(-42), G_VARIANT_TYPE_INT64)); + void testConvertToGVariant() + { + QFETCH(QVariant, value); + QFETCH(QGVariantType, expectedType); - // UInt64 - QVERIFY(compare(QVariant::fromValue<ulong>(42), G_VARIANT_TYPE_UINT64)); + QVERIFY(compare(value, expectedType)); + } - // Double - QVERIFY(compare(QVariant((double)42.42), G_VARIANT_TYPE_DOUBLE)); + void testConvertToGVariantAndBack_data() + { + testConvertToGVariant_data(); + } - // String - QVERIFY(compare(QVariant(QString("42")), G_VARIANT_TYPE_STRING)); + void testConvertToGVariantAndBack() + { + QFETCH(QVariant, value); - // ByteArray - QVERIFY(compare(QVariant(QByteArray("42")), G_VARIANT_TYPE_BYTESTRING)); + GVariant *gv = Converter::toGVariant(value); + QVERIFY(gv != NULL); - // Map - QVERIFY(compare(QVariantMap(), G_VARIANT_TYPE_VARDICT)); + QCOMPARE(Converter::toQVariant(gv), value); + g_variant_unref(gv); } void testTupleConversion() @@ -134,41 +192,190 @@ private Q_SLOTS: g_variant_unref(gTuple); } - void testSchemaConvert() + void testConvertToGVariantWithSchema_data() { - // convert to integer - compareWithSchema(QVariant::fromValue<int>(1), "i"); - compareWithSchema(QVariant::fromValue<double>(1.1), "i"); + QTest::addColumn<QVariant>("value"); + QTest::addColumn<QString>("schema"); + + // convert to byte + QTest::newRow("byte") << QVariant::fromValue<int>(1) << "y"; // convert to integer - compareWithSchema(QVariant::fromValue<bool>(true), "b"); - compareWithSchema(QVariant::fromValue<int>(1), "b"); + QTest::newRow("integer") << QVariant::fromValue<int>(1) << "i"; + QTest::newRow("integer from double") << QVariant::fromValue<double>(1.1) << "i"; + QTest::newRow("int16") << QVariant::fromValue<int>(-1) << "n"; + QTest::newRow("uint16") << QVariant::fromValue<int>(1) << "q"; + QTest::newRow("uint32") << QVariant::fromValue<int>(1) << "u"; + QTest::newRow("int64") << QVariant::fromValue<int>(1) << "x"; + QTest::newRow("uint64") << QVariant::fromValue<int>(1) << "t"; + + // convert to variant + QTest::newRow("variant from int") << QVariant::fromValue<int>(1) << "v"; + QTest::newRow("variant from double") << QVariant::fromValue<double>(1.1) << "v"; + QTest::newRow("variant from string") << QVariant::fromValue<QString>("string") << "v"; + + // convert to bool + QTest::newRow("bool") << QVariant::fromValue<bool>(true) << "b"; + QTest::newRow("bool from int") << QVariant::fromValue<int>(1) << "b"; // convert to double - compareWithSchema(QVariant::fromValue<double>(1.0), "d"); - compareWithSchema(QVariant::fromValue<int>(1), "d"); + QTest::newRow("double") << QVariant::fromValue<double>(1.0) << "d"; + QTest::newRow("double from int") << QVariant::fromValue<int>(1) << "d"; // convert to string - compareWithSchema(QVariant::fromValue<int>(1), "s"); - compareWithSchema(QVariant::fromValue<double>(1.1), "s"); + QTest::newRow("string") << QVariant::fromValue<QString>("FoooBar") << "s"; + QTest::newRow("string from int") << QVariant::fromValue<int>(1) << "s"; + QTest::newRow("string from double") << QVariant::fromValue<double>(1.1) << "s"; // convert to tuple - compareWithSchema(QVariantList() << QVariant::fromValue<bool>(true) << QVariant::fromValue<int>(1) << QVariant::fromValue<int>(1) << QVariant::fromValue<QString>("test1"), "(bdis)"); + QVariantList list = QVariantList() << QVariant::fromValue<bool>(true) << QVariant::fromValue<int>(1) << QVariant::fromValue<int>(1) << QVariant::fromValue<QString>("test1"); + QTest::newRow("tuple") << QVariant(list) << "(bdis)"; // convert to array - compareWithSchema(QVariantList() << QVariant::fromValue<int>(1) << QVariant::fromValue<int>(1), "ad"); - compareWithSchema(QVariantList() << QVariant::fromValue<QString>("test1") << QVariant::fromValue<QString>("test2"), "as"); + list = QVariantList() << QVariant::fromValue<int>(1) << QVariant::fromValue<int>(1); + QTest::newRow("int list") << QVariant(list) << "ad"; + list = QVariantList() << QVariant::fromValue<QString>("test1") << QVariant::fromValue<QString>("test2"); + QTest::newRow("string list") << QVariant(list) << "as"; // convert to array of tuple QVariantList si1(QVariantList() << QVariant::fromValue<QString>("test1") << QVariant::fromValue<int>(1)); QVariantList si2(QVariantList() << QVariant::fromValue<QString>("test1") << QVariant::fromValue<int>(1)); - compareWithSchema(QVariantList() << QVariant::fromValue(si1) << QVariant::fromValue(si2), "a(sd)"); + list = QVariantList() << QVariant::fromValue(si1) << QVariant::fromValue(si2); + QTest::newRow("array of tuple") << QVariant(list) << "a(sd)"; // convert to vardict QVariantMap map; map["test1"] = QVariant::fromValue<int>(1); map["test2"] = QVariant::fromValue<double>(1); - compareWithSchema(map, "a{sv}"); + QTest::newRow("map") << QVariant(map) << "a{sv}"; + } + + void testConvertToGVariantWithSchema() + { + QFETCH(QVariant, value); + QFETCH(QString, schema); + + QVERIFY(compareWithSchema(value, schema)); + } + + /* + * Test converter GVariant to QVariant + */ + + void testConvertToQVariant_data() + { + QTest::addColumn<QGVariant>("value"); + QTest::addColumn<unsigned>("expectedType"); + + QTest::newRow("Boolean") << QGVariant(g_variant_new_boolean(TRUE)) << (unsigned) QVariant::Bool; + QTest::newRow("Byte") << QGVariant(g_variant_new_byte(53)) << (unsigned) QMetaType::UChar; + QTest::newRow("Int16") << QGVariant(g_variant_new_int16(-53)) << (unsigned) QMetaType::Short; + QTest::newRow("UInt16") << QGVariant(g_variant_new_uint16(53)) << (unsigned) QMetaType::UShort; + QTest::newRow("Int32") << QGVariant(g_variant_new_int32(-53)) << (unsigned) QVariant::Int; + QTest::newRow("UInt32") << QGVariant(g_variant_new_uint32(53)) << (unsigned) QVariant::UInt; + QTest::newRow("Int64") << QGVariant(g_variant_new_int64(-53)) << (unsigned) QVariant::LongLong; + QTest::newRow("UInt64") << QGVariant(g_variant_new_uint64(53)) << (unsigned) QVariant::ULongLong; + QTest::newRow("Double") << QGVariant(g_variant_new_double(53.3)) << (unsigned) QVariant::Double; + QTest::newRow("String") << QGVariant(g_variant_new_string("53")) << (unsigned) QVariant::String; + QTest::newRow("Byte string") << QGVariant(g_variant_new_bytestring("53")) << (unsigned) QVariant::ByteArray; + QTest::newRow("Tuple") << QGVariant(g_variant_new("(si)", "foo", 53)) << (unsigned) QVariant::List; + + GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE_VARDICT); + g_variant_builder_add(builder, "{sv}", "fooo", g_variant_new_int64(53)); + QTest::newRow("Map") << QGVariant(g_variant_builder_end(builder)) << (unsigned) QVariant::Map; + g_variant_builder_unref(builder); + + builder = g_variant_builder_new(G_VARIANT_TYPE("ai")); + g_variant_builder_add(builder, "i", g_variant_new_int32(53)); + QTest::newRow("List") << QGVariant(g_variant_new("ai", builder)) << (unsigned) QVariant::List; + g_variant_builder_unref(builder); + + QTest::newRow("Tuple") << QGVariant(g_variant_new("(i)", 53)) << (unsigned) QVariant::List; + + const gchar *byteArray[] = {"42", "53", NULL}; + QTest::newRow("ByteArrayList") << QGVariant(g_variant_new_bytestring_array(byteArray, -1)) << (unsigned) QMetaType::QByteArrayList; + QTest::newRow("String List") << QGVariant(g_variant_new_strv(byteArray, -1)) << (unsigned) QVariant::StringList; + } + + void testConvertToQVariant() + { + QFETCH(QGVariant, value); + QFETCH(unsigned, expectedType); + + QVERIFY(compare(value, (QVariant::Type) expectedType)); + } + + void testConvertToQVariantAndBack_data() + { + testConvertToQVariant_data(); + } + + void testConvertToQVariantAndBack() + { + QFETCH(QGVariant, value); + + QVariant qv = Converter::toQVariant(value); + QVERIFY(qv.isValid()); + + GVariant *gv = Converter::toGVariant(qv); + gboolean equals = g_variant_equal(value, gv); + + if (!equals && qv.type() == QVariant::List) { + QVERIFY(g_variant_type_is_array(g_variant_get_type(value))); + QVERIFY(g_variant_type_is_tuple(g_variant_get_type(gv))); + + gsize vsize = g_variant_n_children(value); + QCOMPARE(vsize, g_variant_n_children(gv)); + + for (gsize i = 0; i < vsize; ++i) { + equals = g_variant_equal(g_variant_get_child_value(value, i), g_variant_get_child_value(gv, i)); + if (!equals) + break; + } + } + + if (!equals) { + gchar *vs = g_variant_print(value, TRUE); + gchar *gvs = g_variant_print(gv, TRUE); + qWarning() << "Values do not match. Old" << vs << "converted" << gvs; + g_free(vs); + g_free(gvs); + } + + g_variant_unref(gv); + QVERIFY(equals != FALSE); + } + + void testConvertToQVariantFromString_data() + { + QTest::addColumn<QString>("value"); + QTest::addColumn<unsigned>("expectedType"); + + QTest::newRow("Boolean") << "true" << (unsigned) QVariant::Bool; + QTest::newRow("Byte") << "byte 0xFF" << (unsigned) QMetaType::UChar; + QTest::newRow("Int16") << "int16 65" << (unsigned) QMetaType::Short; + QTest::newRow("UInt16") << "uint16 65" << (unsigned) QMetaType::UShort; + QTest::newRow("Int32") << "int32 65" << (unsigned) QVariant::Int; + QTest::newRow("UInt32") << "uint32 65" << (unsigned) QVariant::UInt; + QTest::newRow("Int64") << "int64 65" << (unsigned) QVariant::LongLong; + QTest::newRow("UInt64") << "uint64 65" << (unsigned) QVariant::ULongLong; + QTest::newRow("Double") << "double 65" << (unsigned) QVariant::Double; + QTest::newRow("String") << "string '65'" << (unsigned) QVariant::String; + QTest::newRow("String simple") << "\"65\"" << (unsigned) QVariant::String; + QTest::newRow("String List") << "['foo', 'bar']" << (unsigned) QVariant::StringList; + QTest::newRow("Byte string") << "b'fooo'" << (unsigned) QVariant::ByteArray; + QTest::newRow("Map") << "{'foo': <65>}" << (unsigned) QVariant::Map; + QTest::newRow("List") << "[65, 66]" << (unsigned) QVariant::List; + QTest::newRow("Tuple") << "('foo', 65)" << (unsigned) QVariant::List; + QTest::newRow("ByteArrayList") << "[b'foo', b'bar']" << (unsigned) QMetaType::QByteArrayList; + } + + void testConvertToQVariantFromString() + { + QFETCH(QString, value); + QFETCH(unsigned, expectedType); + + QCOMPARE(Converter::toQVariantFromVariantString(value).type(), (QVariant::Type) expectedType); } }; diff --git a/tests/client/modelsignalstest.cpp b/tests/client/modelsignalstest.cpp index 40a76c6..3064778 100644 --- a/tests/client/modelsignalstest.cpp +++ b/tests/client/modelsignalstest.cpp @@ -192,11 +192,6 @@ class ModelSignalsTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase() - { - g_type_init(); - } - /* * Test if the model state still correct before and after insert a new row */ diff --git a/tests/client/treetest.cpp b/tests/client/treetest.cpp index b6fec3c..81399f7 100644 --- a/tests/client/treetest.cpp +++ b/tests/client/treetest.cpp @@ -62,11 +62,6 @@ class TreeTest : public QObject Q_OBJECT private Q_SLOTS: - void initTestCase() - { - g_type_init(); - } - void testMenuBuild() { TestModel menu; |