Unittest of reading config data from qt resource

REVIEW: 124098
wilder
Sune Vuorela 11 years ago
parent 5c1a50b791
commit a5bb0860ca
  1. 7
      autotests/CMakeLists.txt
  2. 11
      autotests/ksharedconfigtest.cpp
  3. 6
      autotests/sharedconfigresources.qrc
  4. 3
      autotests/test.ini

@ -31,11 +31,16 @@ ecm_add_test(${test_kconfigutils_SRCS}
) )
target_include_directories(test_kconfigutils PRIVATE ../src/kconf_update) target_include_directories(test_kconfigutils PRIVATE ../src/kconf_update)
qt5_add_resources(sharedconfigresources sharedconfigresources.qrc)
ecm_add_test(ksharedconfigtest ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent)
ecm_add_tests( ecm_add_tests(
kconfignokdehometest.cpp kconfignokdehometest.cpp
kconfigtest.cpp kconfigtest.cpp
kdesktopfiletest.cpp kdesktopfiletest.cpp
ksharedconfigtest.cpp
test_kconf_update.cpp test_kconf_update.cpp
ksharedconfig_in_global_object ksharedconfig_in_global_object
NAME_PREFIX kconfigcore- NAME_PREFIX kconfigcore-

@ -30,6 +30,7 @@ private Q_SLOTS:
void testUnicity(); void testUnicity();
void testReadWrite(); void testReadWrite();
void testReadWriteSync(); void testReadWriteSync();
void testQrcFile();
private: private:
QString m_path; QString m_path;
}; };
@ -79,6 +80,16 @@ void KSharedConfigTest::testReadWriteSync()
} }
} }
void KSharedConfigTest::testQrcFile()
{
QVERIFY(QFile::exists(QStringLiteral(":/testdata/test.ini")));
KSharedConfig::Ptr sharedConfig = KSharedConfig::openConfig(QStringLiteral(":/testdata/test.ini"), KConfig::NoGlobals);
QVERIFY(sharedConfig);
KConfigGroup cfg(sharedConfig, QStringLiteral("MainSection"));
QCOMPARE(cfg.readEntry(QStringLiteral("TestEntry"), QStringLiteral("UnexpectedData")), QStringLiteral("ExpectedData"));
}
QTEST_MAIN(KSharedConfigTest) QTEST_MAIN(KSharedConfigTest)
#include "ksharedconfigtest.moc" #include "ksharedconfigtest.moc"

@ -0,0 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/testdata">
<file>test.ini</file>
</qresource>
</RCC>

@ -0,0 +1,3 @@
[MainSection]
TestEntry=ExpectedData
Loading…
Cancel
Save