aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/client/CMakeLists.txt22
-rw-r--r--tests/client/convertertest.cpp39
-rw-r--r--tests/client/modeltest.cpp108
-rw-r--r--tests/script/CMakeLists.txt2
-rw-r--r--tests/script/dbusmenuscript.cpp2
6 files changed, 142 insertions, 36 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 0e94a94..96c4bad 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,2 @@
-find_package(Qt5Quick REQUIRED)
-find_package(Qt5Test REQUIRED)
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5DBus REQUIRED)
-
add_subdirectory(script)
add_subdirectory(client)
diff --git a/tests/client/CMakeLists.txt b/tests/client/CMakeLists.txt
index 05d31f3..8a0ed49 100644
--- a/tests/client/CMakeLists.txt
+++ b/tests/client/CMakeLists.txt
@@ -1,16 +1,16 @@
macro(declare_test testname)
add_executable(${testname} ${testname}.cpp)
target_link_libraries(${testname}
- qmenumodel
+ qmenumodel${QMENUMODEL_LIB_SUFFIX}
dbusmenuscript
${GLIB_LDFLAGS}
${GIO_LDFLAGS}
- Qt5::Core
- Qt5::DBus
- Qt5::Widgets
- Qt5::Test
- Qt5::Qml
- Qt5::Quick
+ Qt::Core
+ Qt::DBus
+ Qt::Widgets
+ Qt::Test
+ Qt::Qml
+ Qt::Quick
)
if(TEST_XML_OUTPUT)
@@ -34,11 +34,11 @@ endmacro(declare_test testname)
macro(declare_simple_test testname)
add_executable(${testname} ${testname}.cpp)
target_link_libraries(${testname}
- qmenumodel
+ qmenumodel${QMENUMODEL_LIB_SUFFIX}
${GLIB_LDFLAGS}
${GIO_LDFLAGS}
- Qt5::Core
- Qt5::Test
+ Qt::Core
+ Qt::Test
)
add_test(${testname}
@@ -76,7 +76,7 @@ if (ENABLE_COVERAGE)
find_package(CoverageReport)
ENABLE_COVERAGE_REPORT(
TARGETS
- qmenumodel
+ qmenumodel${QMENUMODEL_LIB_SUFFIX}
FILTER
${CMAKE_SOURCE_DIR}/tests/*
${CMAKE_BINARY_DIR}/*
diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp
index 095a022..72f3c1d 100644
--- a/tests/client/convertertest.cpp
+++ b/tests/client/convertertest.cpp
@@ -72,14 +72,26 @@ private:
g_variant_unref(gv);
return result;
}
- bool compare(GVariant *gv, const QVariant::Type type)
+ bool compare(GVariant *gv, const QMetaType::Type type)
{
g_variant_ref_sink(gv);
const QVariant& qv = Converter::toQVariant(gv);
- bool result = (qv.type() == type);
+ bool result = (
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ qv.typeId()
+#else
+ (QMetaType::Type)qv.type()
+#endif
+ == type
+ );
if (!result) {
qWarning() << "types are different: GVariant:" << g_variant_type_peek_string(g_variant_get_type(gv))
- << "Result:" << qv.type()
+ << "Result:" <<
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ qv.typeId()
+#else
+ qv.type()
+#endif
<< "Expected:"<< type;
}
g_variant_unref(gv);
@@ -300,7 +312,7 @@ private Q_SLOTS:
QFETCH(QGVariant, value);
QFETCH(unsigned, expectedType);
- QVERIFY(compare(value, (QVariant::Type) expectedType));
+ QVERIFY(compare(value, (QMetaType::Type) expectedType));
}
void testConvertToQVariantAndBack_data()
@@ -318,7 +330,14 @@ private Q_SLOTS:
GVariant *gv = Converter::toGVariant(qv);
gboolean equals = g_variant_equal(value, gv);
- if (!equals && qv.type() == QVariant::List) {
+ if (!equals && (
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ qv.typeId()
+#else
+ qv.type()
+#endif
+ == QVariant::List
+ )) {
QVERIFY(g_variant_type_is_array(g_variant_get_type(value)));
QVERIFY(g_variant_type_is_tuple(g_variant_get_type(gv)));
@@ -373,7 +392,15 @@ private Q_SLOTS:
QFETCH(QString, value);
QFETCH(unsigned, expectedType);
- QCOMPARE(Converter::toQVariantFromVariantString(value).type(), (QVariant::Type) expectedType);
+ QCOMPARE(
+ Converter::toQVariantFromVariantString(value)
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ .typeId()
+#else
+ .type()
+#endif
+ , (QMetaType::Type) expectedType
+ );
}
};
diff --git a/tests/client/modeltest.cpp b/tests/client/modeltest.cpp
index e6ae82d..59fe6c1 100644
--- a/tests/client/modeltest.cpp
+++ b/tests/client/modeltest.cpp
@@ -106,13 +106,27 @@ private Q_SLOTS:
// Label (String)
QVariant label = m_model.data(m_model.index(0, 0), QMenuModel::Label);
QVERIFY(label.isValid());
- QCOMPARE(label.type(), QVariant::String);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ label.typeId()
+#else
+ label.type()
+#endif
+ , QVariant::String
+ );
QCOMPARE(label.toString(), QString("Menu0"));
// Action (String)
QVariant action = m_model.data(m_model.index(1, 0), QMenuModel::Action);
QVERIFY(action.isValid());
- QCOMPARE(action.type(), QVariant::String);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ action.typeId()
+#else
+ action.type()
+#endif
+ , QVariant::String
+ );
QCOMPARE(action.toString(), QString("Menu1Act"));
// Wait for menu load (submenus are loaded async)
@@ -144,7 +158,14 @@ private Q_SLOTS:
// Boolean
QVariant v = extra["boolean"];
- QCOMPARE(v.type(), QVariant::Bool);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::Bool
+ );
QCOMPARE(v.toBool(), true);
// Byte
@@ -164,32 +185,74 @@ private Q_SLOTS:
// Int32
v = extra["int32"];
- QCOMPARE(v.type(), QVariant::Int);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::Int
+ );
QCOMPARE(v.toInt(), -42);
// UInt32
v = extra["uint32"];
- QCOMPARE(v.type(), QVariant::UInt);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::UInt
+ );
QCOMPARE(v.toUInt(), (uint) 42);
// Int64
v = extra["int64"];
- QCOMPARE(v.type(), QVariant::LongLong);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::LongLong
+ );
QCOMPARE(v.value<long>(), (long) -42);
// UInt64
v = extra["uint64"];
- QCOMPARE(v.type(), QVariant::ULongLong);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::ULongLong
+ );
QCOMPARE(v.value<ulong>(), (ulong) 42);
// Double
v = extra["double"];
- QCOMPARE(v.type(), QVariant::Double);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::Double
+ );
QCOMPARE(v.toDouble(), 42.42);
// String
v = extra["string"];
- QCOMPARE(v.type(), QVariant::String);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::String
+ );
QCOMPARE(v.toString(), QString("42"));
// Map
@@ -199,19 +262,40 @@ private Q_SLOTS:
map.insert("string", "42");
map.insert("double", 42.42);
- QCOMPARE(v.type(), QVariant::Map);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::Map
+ );
QCOMPARE(v.toMap(), map);
// Utf8
v = extra["utf8"];
- QCOMPARE(v.type(), QVariant::String);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::String
+ );
QCOMPARE(v.toString(), QString("dança"));
// Tuple
v = extra["tuple"];
QVariantList lst;
lst << "1" << 2 << 3.3;
- QCOMPARE(v.type(), QVariant::List);
+ QCOMPARE(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ v.typeId()
+#else
+ v.type()
+#endif
+ , QVariant::List
+ );
QCOMPARE(v.toList(), lst);
}
diff --git a/tests/script/CMakeLists.txt b/tests/script/CMakeLists.txt
index fc0db8a..37e72ab 100644
--- a/tests/script/CMakeLists.txt
+++ b/tests/script/CMakeLists.txt
@@ -4,5 +4,5 @@ add_library(dbusmenuscript STATIC dbusmenuscript.cpp)
set_target_properties(dbusmenuscript PROPERTIES COMPILE_FLAGS -fPIC)
-target_link_libraries(dbusmenuscript Qt5::Core Qt5::DBus Qt5::Test)
+target_link_libraries(dbusmenuscript Qt::Core Qt::DBus Qt::Test)
diff --git a/tests/script/dbusmenuscript.cpp b/tests/script/dbusmenuscript.cpp
index 8fa46c7..49fb2c1 100644
--- a/tests/script/dbusmenuscript.cpp
+++ b/tests/script/dbusmenuscript.cpp
@@ -22,7 +22,7 @@
#include <QtTestGui>
#include <QDebug>
-#define WAIT_TIMEOUT 500
+#define WAIT_TIMEOUT 2000
DBusMenuScript::DBusMenuScript()
:m_script(0)