From dbac3e9225161b1d5a6b2a5cef494fc4acaf9446 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 19 Jan 2024 17:27:27 +0100 Subject: [PATCH] Vcpkg: Move test creation closer to tested code Change-Id: Id135a9225bcc8806d89c7589d68f9c21200d9374 Reviewed-by: Jarek Kobus --- src/plugins/vcpkg/vcpkg_test.cpp | 20 ++++++++++++++++---- src/plugins/vcpkg/vcpkg_test.h | 18 ++---------------- src/plugins/vcpkg/vcpkgplugin.cpp | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/plugins/vcpkg/vcpkg_test.cpp b/src/plugins/vcpkg/vcpkg_test.cpp index 71e3d50a848..1c2918b4097 100644 --- a/src/plugins/vcpkg/vcpkg_test.cpp +++ b/src/plugins/vcpkg/vcpkg_test.cpp @@ -10,11 +10,16 @@ namespace Vcpkg::Internal { -VcpkgSearchTest::VcpkgSearchTest(QObject *parent) - : QObject(parent) -{ } +class VcpkgSearchTest : public QObject +{ + Q_OBJECT -VcpkgSearchTest::~VcpkgSearchTest() = default; +private slots: + void testVcpkgJsonParser_data(); + void testVcpkgJsonParser(); + void testAddDependency_data(); + void testAddDependency(); +}; void VcpkgSearchTest::testVcpkgJsonParser_data() { @@ -178,4 +183,11 @@ void VcpkgSearchTest::testAddDependency() QCOMPARE(QString::fromUtf8(result), modifiedVcpkgManifestJsonData); } +QObject *createVcpkgSearchTest() +{ + return new VcpkgSearchTest; +} + } // namespace Vcpkg::Internal + +#include "vcpkg_test.moc" diff --git a/src/plugins/vcpkg/vcpkg_test.h b/src/plugins/vcpkg/vcpkg_test.h index 2bc386e7aa1..d66cc704316 100644 --- a/src/plugins/vcpkg/vcpkg_test.h +++ b/src/plugins/vcpkg/vcpkg_test.h @@ -3,24 +3,10 @@ #pragma once -#include -#include +#include namespace Vcpkg::Internal { -class VcpkgSearchTest : public QObject -{ - Q_OBJECT - -public: - VcpkgSearchTest(QObject *parent = nullptr); - ~VcpkgSearchTest(); - -private slots: - void testVcpkgJsonParser_data(); - void testVcpkgJsonParser(); - void testAddDependency_data(); - void testAddDependency(); -}; +QObject *createVcpkgSearchTest(); } // namespace Vcpkg::Internal diff --git a/src/plugins/vcpkg/vcpkgplugin.cpp b/src/plugins/vcpkg/vcpkgplugin.cpp index 2247bda2cf5..cc3abc097da 100644 --- a/src/plugins/vcpkg/vcpkgplugin.cpp +++ b/src/plugins/vcpkg/vcpkgplugin.cpp @@ -26,7 +26,7 @@ public: setupVcpkgManifestEditor(); #ifdef WITH_TESTS - addTest(); + addTestCreator(createVcpkgSearchTest); #endif }