From e845a551a4f26933cd7e12d9454ed8e8c82680fa Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 19 Jan 2024 17:03:41 +0100 Subject: [PATCH] PerfProfiler: Move resource counter test creation closer to test code Change-Id: Ie4fb52d171eabfa4440ed937ea57003a152f7338 Reviewed-by: Jarek Kobus --- .../perfprofiler/perfprofilerplugin.cpp | 2 +- .../tests/perfresourcecounter_test.cpp | 28 ++++++++++++++++--- .../tests/perfresourcecounter_test.h | 21 ++------------ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/plugins/perfprofiler/perfprofilerplugin.cpp b/src/plugins/perfprofiler/perfprofilerplugin.cpp index 93568849496..a5db90dbdee 100644 --- a/src/plugins/perfprofiler/perfprofilerplugin.cpp +++ b/src/plugins/perfprofiler/perfprofilerplugin.cpp @@ -29,7 +29,7 @@ class PerfProfilerPlugin final : public ExtensionSystem::IPlugin #if WITH_TESTS // addTest(); // FIXME these tests have to get rewritten - addTest(); + addTestCreator(createPerfResourceCounterTest); #endif // WITH_TESTS } diff --git a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp index eac4cf7506b..74a8049f231 100644 --- a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp +++ b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp @@ -5,8 +5,7 @@ #include #include -namespace PerfProfiler { -namespace Internal { +namespace PerfProfiler::Internal { struct SizePayload : public NoPayload { @@ -71,6 +70,22 @@ static void fill(Counter &counter, const typename Counter::Container &container, QCOMPARE(sum(container), 0); } +class PerfResourceCounterTest final : public QObject +{ + Q_OBJECT + +private slots: + void testMallocFree(); + void testRandomFill(); + void testUnitSized(); + void testRandomAlternate(); + void testGuesses(); + void testNegative(); + void testInvalidId(); + void testMultiCounter(); + void testMove(); +}; + void PerfResourceCounterTest::testMallocFree() { SizeCounter::Container intContainer; @@ -345,6 +360,11 @@ void PerfResourceCounterTest::testMove() QCOMPARE(counter.currentTotal(), 500ll); } -} // namespace Internal -} // namespace PerfProfiler +QObject *createPerfResourceCounterTest() +{ + return new PerfResourceCounterTest; +} +} // PerfProfiler::Internal + +#include "perfresourcecounter_test.moc" diff --git a/src/plugins/perfprofiler/tests/perfresourcecounter_test.h b/src/plugins/perfprofiler/tests/perfresourcecounter_test.h index ad5178acc3b..b48c3895c57 100644 --- a/src/plugins/perfprofiler/tests/perfresourcecounter_test.h +++ b/src/plugins/perfprofiler/tests/perfresourcecounter_test.h @@ -5,23 +5,8 @@ #include -namespace PerfProfiler { -namespace Internal { +namespace PerfProfiler::Internal { -class PerfResourceCounterTest : public QObject -{ - Q_OBJECT -private slots: - void testMallocFree(); - void testRandomFill(); - void testUnitSized(); - void testRandomAlternate(); - void testGuesses(); - void testNegative(); - void testInvalidId(); - void testMultiCounter(); - void testMove(); -}; +QObject *createPerfResourceCounterTest(); -} // namespace Internal -} // namespace PerfProfiler +} // PerfProfiler::Internal