[frameworks/kconfig] autotests: Add test for KConfigLoader ctor that takes KConfigGroup

Nicolas Fella <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit d8bd982c5011c26a53adba77c0b5abc569534fa0 by Nicolas Fella.
Committed on 23/07/2026 at 08:04.
Pushed by nicolasfella into branch 'master'.

Add test for KConfigLoader ctor that takes KConfigGroup

M  +20   -0    autotests/kconfigloadertest.cpp
M  +1    -0    autotests/kconfigloadertest.h

https://invent.kde.org/frameworks/kconfig/-/commit/d8bd982c5011c26a53adba77c0b5abc569534fa0

diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp
index 513822a8..292cb019 100644
--- a/autotests/kconfigloadertest.cpp
+++ b/autotests/kconfigloadertest.cpp
@@ -238,6 +238,26 @@ void ConfigLoaderTest::timeDefaultValue()
     QVERIFY(typeItem->isEqual(QTime(21, 42, 32)));
 }
 
+void ConfigLoaderTest::testConfigGroup()
+{
+    QString fileName = s_testName + QLatin1String(".xml");
+    QFile configFile(QFINDTESTDATA(QString::fromLatin1("/") + fileName));
+
+    KConfig config(QStringLiteral("kconfigloadertestgroup"));
+    config.group(QStringLiteral("SubGroup")).group(QStringLiteral("kconfigloadertest")).writeEntry("DefaultIntItem", 13);
+    config.sync();
+
+    KConfigGroup group = config.group(QStringLiteral("SubGroup"));
+
+    auto loader = new KConfigLoader(group, &configFile);
+    auto item = loader->findItemByName(QStringLiteral("DefaultIntItem"));
+    auto intItem = static_cast<KConfigSkeleton::ItemInt *>(item);
+    QCOMPARE(intItem->value(), 13);
+    QCOMPARE(intItem->getDefault().toInt(), 27);
+
+    delete loader;
+}
+
 QTEST_MAIN(ConfigLoaderTest)
 
 #include "moc_kconfigloadertest.cpp"
diff --git a/autotests/kconfigloadertest.h b/autotests/kconfigloadertest.h
index e48af61c..d054d1e2 100644
--- a/autotests/kconfigloadertest.h
+++ b/autotests/kconfigloadertest.h
@@ -47,6 +47,7 @@ private Q_SLOTS:
     void sizeFDefaultValue();
     void ulongLongDefaultValue();
     void timeDefaultValue();
+    void testConfigGroup();
 
 private:
     KConfigLoader *cl;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.