snapd-glib/snapd-glib-1.64-upstream-qt...

698 lines
32 KiB
Diff

From 5e8db3bc888f2daedb7119bc74dafbe46497a60f Mon Sep 17 00:00:00 2001
From: carlosd <60242467+carlosdem@users.noreply.github.com>
Date: Tue, 2 Apr 2024 14:32:00 +1100
Subject: [PATCH] allow dual build of qt5 and qt6 (#147)
Port to Qt 6
Co-authored-by: Aleix Pol <aleixpol@kde.org>
Co-authored-by: Robert Ancell <robert.ancell@canonical.com>
---
.github/workflows/test.yaml | 35 ++++-
meson.build | 15 +-
meson_options.txt | 11 +-
...onfig.cmake.in => SnapdQt5Config.cmake.in} | 0
...make.in => SnapdQt5ConfigVersion.cmake.in} | 0
snapd-qt/SnapdQt6Config.cmake.in | 14 ++
snapd-qt/SnapdQt6ConfigVersion.cmake.in | 10 ++
snapd-qt/markdown-node.cpp | 11 ++
snapd-qt/markdown-parser.cpp | 2 +-
snapd-qt/meson.build | 141 +++++++++++-------
snapd-qt/snapd-qt.pc.in | 4 +-
tests/meson.build | 20 +--
tests/test-markdown-qt.test.in | 3 -
tests/test-markdown-qt5.test.in | 3 +
tests/test-markdown-qt6.test.in | 3 +
tests/test-qt.cpp | 51 +++----
tests/test-qt.test.in | 3 -
tests/test-qt5.test.in | 3 +
tests/test-qt6.test.in | 3 +
19 files changed, 216 insertions(+), 116 deletions(-)
rename snapd-qt/{SnapdConfig.cmake.in => SnapdQt5Config.cmake.in} (100%)
rename snapd-qt/{SnapdConfigVersion.cmake.in => SnapdQt5ConfigVersion.cmake.in} (100%)
create mode 100644 snapd-qt/SnapdQt6Config.cmake.in
create mode 100644 snapd-qt/SnapdQt6ConfigVersion.cmake.in
delete mode 100644 tests/test-markdown-qt.test.in
create mode 100644 tests/test-markdown-qt5.test.in
create mode 100644 tests/test-markdown-qt6.test.in
delete mode 100644 tests/test-qt.test.in
create mode 100644 tests/test-qt5.test.in
create mode 100644 tests/test-qt6.test.in
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 8a8668f2..95f95d77 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -16,13 +16,18 @@ jobs:
- fedora:latest
soup:
- libsoup3
+ qt:
+ - qt6
include:
- image: ubuntu:22.04
soup: libsoup2
+ qt: qt6
- image: ubuntu:20.04
soup: libsoup2
+ qt: qt5
- image: ubuntu:18.04
soup: libsoup2
+ qt: qt5
runs-on: ubuntu-latest
container: ${{ matrix.image }}
@@ -40,7 +45,7 @@ jobs:
if: startsWith(matrix.image, 'ubuntu:')
run: |
apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gtk-doc-tools libgirepository1.0-dev libglib2.0-dev libjson-glib-dev ninja-build python3-pip python3-setuptools python3-wheel qtbase5-dev qtdeclarative5-dev valac
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gtk-doc-tools libgirepository1.0-dev libglib2.0-dev libjson-glib-dev ninja-build python3-pip python3-setuptools python3-wheel valac
- name: Install libsoup3 dependencies (Ubuntu)
if: startsWith(matrix.image, 'ubuntu:') && matrix.soup == 'libsoup3'
@@ -52,10 +57,20 @@ jobs:
run: |
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libsoup2.4-dev
+ - name: Install Qt5 dependencies (Ubuntu)
+ if: startsWith(matrix.image, 'ubuntu:') && matrix.qt == 'qt5'
+ run: |
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends qtbase5-dev qtdeclarative5-dev
+
+ - name: Install Qt6 dependencies (Ubuntu)
+ if: startsWith(matrix.image, 'ubuntu:') && matrix.qt == 'qt6'
+ run: |
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends qt6-base-dev qt6-declarative-dev
+
- name: Install dependencies (Fedora)
if: startsWith(matrix.image, 'fedora:')
run: |
- dnf install -y gcc gcc-c++ gobject-introspection-devel glib2-devel gtk-doc json-glib-devel libsoup3-devel ninja-build python3-pip qt5-qtbase-devel qt5-qtdeclarative-devel redhat-rpm-config vala
+ dnf install -y gcc gcc-c++ gobject-introspection-devel glib2-devel gtk-doc json-glib-devel libsoup3-devel ninja-build python3-pip qt6-qtbase-devel qt6-qtdeclarative-devel redhat-rpm-config vala
- name: Install meson
if: matrix.image != 'ubuntu:rolling'
@@ -67,15 +82,25 @@ jobs:
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends meson
- name: Configure
- if: matrix.soup == 'libsoup3'
+ if: matrix.soup == 'libsoup3' && matrix.qt != 'qt5'
run: |
meson _build
- - name: Configure (libsoup2.4)
- if: matrix.soup == 'libsoup2'
+ - name: Configure (Qt5)
+ if: matrix.soup == 'libsoup3' && matrix.qt == 'qt5'
run: |
+ meson _build -Dqt=5=true -Dqt6=false
+
+ - name: Configure (libsoup2.4)
+ if: matrix.soup == 'libsoup2' && matrix.qt != 'qt5'
+ run:
meson _build -Dsoup2=true
+ - name: Configure (libsoup2.4 and Qt5)
+ if: matrix.soup == 'libsoup2' && matrix.qt == 'qt5'
+ run: |
+ meson _build -Dsoup2=true -Dqt5=true -Dqt6=false
+
- name: Build
run: |
ninja -C _build
diff --git a/meson.build b/meson.build
index b9f98d37..76637a7a 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,8 @@
project ('snapd-glib', [ 'c', 'cpp' ],
version: '1.64',
- meson_version: '>= 0.43.0',
- default_options : [ 'c_std=c11', 'cpp_std=c++11' ])
+ meson_version: '>= 0.58.0',
+ default_options : [ 'c_std=c11' ])
+
glib_dep = dependency ('glib-2.0', version: '>= 2.46')
gio_dep = dependency ('gio-2.0', version: '>= 2.46')
@@ -13,18 +14,14 @@ else
endif
json_glib_dep = dependency ('json-glib-1.0', version: '>= 1.1.2')
-if get_option ('qt-bindings')
- qt5_core_dep = dependency ('qt5', modules: [ 'Core' ])
- qt5_network_dep = dependency ('qt5', modules: [ 'Network' ])
- qml_dep = dependency ('qt5', modules: [ 'Qml' ])
-endif
-
datadir = join_paths (get_option ('prefix'), get_option ('datadir'))
includedir = join_paths (get_option ('prefix'), get_option ('includedir'))
libdir = join_paths (get_option ('prefix'), get_option ('libdir'))
subdir ('snapd-glib')
-subdir ('snapd-qt')
+if get_option('qt5') or get_option('qt6')
+ subdir ('snapd-qt')
+endif
subdir ('tests')
subdir ('examples')
subdir ('doc')
diff --git a/meson_options.txt b/meson_options.txt
index ad9ac9ca..7700d929 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,9 +7,14 @@ option('docs',
option('vala-bindings',
type: 'boolean', value: true,
description: 'Build the Vala bindings (requires introspection)')
-option('qt-bindings',
- type: 'boolean', value: true,
- description: 'Build the Qt bindings')
+option('qt5',
+ type : 'boolean',
+ value : false,
+ description: 'Build the Qt5 bindings')
+option('qt6',
+ type : 'boolean',
+ value : true,
+ description: 'Build the Qt6 bindings')
option('qml-bindings',
type: 'boolean', value: true,
description: 'Build the QML bindings (requires the Qt bindings)')
diff --git a/snapd-qt/SnapdConfig.cmake.in b/snapd-qt/SnapdQt5Config.cmake.in
similarity index 100%
rename from snapd-qt/SnapdConfig.cmake.in
rename to snapd-qt/SnapdQt5Config.cmake.in
diff --git a/snapd-qt/SnapdConfigVersion.cmake.in b/snapd-qt/SnapdQt5ConfigVersion.cmake.in
similarity index 100%
rename from snapd-qt/SnapdConfigVersion.cmake.in
rename to snapd-qt/SnapdQt5ConfigVersion.cmake.in
diff --git a/snapd-qt/SnapdQt6Config.cmake.in b/snapd-qt/SnapdQt6Config.cmake.in
new file mode 100644
index 00000000..69afb05b
--- /dev/null
+++ b/snapd-qt/SnapdQt6Config.cmake.in
@@ -0,0 +1,14 @@
+# SNAPD_INCLUDE_DIRS - The snapd-qt include directories
+# SNAPD_LIBRARIES - The libraries needed to use snapd-qt
+
+set(SNAPD_LIBRARIES @libdir@/lib@library_name@.so)
+set(SNAPD_INCLUDE_DIRS @includedir@/@library_name@/)
+
+add_library(Snapd::Core SHARED IMPORTED)
+set_target_properties(Snapd::Core PROPERTIES
+ IMPORTED_LINK_DEPENDENT_LIBRARIES "Qt6::Core"
+ IMPORTED_LOCATION "${SNAPD_LIBRARIES}"
+ IMPORTED_SONAME "lib@library_name@.so"
+ )
+
+set_property(TARGET Snapd::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SNAPD_INCLUDE_DIRS})
diff --git a/snapd-qt/SnapdQt6ConfigVersion.cmake.in b/snapd-qt/SnapdQt6ConfigVersion.cmake.in
new file mode 100644
index 00000000..e6719826
--- /dev/null
+++ b/snapd-qt/SnapdQt6ConfigVersion.cmake.in
@@ -0,0 +1,10 @@
+set(PACKAGE_VERSION @version@)
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
diff --git a/snapd-qt/markdown-node.cpp b/snapd-qt/markdown-node.cpp
index 2be1751e..2e87707b 100644
--- a/snapd-qt/markdown-node.cpp
+++ b/snapd-qt/markdown-node.cpp
@@ -62,3 +62,14 @@ QSnapdMarkdownNode *QSnapdMarkdownNode::child (int n) const
return NULL;
return new QSnapdMarkdownNode (children->pdata[n]);
}
+
+QSnapdMarkdownNode & QSnapdMarkdownNode::operator=(const QSnapdMarkdownNode& node)
+{
+ if (&node == this) {
+ return *this;
+ }
+ g_object_unref(wrapped_object);
+ wrapped_object = node.wrapped_object;
+ g_object_ref(wrapped_object);
+ return *this;
+}
diff --git a/snapd-qt/markdown-parser.cpp b/snapd-qt/markdown-parser.cpp
index 751592c3..1a305ad9 100644
--- a/snapd-qt/markdown-parser.cpp
+++ b/snapd-qt/markdown-parser.cpp
@@ -56,7 +56,7 @@ bool QSnapdMarkdownParser::preserveWhitespace () const
QList<QSnapdMarkdownNode> QSnapdMarkdownParser::parse (const QString &text) const
{
Q_D(const QSnapdMarkdownParser);
- g_autoptr(GPtrArray) nodes = snapd_markdown_parser_parse (d->parser, text.toStdString ().c_str ());
+ g_autoptr(GPtrArray) nodes = snapd_markdown_parser_parse (d->parser, text.toUtf8().constData());
QList<QSnapdMarkdownNode> nodes_list;
for (uint i = 0; i < nodes->len; i++) {
SnapdMarkdownNode *node = (SnapdMarkdownNode *) g_ptr_array_index (nodes, i);
diff --git a/snapd-qt/meson.build b/snapd-qt/meson.build
index 74687852..856829e7 100644
--- a/snapd-qt/meson.build
+++ b/snapd-qt/meson.build
@@ -1,15 +1,47 @@
-library_name = 'snapd-qt'
-if not get_option('soup2')
- library_name += '-2'
+if get_option('qt5') and get_option('qt6')
+ error('Both the "qt5" and "qt6" bindings are selected, snapd-glib only supports building one Qt major version at a time.')
+endif
+
+if get_option('qt5')
+ qt_min_version = '5.9.5'
+ qt_version = 'qt5'
+ qt_core_camel = 'Qt5Core'
+ description = 'Snapd Qt'
+ cmake_base_name = 'SnapdQt5'
+ library_name = 'snapd-qt'
+ qt_core_dep = dependency ('qt5', modules: [ 'Core' ])
+ qt_network_dep = dependency ('qt5', modules: [ 'Network' ])
+ qml_dep = dependency ('qt5', modules: [ 'Qml' ])
endif
-qt_name= 'Snapd'
+if get_option('qt6')
+ qt_min_version = '6.2.4'
+ qt_version = 'qt6'
+ qt_core_camel = 'Qt6Core'
+ description = 'Snapd Qt'
+ cmake_base_name = 'SnapdQt6'
+ library_name = 'snapd-qt'
+ qt6_core_dep = dependency ('qt6', modules: [ 'Core' ])
+ qt6_network_dep = dependency ('qt6', modules: [ 'Network' ])
+ qml_dep = dependency ('qt6', modules: [ 'Qml' ])
+endif
+
+qt_name = 'Snapd'
if not get_option('soup2')
- qt_name += '2'
+ library_name += '-2'
+ qt_name += '2'
endif
+qt = import(qt_version)
+qt_dep = dependency(
+ qt_version,
+ modules: ['Core', 'Network'],
+ version: f'>= @qt_min_version@',
+ include_type: 'system'
+)
+
install_header_dir = join_paths (includedir, library_name, 'Snapd')
-qml_dir = join_paths (libdir, 'qt5', 'qml', qt_name)
+qml_dir = join_paths (libdir, f'@qt_version@', 'qml', f'@qt_name@')
cmake_dir = join_paths (libdir, 'cmake', qt_name)
source_cpp = [
@@ -113,60 +145,59 @@ source_private_h = [
'variant.h',
]
-if get_option ('qt-bindings')
- qt5 = import ('qt5')
- moc_files = qt5.preprocess (moc_headers: [ source_h, source_private_h ],
- dependencies: [ qt5_core_dep, qt5_network_dep ])
-
- snapd_qt_lib = library (library_name,
- source_cpp, moc_files,
- version: '1.0.0',
- dependencies: [ qt5_core_dep, qt5_network_dep, glib_dep, gio_dep, snapd_glib_dep ],
- cpp_args: [ '-DQT_NO_SIGNALS_SLOTS_KEYWORDS' ],
- install: true)
-
- snapd_qt_dep = declare_dependency (link_with: snapd_qt_lib,
- dependencies: [ qt5_network_dep ],
- include_directories: include_directories ('.'))
-
- install_headers (source_h + source_alias_h,
- install_dir: install_header_dir)
-
- pc = import ('pkgconfig')
- pc.generate (libraries: snapd_qt_lib,
- filebase: library_name,
- name: 'Snapd Qt',
- description: 'Libary for accessing snapd',
- version: meson.project_version ())
-
- install_data ('qmldir',
- install_dir: qml_dir)
-
- cmake_conf = configuration_data ()
- cmake_conf.set ('libdir', libdir)
- cmake_conf.set ('includedir', includedir)
- cmake_conf.set ('version', meson.project_version ())
- cmake_conf.set ('library_name', library_name)
- cmake_file = configure_file (input: 'SnapdConfig.cmake.in',
- output: 'SnapdConfig.cmake',
- configuration: cmake_conf)
- cmake_version_file = configure_file (input: 'SnapdConfigVersion.cmake.in',
- output: 'SnapdConfigVersion.cmake',
- configuration: cmake_conf)
- install_data (cmake_file, cmake_version_file,
- install_dir: cmake_dir)
+moc_files = qt.preprocess (moc_headers: [ source_h, source_private_h ],
+ dependencies: [ qt_dep ])
+
+snapd_qt_lib = library (library_name,
+ source_cpp, moc_files,
+ version: '1.0.0',
+ dependencies: [ qt_dep, glib_dep, gio_dep, snapd_glib_dep ],
+ cpp_args: [ '-DQT_NO_SIGNALS_SLOTS_KEYWORDS' ],
+ install: true)
+
+snapd_qt_dep = declare_dependency (link_with: snapd_qt_lib,
+ dependencies: qt_dep,
+ include_directories: include_directories ('.'))
+
+install_headers (source_h + source_alias_h,
+ install_dir: install_header_dir)
+
+pc = import ('pkgconfig')
+pc_required_qt=f'@qt_core_camel@'
+pc.generate (libraries: snapd_qt_lib,
+ filebase: library_name,
+ name: 'Snapd Qt',
+ description: 'Library for accessing snapd',
+ version: meson.project_version (),
+ requires: pc_required_qt,)
+
+install_data ('qmldir',
+ install_dir: qml_dir)
+
+cmake_conf = configuration_data ()
+cmake_conf.set ('libdir', libdir)
+cmake_conf.set ('includedir', includedir)
+cmake_conf.set ('version', meson.project_version ())
+cmake_conf.set ('library_name', library_name)
+cmake_file = configure_file (input: f'@cmake_base_name@Config.cmake.in',
+ output: 'SnapdConfig.cmake',
+ configuration: cmake_conf)
+cmake_version_file = configure_file (input: f'@cmake_base_name@ConfigVersion.cmake.in',
+ output: 'SnapdConfigVersion.cmake',
+ configuration: cmake_conf)
+install_data (cmake_file, cmake_version_file,
+ install_dir: cmake_dir)
if get_option ('qml-bindings')
install_data ('qmldir',
install_dir: qml_dir)
- qml_moc_files = qt5.preprocess (moc_headers: 'qml-plugin.h',
+ qml_moc_files = qt.preprocess (moc_headers: 'qml-plugin.h',
dependencies: qml_dep)
library (qt_name,
- 'qml-plugin.cpp', qml_moc_files,
- dependencies: [ qml_dep, snapd_qt_dep ],
- build_rpath: qml_dir,
- install: true,
- install_dir: qml_dir)
+ 'qml-plugin.cpp', qml_moc_files,
+ dependencies: [ qml_dep, snapd_qt_dep ],
+ build_rpath: qml_dir,
+ install: true,
+ install_dir: qml_dir)
endif
-endif
diff --git a/snapd-qt/snapd-qt.pc.in b/snapd-qt/snapd-qt.pc.in
index 60bc7d6e..fe4747ff 100644
--- a/snapd-qt/snapd-qt.pc.in
+++ b/snapd-qt/snapd-qt.pc.in
@@ -4,8 +4,8 @@ libdir=@libdir@
includedir=@includedir@
Name: Snapd Qt
-Description: Libary for accessing snapd
+Description: Library for accessing snapd
Version: @VERSION@
Libs: -L${libdir} -lsnapd-qt
Cflags: -I${includedir}/snapd-qt
-Requires: Qt5Core
+Requires: @pc_required_qt@
diff --git a/tests/meson.build b/tests/meson.build
index dd4ac7ef..bc7882e6 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -38,31 +38,31 @@ test_file = configure_file (input: 'test-markdown-glib.test.in',
configuration: test_data_conf)
install_data (test_file, install_dir: installed_tests_data_dir)
-if get_option ('qt-bindings')
- moc_files = qt5.preprocess (moc_headers: [ 'test-qt.h' ])
+if get_option('qt5') or get_option('qt6')
+ moc_files = qt.preprocess (moc_headers: [ 'test-qt.h' ])
- test_executable = executable ('test-qt',
+ test_executable = executable (f'test-@qt_version@',
'test-qt.cpp', moc_files,
dependencies: [ glib_dep, snapd_qt_dep ],
link_with: [ mock_snapd_lib ],
cpp_args: [ '-DVERSION="@0@"'.format (meson.project_version ()) ],
install_dir: installed_tests_exec_dir,
install: true)
- test ('Tests (Qt)', test_executable, timeout: 600)
- test_file = configure_file (input: 'test-qt.test.in',
- output: 'test-qt.test',
+ test (f'Tests (@qt_version@', test_executable, timeout: 600)
+ test_file = configure_file (input: f'test-@qt_version@.test.in',
+ output: f'test-@qt_version@.test',
configuration: test_data_conf)
install_data (test_file, install_dir: installed_tests_data_dir)
- test_executable = executable ('test-markdown-qt',
+ test_executable = executable (f'test-markdown-@qt_version@',
'test-markdown-qt.cpp',
dependencies: [ glib_dep, snapd_qt_dep ],
link_with: [ mock_snapd_lib ],
install_dir: installed_tests_exec_dir,
install: true)
- test ('Markdown tests (Qt)', test_executable, timeout: 600)
- test_file = configure_file (input: 'test-markdown-qt.test.in',
- output: 'test-markdown-qt.test',
+ test (f'Markdown tests (@qt_version@)', test_executable, timeout: 600)
+ test_file = configure_file (input: f'test-markdown-@qt_version@.test.in',
+ output: f'test-markdown-@qt_version@.test',
configuration: test_data_conf)
install_data (test_file, install_dir: installed_tests_data_dir)
endif
diff --git a/tests/test-markdown-qt.test.in b/tests/test-markdown-qt.test.in
deleted file mode 100644
index 31d23f42..00000000
--- a/tests/test-markdown-qt.test.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[Test]
-Type=session
-Exec=@installed_tests_exec_dir@/test-markdown-qt
diff --git a/tests/test-markdown-qt5.test.in b/tests/test-markdown-qt5.test.in
new file mode 100644
index 00000000..8ca657da
--- /dev/null
+++ b/tests/test-markdown-qt5.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@installed_tests_exec_dir@/test-markdown-qt5
diff --git a/tests/test-markdown-qt6.test.in b/tests/test-markdown-qt6.test.in
new file mode 100644
index 00000000..7482ba7a
--- /dev/null
+++ b/tests/test-markdown-qt6.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@installed_tests_exec_dir@/test-markdown-qt6
diff --git a/tests/test-qt.cpp b/tests/test-qt.cpp
index 04243a51..105f3fb2 100644
--- a/tests/test-qt.cpp
+++ b/tests/test-qt.cpp
@@ -10,6 +10,7 @@
#include "mock-snapd.h"
#include <QBuffer>
+#include <QVariant>
#include <Snapd/Client>
#include <Snapd/Assertion>
@@ -2918,32 +2919,32 @@ test_get_connections_attributes ()
check_names_match (connection->plugAttributeNames (), QStringList () << "plug-string-key" << "plug-int-key" << "plug-bool-key" << "plug-number-key");
g_assert_true (connection->hasPlugAttribute ("plug-string-key"));
- g_assert_true (connection->plugAttribute ("plug-string-key").type () == (QVariant::Type) QMetaType::QString);
+ g_assert_true (connection->plugAttribute ("plug-string-key").type () == QMetaType::QString);
g_assert_true (connection->plugAttribute ("plug-string-key").toString () == "value");
g_assert_true (connection->hasPlugAttribute ("plug-int-key"));
- g_assert_true (connection->plugAttribute ("plug-int-key").type () == (QVariant::Type) QMetaType::LongLong);
+ g_assert_true (connection->plugAttribute ("plug-int-key").type () == QMetaType::LongLong);
g_assert_cmpint (connection->plugAttribute ("plug-int-key").toLongLong (), ==, 42);
g_assert_true (connection->hasPlugAttribute ("plug-bool-key"));
- g_assert_true (connection->plugAttribute ("plug-bool-key").type () == (QVariant::Type) QMetaType::Bool);
+ g_assert_true (connection->plugAttribute ("plug-bool-key").type () == QMetaType::Bool);
g_assert_true (connection->plugAttribute ("plug-bool-key").toBool ());
g_assert_true (connection->hasPlugAttribute ("plug-number-key"));
- g_assert_true (connection->plugAttribute ("plug-number-key").type () == (QVariant::Type) QMetaType::Double);
+ g_assert_true (connection->plugAttribute ("plug-number-key").type () == QMetaType::Double);
g_assert_cmpfloat (connection->plugAttribute ("plug-number-key").toDouble (), ==, 1.25);
g_assert_false (connection->hasPlugAttribute ("plug-invalid-key"));
g_assert_false (connection->plugAttribute ("plug-invalid-key").isValid ());
check_names_match (connection->slotAttributeNames (), QStringList () << "slot-string-key" << "slot-int-key" << "slot-bool-key" << "slot-number-key");
g_assert_true (connection->hasSlotAttribute ("slot-string-key"));
- g_assert_true (connection->slotAttribute ("slot-string-key").type () == (QVariant::Type) QMetaType::QString);
+ g_assert_true (connection->slotAttribute ("slot-string-key").type () == QMetaType::QString);
g_assert_true (connection->slotAttribute ("slot-string-key").toString () == "value");
g_assert_true (connection->hasSlotAttribute ("slot-int-key"));
- g_assert_true (connection->slotAttribute ("slot-int-key").type () == (QVariant::Type) QMetaType::LongLong);
+ g_assert_true (connection->slotAttribute ("slot-int-key").type () == QMetaType::LongLong);
g_assert_cmpint (connection->slotAttribute ("slot-int-key").toLongLong (), ==, 42);
g_assert_true (connection->hasSlotAttribute ("slot-bool-key"));
- g_assert_true (connection->slotAttribute ("slot-bool-key").type () == (QVariant::Type) QMetaType::Bool);
+ g_assert_true (connection->slotAttribute ("slot-bool-key").type () == QMetaType::Bool);
g_assert_true (connection->slotAttribute ("slot-bool-key").toBool ());
g_assert_true (connection->hasSlotAttribute ("slot-number-key"));
- g_assert_true (connection->slotAttribute ("slot-number-key").type () == (QVariant::Type) QMetaType::Double);
+ g_assert_true (connection->slotAttribute ("slot-number-key").type () == QMetaType::Double);
g_assert_cmpfloat (connection->slotAttribute ("slot-number-key").toDouble (), ==, 1.25);
g_assert_false (connection->hasSlotAttribute ("slot-invalid-key"));
g_assert_false (connection->slotAttribute ("slot-invalid-key").isValid ());
@@ -2952,16 +2953,16 @@ test_get_connections_attributes ()
QScopedPointer<QSnapdPlug> plug (getConnectionsRequest->plug (0));
check_names_match (plug->attributeNames (), QStringList () << "plug-string-key" << "plug-int-key" << "plug-bool-key" << "plug-number-key");
g_assert_true (plug->hasAttribute ("plug-string-key"));
- g_assert_true (plug->attribute ("plug-string-key").type () == (QVariant::Type) QMetaType::QString);
+ g_assert_true (plug->attribute ("plug-string-key").type () == QMetaType::QString);
g_assert_true (plug->attribute ("plug-string-key").toString () == "value");
g_assert_true (plug->hasAttribute ("plug-int-key"));
- g_assert_true (plug->attribute ("plug-int-key").type () == (QVariant::Type) QMetaType::LongLong);
+ g_assert_true (plug->attribute ("plug-int-key").type () == QMetaType::LongLong);
g_assert_cmpint (plug->attribute ("plug-int-key").toLongLong (), ==, 42);
g_assert_true (plug->hasAttribute ("plug-bool-key"));
- g_assert_true (plug->attribute ("plug-bool-key").type () == (QVariant::Type) QMetaType::Bool);
+ g_assert_true (plug->attribute ("plug-bool-key").type () == QMetaType::Bool);
g_assert_true (plug->attribute ("plug-bool-key").toBool ());
g_assert_true (plug->hasAttribute ("plug-number-key"));
- g_assert_true (plug->attribute ("plug-number-key").type () == (QVariant::Type) QMetaType::Double);
+ g_assert_true (plug->attribute ("plug-number-key").type () == QMetaType::Double);
g_assert_cmpfloat (plug->attribute ("plug-number-key").toDouble (), ==, 1.25);
g_assert_false (plug->hasAttribute ("plug-invalid-key"));
g_assert_false (plug->attribute ("plug-invalid-key").isValid ());
@@ -2970,16 +2971,16 @@ test_get_connections_attributes ()
QScopedPointer<QSnapdSlot> slot (getConnectionsRequest->slot (0));
check_names_match (slot->attributeNames (), QStringList () << "slot-string-key" << "slot-int-key" << "slot-bool-key" << "slot-number-key");
g_assert_true (slot->hasAttribute ("slot-string-key"));
- g_assert_true (slot->attribute ("slot-string-key").type () == (QVariant::Type) QMetaType::QString);
+ g_assert_true (slot->attribute ("slot-string-key").type () == QMetaType::QString);
g_assert_true (slot->attribute ("slot-string-key").toString () == "value");
g_assert_true (slot->hasAttribute ("slot-int-key"));
- g_assert_true (slot->attribute ("slot-int-key").type () == (QVariant::Type) QMetaType::LongLong);
+ g_assert_true (slot->attribute ("slot-int-key").type () == QMetaType::LongLong);
g_assert_cmpint (slot->attribute ("slot-int-key").toLongLong (), ==, 42);
g_assert_true (slot->hasAttribute ("slot-bool-key"));
- g_assert_true (slot->attribute ("slot-bool-key").type () == (QVariant::Type) QMetaType::Bool);
+ g_assert_true (slot->attribute ("slot-bool-key").type () == QMetaType::Bool);
g_assert_true (slot->attribute ("slot-bool-key").toBool ());
g_assert_true (slot->hasAttribute ("slot-number-key"));
- g_assert_true (slot->attribute ("slot-number-key").type () == (QVariant::Type) QMetaType::Double);
+ g_assert_true (slot->attribute ("slot-number-key").type () == QMetaType::Double);
g_assert_cmpfloat (slot->attribute ("slot-number-key").toDouble (), ==, 1.25);
g_assert_false (slot->hasAttribute ("slot-invalid-key"));
g_assert_false (slot->attribute ("slot-invalid-key").isValid ());
@@ -3123,13 +3124,13 @@ test_get_interfaces_attributes ()
QScopedPointer<QSnapdPlug> plug (getInterfacesRequest->plug (0));
check_names_match (plug->attributeNames (), QStringList () << "plug-string-key" << "plug-int-key" << "plug-bool-key");
g_assert_true (plug->hasAttribute ("plug-string-key"));
- g_assert_true (plug->attribute ("plug-string-key").type () == (QVariant::Type) QMetaType::QString);
+ g_assert_true (plug->attribute ("plug-string-key").type () == QMetaType::QString);
g_assert_true (plug->attribute ("plug-string-key").toString () == "value");
g_assert_true (plug->hasAttribute ("plug-int-key"));
- g_assert_true (plug->attribute ("plug-int-key").type () == (QVariant::Type) QMetaType::LongLong);
+ g_assert_true (plug->attribute ("plug-int-key").type () == QMetaType::LongLong);
g_assert_cmpint (plug->attribute ("plug-int-key").toLongLong (), ==, 42);
g_assert_true (plug->hasAttribute ("plug-bool-key"));
- g_assert_true (plug->attribute ("plug-bool-key").type () == (QVariant::Type) QMetaType::Bool);
+ g_assert_true (plug->attribute ("plug-bool-key").type () == QMetaType::Bool);
g_assert_true (plug->attribute ("plug-bool-key").toBool ());
g_assert_false (plug->hasAttribute ("plug-invalid-key"));
g_assert_false (plug->attribute ("plug-invalid-key").isValid ());
@@ -3138,13 +3139,13 @@ test_get_interfaces_attributes ()
QScopedPointer<QSnapdSlot> slot (getInterfacesRequest->slot (0));
check_names_match (slot->attributeNames (), QStringList () << "slot-string-key" << "slot-int-key" << "slot-bool-key");
g_assert_true (slot->hasAttribute ("slot-string-key"));
- g_assert_true (slot->attribute ("slot-string-key").type () == (QVariant::Type) QMetaType::QString);
+ g_assert_true (slot->attribute ("slot-string-key").type () == QMetaType::QString);
g_assert_true (slot->attribute ("slot-string-key").toString () == "value");
g_assert_true (slot->hasAttribute ("slot-int-key"));
- g_assert_true (slot->attribute ("slot-int-key").type () == (QVariant::Type) QMetaType::LongLong);
+ g_assert_true (slot->attribute ("slot-int-key").type () == QMetaType::LongLong);
g_assert_cmpint (slot->attribute ("slot-int-key").toLongLong (), ==, 42);
g_assert_true (slot->hasAttribute ("slot-bool-key"));
- g_assert_true (slot->attribute ("slot-bool-key").type () == (QVariant::Type) QMetaType::Bool);
+ g_assert_true (slot->attribute ("slot-bool-key").type () == QMetaType::Bool);
g_assert_true (slot->attribute ("slot-bool-key").toBool ());
g_assert_false (slot->hasAttribute ("slot-invalid-key"));
g_assert_false (slot->attribute ("slot-invalid-key").isValid ());
@@ -3894,7 +3895,7 @@ test_find_channels ()
if (channel->name () == "stable") {
g_assert_true (channel->track () == "latest");
g_assert_true (channel->risk () == "stable");
- g_assert_true (channel->branch () == NULL);
+ g_assert_true (channel->branch ().isEmpty());
g_assert_true (channel->revision () == "REVISION");
g_assert_true (channel->version () == "VERSION");
g_assert_true (channel->epoch () == "0");
@@ -3907,7 +3908,7 @@ test_find_channels ()
g_assert_true (channel->name () == "beta");
g_assert_true (channel->track () == "latest");
g_assert_true (channel->risk () == "beta");
- g_assert_true (channel->branch () == NULL);
+ g_assert_true (channel->branch ().isEmpty());
g_assert_true (channel->revision () == "BETA-REVISION");
g_assert_true (channel->version () == "BETA-VERSION");
g_assert_true (channel->epoch () == "1");
@@ -3926,7 +3927,7 @@ test_find_channels ()
if (channel->name () == "insider/stable") {
g_assert_true (channel->track () == "insider");
g_assert_true (channel->risk () == "stable");
- g_assert_true (channel->branch () == NULL);
+ g_assert_true (channel->branch ().isEmpty());
g_assert_true (channel->releasedAt ().isNull ());
matched_track = TRUE;
}
diff --git a/tests/test-qt.test.in b/tests/test-qt.test.in
deleted file mode 100644
index cb2463bd..00000000
--- a/tests/test-qt.test.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[Test]
-Type=session
-Exec=@installed_tests_exec_dir@/test-qt
diff --git a/tests/test-qt5.test.in b/tests/test-qt5.test.in
new file mode 100644
index 00000000..628fdb27
--- /dev/null
+++ b/tests/test-qt5.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@installed_tests_exec_dir@/test-qt5
diff --git a/tests/test-qt6.test.in b/tests/test-qt6.test.in
new file mode 100644
index 00000000..d1109649
--- /dev/null
+++ b/tests/test-qt6.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@installed_tests_exec_dir@/test-qt6