From e29ef32ec02e01d51065962e0b0f88c70121b3de Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 26 Mar 2013 13:10:09 +0100 Subject: Add strict and relaxed parsing to Settings class. * StrictParseMode -> creating binaries and repositories * RelaxedParseMode -> running the installer/updater itself Introduced parse modes to be able to use old settings (existing ones on user systems) with new binaries. Add and adjust autotest. Change-Id: I3f7c7357325661a1197400d8d8dc2a5ca8bed184 Reviewed-by: Karsten Heimrich --- .../installer/settings/data/unknown_element_config.xml | 1 + tests/auto/installer/settings/tst_settings.cpp | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/installer/settings/data/unknown_element_config.xml b/tests/auto/installer/settings/data/unknown_element_config.xml index 0d97564e6..ee9e0ef1a 100644 --- a/tests/auto/installer/settings/data/unknown_element_config.xml +++ b/tests/auto/installer/settings/data/unknown_element_config.xml @@ -3,4 +3,5 @@ Your application 1.2.3 + Your application Installer diff --git a/tests/auto/installer/settings/tst_settings.cpp b/tests/auto/installer/settings/tst_settings.cpp index 1cc0fef00..be2643ec2 100644 --- a/tests/auto/installer/settings/tst_settings.cpp +++ b/tests/auto/installer/settings/tst_settings.cpp @@ -17,7 +17,8 @@ private slots: void loadEmptyConfig(); void loadNotExistingConfig(); void loadMalformedConfig(); - void loadUnknownElementConfig(); + void loadUnknownElementConfigInStrictParseMode(); + void loadUnknownElementConfigInRelaxedParseMode(); }; void tst_Settings::loadTutorialConfig() @@ -119,7 +120,7 @@ void tst_Settings::loadMalformedConfig() QFAIL("No exception thrown"); } -void tst_Settings::loadUnknownElementConfig() +void tst_Settings::loadUnknownElementConfigInStrictParseMode() { QTest::ignoreMessage(QtDebugMsg, "create Error-Exception: \"Error in :/data/unknown_element_config.xml, line 5, " "column 13: Unexpected element 'unknown'.\" "); @@ -133,6 +134,19 @@ void tst_Settings::loadUnknownElementConfig() QFAIL("No exception thrown"); } +void tst_Settings::loadUnknownElementConfigInRelaxedParseMode() +{ + QTest::ignoreMessage(QtWarningMsg, "\"Ignoring following settings reader error in " + ":/data/unknown_element_config.xml, line 5, column 13: \" "); + try { + Settings settings = Settings::fromFileAndPrefix(":/data/unknown_element_config.xml", ":/data", + Settings::RelaxedParseMode); + QCOMPARE(settings.title(), QLatin1String("Your application Installer")); + } catch (const Error &error) { + QFAIL(qPrintable(QString::fromLatin1("Got an exception in FaultTolerantParseMode: %1").arg(error.message()))); + } +} + QTEST_MAIN(tst_Settings) #include "tst_settings.moc" -- cgit v1.2.3