diff -Nru kcoreaddons-5.79.0/autotests/alwaysunloadplugin.cpp kcoreaddons-5.80.0/autotests/alwaysunloadplugin.cpp --- kcoreaddons-5.79.0/autotests/alwaysunloadplugin.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/alwaysunloadplugin.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -7,9 +7,9 @@ #include "alwaysunloadplugin.h" #include "kcoreaddons_debug.h" +#include #include #include -#include AlwaysUnloadPlugin::AlwaysUnloadPlugin(QObject *parent, const QVariantList &args) : QObject(parent) diff -Nru kcoreaddons-5.79.0/autotests/desktoptojsontest.cpp kcoreaddons-5.80.0/autotests/desktoptojsontest.cpp --- kcoreaddons-5.79.0/autotests/desktoptojsontest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/desktoptojsontest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -5,21 +5,21 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ +#include "kcoreaddons_debug.h" +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include "kcoreaddons_debug.h" #include namespace QTest { - -template<> inline char *toString(const QJsonValue &val) +template<> +inline char *toString(const QJsonValue &val) { // simply reuse the QDebug representation QString result; @@ -34,7 +34,8 @@ Q_OBJECT private: - void compareJson(const QJsonObject& actual, const QJsonObject& expected) { + void compareJson(const QJsonObject &actual, const QJsonObject &expected) + { for (auto it = actual.constBegin(); it != actual.constEnd(); ++it) { if (expected.constFind(it.key()) == expected.constEnd()) { qCritical() << "Result has key" << it.key() << "which is not expected!"; @@ -71,54 +72,54 @@ QJsonObject expectedResult; QJsonObject kpluginObj; QByteArray input = - // include an insignificant group - "[Some Group]\n" - "Foo=Bar\n" - "\n" - "[Desktop Entry]\n" - // only data inside [Desktop Entry] should be included - "Name=Example\n" - //empty lines - "\n" - " \n" - // make sure translations are included: - "Name[de_DE]=Beispiel\n" - // ignore comments: - "#Comment=Comment\n" - " #Comment=Comment\n" - "Categories=foo;bar;a\\;b\n" - // As the case is significant, the keys Name and NAME are not equivalent: - "CaseSensitive=ABC\n" - "CASESENSITIVE=abc\n" - // Space before and after the equals sign should be ignored: - "SpacesBeforeEq =foo\n" - "SpacesAfterEq= foo\n" - // Space before and after the equals sign should be ignored; the = sign is the actual delimiter. - // TODO: error in spec (spaces before and after the key??) - " SpacesBeforeKey=foo\n" - "SpacesAfterKey =foo\n" - // ignore trailing spaces - "TrailingSpaces=foo \n" - // However spaces in the value are significant: - "SpacesInValue=Hello, World!\n" - // The escape sequences \s, \n, \t, \r, and \\ are supported for values of - // type string and localestring, meaning ASCII space, newline, tab, - // carriage return, and backslash, respectively: - "EscapeSequences=So\\sme esc\\nap\\te se\\\\qu\\re\\\\nces\n" // make sure that the last n is a literal n not a newline! - // the standard keys that are used by plugins, make sure correct types are used: - "X-KDE-PluginInfo-Category=Examples\n" // string key - "X-KDE-PluginInfo-Version=1.0\n" - // The multiple values should be separated by a semicolon and the value of the key - // may be optionally terminated by a semicolon. Trailing empty strings must always - // be terminated with a semicolon. Semicolons in these values need to be escaped using \;. + // include an insignificant group + "[Some Group]\n" + "Foo=Bar\n" + "\n" + "[Desktop Entry]\n" + // only data inside [Desktop Entry] should be included + "Name=Example\n" + // empty lines + "\n" + " \n" + // make sure translations are included: + "Name[de_DE]=Beispiel\n" + // ignore comments: + "#Comment=Comment\n" + " #Comment=Comment\n" + "Categories=foo;bar;a\\;b\n" + // As the case is significant, the keys Name and NAME are not equivalent: + "CaseSensitive=ABC\n" + "CASESENSITIVE=abc\n" + // Space before and after the equals sign should be ignored: + "SpacesBeforeEq =foo\n" + "SpacesAfterEq= foo\n" + // Space before and after the equals sign should be ignored; the = sign is the actual delimiter. + // TODO: error in spec (spaces before and after the key??) + " SpacesBeforeKey=foo\n" + "SpacesAfterKey =foo\n" + // ignore trailing spaces + "TrailingSpaces=foo \n" + // However spaces in the value are significant: + "SpacesInValue=Hello, World!\n" + // The escape sequences \s, \n, \t, \r, and \\ are supported for values of + // type string and localestring, meaning ASCII space, newline, tab, + // carriage return, and backslash, respectively: + "EscapeSequences=So\\sme esc\\nap\\te se\\\\qu\\re\\\\nces\n" // make sure that the last n is a literal n not a newline! + // the standard keys that are used by plugins, make sure correct types are used: + "X-KDE-PluginInfo-Category=Examples\n" // string key + "X-KDE-PluginInfo-Version=1.0\n" + // The multiple values should be separated by a semicolon and the value of the key + // may be optionally terminated by a semicolon. Trailing empty strings must always + // be terminated with a semicolon. Semicolons in these values need to be escaped using \;. #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79) - "X-KDE-PluginInfo-Depends=foo,bar,esc\\,aped\n" // string list key + "X-KDE-PluginInfo-Depends=foo,bar,esc\\,aped\n" // string list key #endif - "X-KDE-ServiceTypes=\n" // empty string list - "X-KDE-PluginInfo-EnabledByDefault=true\n" // bool key - // now start a new group - "[New Group]\n" - "InWrongGroup=true\n"; + "X-KDE-ServiceTypes=\n" // empty string list + "X-KDE-PluginInfo-EnabledByDefault=true\n" // bool key + // now start a new group + "[New Group]\n" + "InWrongGroup=true\n"; expectedResult[QStringLiteral("Categories")] = QStringLiteral("foo;bar;a\\;b"); expectedResult[QStringLiteral("CaseSensitive")] = QStringLiteral("ABC"); @@ -134,8 +135,8 @@ kpluginObj[QStringLiteral("Name[de_DE]")] = QStringLiteral("Beispiel"); kpluginObj[QStringLiteral("Category")] = QStringLiteral("Examples"); #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79) - kpluginObj[QStringLiteral("Dependencies")] = QJsonArray::fromStringList - (QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped")); + kpluginObj[QStringLiteral("Dependencies")] = + QJsonArray::fromStringList(QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped")); #endif kpluginObj[QStringLiteral("ServiceTypes")] = QJsonArray::fromStringList(QStringList()); kpluginObj[QStringLiteral("EnabledByDefault")] = true; @@ -146,8 +147,8 @@ compatResult[QStringLiteral("X-KDE-PluginInfo-Category")] = QStringLiteral("Examples"); compatResult[QStringLiteral("X-KDE-PluginInfo-Version")] = QStringLiteral("1.0"); #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79) - compatResult[QStringLiteral("X-KDE-PluginInfo-Depends")] = QJsonArray::fromStringList - (QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped")); + compatResult[QStringLiteral("X-KDE-PluginInfo-Depends")] = + QJsonArray::fromStringList(QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped")); #endif compatResult[QStringLiteral("X-KDE-ServiceTypes")] = QJsonArray::fromStringList(QStringList()); compatResult[QStringLiteral("X-KDE-PluginInfo-EnabledByDefault")] = true; @@ -157,99 +158,107 @@ QTest::newRow("newFormat") << input << expectedResult << false << QStringList(); QTest::newRow("compatFormat") << input << compatResult << true << QStringList(); - // test conversion of a currently existing .desktop file (excluding most of the translations): QByteArray kdevInput = - "[Desktop Entry]\n" - "Type = Service\n" - "Icon=text-x-c++src\n" - "Exec=blubb\n" - "Comment=C/C++ Language Support\n" - "Comment[fr]=Prise en charge du langage C/C++\n" - "Comment[it]=Supporto al linguaggio C/C++\n" - "Name=C++ Support\n" - "Name[fi]=C++-tuki\n" - "Name[fr]=Prise en charge du C++\n" - "GenericName=Language Support\n" - "GenericName[sl]=Podpora jeziku\n" - "ServiceTypes=KDevelop/NonExistentPlugin\n" - "X-KDE-Library=kdevcpplanguagesupport\n" - "X-KDE-PluginInfo-Name=kdevcppsupport\n" - "X-KDE-PluginInfo-Category=Language Support\n" - "X-KDevelop-Version=1\n" - "X-KDevelop-Language=C++\n" - "X-KDevelop-Args=CPP\n" - "X-KDevelop-Interfaces=ILanguageSupport\n" - "X-KDevelop-SupportedMimeTypes=text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\n" - "X-KDevelop-Mode=NoGUI\n" - "X-KDevelop-LoadMode=AlwaysOn"; + "[Desktop Entry]\n" + "Type = Service\n" + "Icon=text-x-c++src\n" + "Exec=blubb\n" + "Comment=C/C++ Language Support\n" + "Comment[fr]=Prise en charge du langage C/C++\n" + "Comment[it]=Supporto al linguaggio C/C++\n" + "Name=C++ Support\n" + "Name[fi]=C++-tuki\n" + "Name[fr]=Prise en charge du C++\n" + "GenericName=Language Support\n" + "GenericName[sl]=Podpora jeziku\n" + "ServiceTypes=KDevelop/NonExistentPlugin\n" + "X-KDE-Library=kdevcpplanguagesupport\n" + "X-KDE-PluginInfo-Name=kdevcppsupport\n" + "X-KDE-PluginInfo-Category=Language Support\n" + "X-KDevelop-Version=1\n" + "X-KDevelop-Language=C++\n" + "X-KDevelop-Args=CPP\n" + "X-KDevelop-Interfaces=ILanguageSupport\n" + "X-KDevelop-SupportedMimeTypes=text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\n" + "X-KDevelop-Mode=NoGUI\n" + "X-KDevelop-LoadMode=AlwaysOn"; QJsonParseError e; - QJsonObject kdevExpected = QJsonDocument::fromJson("{\n" - " \"GenericName\": \"Language Support\",\n" - " \"GenericName[sl]\": \"Podpora jeziku\",\n" - " \"KPlugin\": {\n" - " \"Category\": \"Language Support\",\n" - " \"Description\": \"C/C++ Language Support\",\n" - " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" - " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" - " \"Icon\": \"text-x-c++src\",\n" - " \"Id\": \"kdevcppsupport\",\n" - " \"Name\": \"C++ Support\",\n" - " \"Name[fi]\": \"C++-tuki\",\n" - " \"Name[fr]\": \"Prise en charge du C++\",\n" - " \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n" - " },\n" - " \"X-KDevelop-Args\": \"CPP\",\n" - " \"X-KDevelop-Interfaces\": \"ILanguageSupport\",\n" - " \"X-KDevelop-Language\": \"C++\",\n" - " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" - " \"X-KDevelop-Mode\": \"NoGUI\",\n" - " \"X-KDevelop-SupportedMimeTypes\": \"text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\",\n" - " \"X-KDevelop-Version\": \"1\"\n" - "}\n", &e).object(); + QJsonObject kdevExpected = QJsonDocument::fromJson( + "{\n" + " \"GenericName\": \"Language Support\",\n" + " \"GenericName[sl]\": \"Podpora jeziku\",\n" + " \"KPlugin\": {\n" + " \"Category\": \"Language Support\",\n" + " \"Description\": \"C/C++ Language Support\",\n" + " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" + " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" + " \"Icon\": \"text-x-c++src\",\n" + " \"Id\": \"kdevcppsupport\",\n" + " \"Name\": \"C++ Support\",\n" + " \"Name[fi]\": \"C++-tuki\",\n" + " \"Name[fr]\": \"Prise en charge du C++\",\n" + " \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n" + " },\n" + " \"X-KDevelop-Args\": \"CPP\",\n" + " \"X-KDevelop-Interfaces\": \"ILanguageSupport\",\n" + " \"X-KDevelop-Language\": \"C++\",\n" + " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" + " \"X-KDevelop-Mode\": \"NoGUI\",\n" + " \"X-KDevelop-SupportedMimeTypes\": \"text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\",\n" + " \"X-KDevelop-Version\": \"1\"\n" + "}\n", + &e) + .object(); QCOMPARE(e.error, QJsonParseError::NoError); QTest::newRow("kdevcpplanguagesupport no servicetype") << kdevInput << kdevExpected << false << QStringList(); - QJsonObject kdevExpectedWithServiceType = QJsonDocument::fromJson("{\n" - " \"GenericName\": \"Language Support\",\n" - " \"GenericName[sl]\": \"Podpora jeziku\",\n" - " \"KPlugin\": {\n" - " \"Category\": \"Language Support\",\n" - " \"Description\": \"C/C++ Language Support\",\n" - " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" - " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" - " \"Icon\": \"text-x-c++src\",\n" - " \"Id\": \"kdevcppsupport\",\n" - " \"Name\": \"C++ Support\",\n" - " \"Name[fi]\": \"C++-tuki\",\n" - " \"Name[fr]\": \"Prise en charge du C++\",\n" - " \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n" - " },\n" - " \"X-KDevelop-Args\": \"CPP\",\n" - " \"X-KDevelop-Interfaces\": [\"ILanguageSupport\"],\n" - " \"X-KDevelop-Language\": \"C++\",\n" - " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" - " \"X-KDevelop-Mode\": \"NoGUI\",\n" - " \"X-KDevelop-SupportedMimeTypes\": [\"text/x-chdr\", \"text/x-c++hdr\", \"text/x-csrc\", \"text/x-c++src\"],\n" - " \"X-KDevelop-Version\": 1\n" - "}\n", &e).object(); + QJsonObject kdevExpectedWithServiceType = + QJsonDocument::fromJson( + "{\n" + " \"GenericName\": \"Language Support\",\n" + " \"GenericName[sl]\": \"Podpora jeziku\",\n" + " \"KPlugin\": {\n" + " \"Category\": \"Language Support\",\n" + " \"Description\": \"C/C++ Language Support\",\n" + " \"Description[fr]\": \"Prise en charge du langage C/C++\",\n" + " \"Description[it]\": \"Supporto al linguaggio C/C++\",\n" + " \"Icon\": \"text-x-c++src\",\n" + " \"Id\": \"kdevcppsupport\",\n" + " \"Name\": \"C++ Support\",\n" + " \"Name[fi]\": \"C++-tuki\",\n" + " \"Name[fr]\": \"Prise en charge du C++\",\n" + " \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n" + " },\n" + " \"X-KDevelop-Args\": \"CPP\",\n" + " \"X-KDevelop-Interfaces\": [\"ILanguageSupport\"],\n" + " \"X-KDevelop-Language\": \"C++\",\n" + " \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n" + " \"X-KDevelop-Mode\": \"NoGUI\",\n" + " \"X-KDevelop-SupportedMimeTypes\": [\"text/x-chdr\", \"text/x-c++hdr\", \"text/x-csrc\", \"text/x-c++src\"],\n" + " \"X-KDevelop-Version\": 1\n" + "}\n", + &e) + .object(); QCOMPARE(e.error, QJsonParseError::NoError); const QString kdevServiceTypePath = QFINDTESTDATA("data/servicetypes/fake-kdevelopplugin.desktop"); QVERIFY(!kdevServiceTypePath.isEmpty()); - QTest::newRow("kdevcpplanguagesupport with servicetype") << kdevInput << kdevExpectedWithServiceType - << false << QStringList(kdevServiceTypePath); + QTest::newRow("kdevcpplanguagesupport with servicetype") << kdevInput << kdevExpectedWithServiceType << false << QStringList(kdevServiceTypePath); // test conversion of the X-KDE-PluginInfo-Author + X-KDE-PluginInfo-Email key: QByteArray authorInput = - "[Desktop Entry]\n" - "Type=Service\n" - "X-KDE-PluginInfo-Author=Foo Bar\n" - "X-KDE-PluginInfo-Email=foo.bar@baz.com\n"; - - QJsonObject authorsExpected = QJsonDocument::fromJson("{\n" - " \"KPlugin\": {\n" - " \"Authors\": [ { \"Name\": \"Foo Bar\", \"Email\": \"foo.bar@baz.com\" } ]\n" - " }\n }\n", &e).object(); + "[Desktop Entry]\n" + "Type=Service\n" + "X-KDE-PluginInfo-Author=Foo Bar\n" + "X-KDE-PluginInfo-Email=foo.bar@baz.com\n"; + + QJsonObject authorsExpected = QJsonDocument::fromJson( + "{\n" + " \"KPlugin\": {\n" + " \"Authors\": [ { \"Name\": \"Foo Bar\", \"Email\": \"foo.bar@baz.com\" } ]\n" + " }\n }\n", + &e) + .object(); QCOMPARE(e.error, QJsonParseError::NoError); QTest::newRow("authors") << authorInput << authorsExpected << false << QStringList(); @@ -273,31 +282,31 @@ // test conversion of kcookiejar.desktop (for some reason the wrong boolean values were committed) QByteArray kcookiejarInput = - "[Desktop Entry]\n" - "Type= Service\n" - "Name=Cookie Jar\n" - "Comment=Stores network cookies\n" - "X-KDE-ServiceTypes=KDEDModule\n" - "X-KDE-Library=kf5/kded/kcookiejar\n" - "X-KDE-Kded-autoload=false\n" - "X-KDE-Kded-load-on-demand=true\n"; + "[Desktop Entry]\n" + "Type= Service\n" + "Name=Cookie Jar\n" + "Comment=Stores network cookies\n" + "X-KDE-ServiceTypes=KDEDModule\n" + "X-KDE-Library=kf5/kded/kcookiejar\n" + "X-KDE-Kded-autoload=false\n" + "X-KDE-Kded-load-on-demand=true\n"; auto kcookiejarResult = QJsonDocument::fromJson( - "{\n" - " \"KPlugin\": {\n" - " \"Description\": \"Stores network cookies\",\n" - " \"Name\": \"Cookie Jar\",\n" - " \"ServiceTypes\": [\n" - " \"KDEDModule\"\n" - " ]\n" - " },\n" - "\"X-KDE-Kded-autoload\": false,\n" - "\"X-KDE-Kded-load-on-demand\": true\n" - "}\n", &e).object(); + "{\n" + " \"KPlugin\": {\n" + " \"Description\": \"Stores network cookies\",\n" + " \"Name\": \"Cookie Jar\",\n" + " \"ServiceTypes\": [\n" + " \"KDEDModule\"\n" + " ]\n" + " },\n" + "\"X-KDE-Kded-autoload\": false,\n" + "\"X-KDE-Kded-load-on-demand\": true\n" + "}\n", + &e) + .object(); const QString kdedmoduleServiceType = QFINDTESTDATA("data/servicetypes/fake-kdedmodule.desktop"); QVERIFY(!kdedmoduleServiceType.isEmpty()); QTest::newRow("kcookiejar") << kcookiejarInput << kcookiejarResult << false << QStringList(kdedmoduleServiceType); - - } void testDesktopToJson() @@ -321,7 +330,7 @@ if (compatibilityMode) { arguments << QStringLiteral("-c"); } - for(const QString &s : qAsConst(serviceTypes)) { + for (const QString &s : qAsConst(serviceTypes)) { arguments << QStringLiteral("-s") << s; } proc.setArguments(arguments); @@ -329,7 +338,7 @@ QVERIFY(proc.waitForFinished(10000)); QByteArray errorOut = proc.readAllStandardError(); if (!errorOut.isEmpty()) { - qCWarning(KCOREADDONS_DEBUG).nospace() << "desktoptojson STDERR:\n\n" << errorOut.constData() << "\n"; + qCWarning(KCOREADDONS_DEBUG).nospace() << "desktoptojson STDERR:\n\n" << errorOut.constData() << "\n"; } QCOMPARE(proc.exitCode(), 0); QVERIFY(output.open()); diff -Nru kcoreaddons-5.79.0/autotests/kaboutdataapplicationdatatest.cpp kcoreaddons-5.80.0/autotests/kaboutdataapplicationdatatest.cpp --- kcoreaddons-5.79.0/autotests/kaboutdataapplicationdatatest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kaboutdataapplicationdatatest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -25,18 +25,17 @@ #endif }; - -static const char AppName[] = "app"; -static const char ProgramName[] = "ProgramName"; -static const char Version[] = "Version"; +static const char AppName[] = "app"; +static const char ProgramName[] = "ProgramName"; +static const char Version[] = "Version"; static const char OrganizationDomain[] = "no.where"; -static const char DesktopFileName[] = "org.kde.someapp"; +static const char DesktopFileName[] = "org.kde.someapp"; -static const char AppName2[] = "otherapp"; -static const char ProgramName2[] = "OtherProgramName"; -static const char Version2[] = "OtherVersion"; +static const char AppName2[] = "otherapp"; +static const char ProgramName2[] = "OtherProgramName"; +static const char Version2[] = "OtherVersion"; static const char OrganizationDomain2[] = "other.no.where"; -static const char DesktopFileName2[] = "org.kde.otherapp"; +static const char DesktopFileName2[] = "org.kde.otherapp"; void KAboutDataApplicationDataTest::testInteractionWithQApplicationData() { diff -Nru kcoreaddons-5.79.0/autotests/kaboutdatatest.cpp kcoreaddons-5.80.0/autotests/kaboutdatatest.cpp --- kcoreaddons-5.79.0/autotests/kaboutdatatest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kaboutdatatest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -8,11 +8,11 @@ // test object #include // Qt -#include #include -#include -#include #include +#include +#include +#include #ifndef Q_OS_WIN void initLocale() { @@ -43,27 +43,30 @@ void testLicenseOrLater(); }; -static const char AppName[] = "app"; -static const char ProgramName[] = "ProgramName"; +static const char AppName[] = "app"; +static const char ProgramName[] = "ProgramName"; #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) -static const char ProgramIconName[] = "program-icon"; +static const char ProgramIconName[] = "program-icon"; #endif -static const char Version[] = "Version"; -static const char ShortDescription[] = "ShortDescription"; +static const char Version[] = "Version"; +static const char ShortDescription[] = "ShortDescription"; static const char CopyrightStatement[] = "CopyrightStatement"; -static const char Text[] = "Text"; -static const char HomePageAddress[] = "http://test.no.where/"; -static const char HomePageSecure[] = "https://test.no.where/"; +static const char Text[] = "Text"; +static const char HomePageAddress[] = "http://test.no.where/"; +static const char HomePageSecure[] = "https://test.no.where/"; static const char OrganizationDomain[] = "no.where"; -static const char BugsEmailAddress[] = "bugs@no.else"; -static const char LicenseText[] = "free to write, reading forbidden"; -static const char LicenseFileName[] = "testlicensefile"; -static const char LicenseFileText[] = "free to write, reading forbidden, in the file"; +static const char BugsEmailAddress[] = "bugs@no.else"; +static const char LicenseText[] = "free to write, reading forbidden"; +static const char LicenseFileName[] = "testlicensefile"; +static const char LicenseFileText[] = "free to write, reading forbidden, in the file"; void KAboutDataTest::testLongFormConstructorWithDefaults() { - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::Unknown); + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::Unknown); QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName)); @@ -94,15 +97,20 @@ QCOMPARE(aboutData.customAuthorRichText(), QString()); QVERIFY(!aboutData.customAuthorTextEnabled()); QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app")); - //TODO: test internalVersion, internalProgramName, internalBugAddress + // TODO: test internalVersion, internalProgramName, internalBugAddress } void KAboutDataTest::testLongFormConstructor() { - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::Unknown, - QLatin1String(CopyrightStatement), QLatin1String(Text), - QString::fromLatin1(HomePageAddress), QString::fromLatin1(BugsEmailAddress)); + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::Unknown, + QLatin1String(CopyrightStatement), + QLatin1String(Text), + QString::fromLatin1(HomePageAddress), + QString::fromLatin1(BugsEmailAddress)); QCOMPARE(aboutData.componentName(), QLatin1String(AppName)); QCOMPARE(aboutData.productName(), QLatin1String(AppName)); @@ -133,14 +141,19 @@ QCOMPARE(aboutData.customAuthorRichText(), QString()); QVERIFY(!aboutData.customAuthorTextEnabled()); QCOMPARE(aboutData.desktopFileName(), QStringLiteral("where.no.app")); - //TODO: test internalVersion, internalProgramName, internalBugAddress + // TODO: test internalVersion, internalProgramName, internalBugAddress // We support http and https protocols on the homepage address, ensure they // give the same org. domain and desktop file name. - KAboutData aboutDataSecure(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::Unknown, - QLatin1String(CopyrightStatement), QLatin1String(Text), - QString::fromLatin1(HomePageSecure), QString::fromLatin1(BugsEmailAddress)); + KAboutData aboutDataSecure(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::Unknown, + QLatin1String(CopyrightStatement), + QLatin1String(Text), + QString::fromLatin1(HomePageSecure), + QString::fromLatin1(BugsEmailAddress)); QCOMPARE(aboutDataSecure.componentName(), QLatin1String(AppName)); QCOMPARE(aboutDataSecure.productName(), QLatin1String(AppName)); QCOMPARE(aboutDataSecure.organizationDomain(), QString::fromLatin1(OrganizationDomain)); @@ -180,21 +193,29 @@ QCOMPARE(aboutData.customAuthorRichText(), QString()); QVERIFY(!aboutData.customAuthorTextEnabled()); QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app")); - //TODO: test internalVersion, internalProgramName, internalBugAddress + // TODO: test internalVersion, internalProgramName, internalBugAddress } void KAboutDataTest::testKAboutDataOrganizationDomain() { - KAboutData data(QString::fromLatin1("app"), QLatin1String("program"), QString::fromLatin1("version"), - QLatin1String("description"), KAboutLicense::LGPL, - QLatin1String("copyright"), QLatin1String("hello world"), + KAboutData data(QString::fromLatin1("app"), + QLatin1String("program"), + QString::fromLatin1("version"), + QLatin1String("description"), + KAboutLicense::LGPL, + QLatin1String("copyright"), + QLatin1String("hello world"), QStringLiteral("http://www.koffice.org")); QCOMPARE(data.organizationDomain(), QString::fromLatin1("koffice.org")); QCOMPARE(data.desktopFileName(), QStringLiteral("org.koffice.app")); - KAboutData data2(QString::fromLatin1("app"), QLatin1String("program"), QString::fromLatin1("version"), - QLatin1String("description"), KAboutLicense::LGPL, - QString::fromLatin1("copyright"), QLatin1String("hello world"), + KAboutData data2(QString::fromLatin1("app"), + QLatin1String("program"), + QString::fromLatin1("version"), + QLatin1String("description"), + KAboutLicense::LGPL, + QString::fromLatin1("copyright"), + QLatin1String("hello world"), QStringLiteral("app")); QCOMPARE(data2.organizationDomain(), QString::fromLatin1("kde.org")); QCOMPARE(data2.desktopFileName(), QStringLiteral("org.kde.app")); @@ -212,10 +233,15 @@ const QString copyrightStatement = QLatin1String(CopyrightStatement); const QString lineFeed = QString::fromLatin1("\n\n"); - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::Unknown, - QLatin1String(CopyrightStatement), QLatin1String(Text), - QString::fromLatin1(HomePageAddress), QString::fromLatin1(BugsEmailAddress)); + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::Unknown, + QLatin1String(CopyrightStatement), + QLatin1String(Text), + QString::fromLatin1(HomePageAddress), + QString::fromLatin1(BugsEmailAddress)); // set to GPL2 aboutData.setLicense(KAboutLicense::GPL_V2); @@ -266,8 +292,7 @@ QCOMPARE(aboutData.licenses().at(2).text(), QLatin1String(LicenseText)); QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::ShortName), QString::fromLatin1("Custom")); QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::FullName), QString::fromLatin1("Custom")); - QCOMPARE(aboutData.licenses().at(3).text(), QString(copyrightStatement + lineFeed + - QLatin1String(LicenseFileText))); + QCOMPARE(aboutData.licenses().at(3).text(), QString(copyrightStatement + lineFeed + QLatin1String(LicenseFileText))); } #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) @@ -275,10 +300,15 @@ { const QString programIconName(QString::fromLatin1(ProgramIconName)); - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::Unknown, - QLatin1String(CopyrightStatement), QLatin1String(Text), - QString::fromLatin1(HomePageAddress), QString::fromLatin1(BugsEmailAddress)); + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::Unknown, + QLatin1String(CopyrightStatement), + QLatin1String(Text), + QString::fromLatin1(HomePageAddress), + QString::fromLatin1(BugsEmailAddress)); // Deprecated, still want to test this though. Silence GCC warnings. #pragma GCC diagnostic push @@ -292,12 +322,18 @@ void KAboutDataTest::testCopying() { - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::GPL_V2); + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::GPL_V2); { - KAboutData aboutData2(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::GPL_V3); + KAboutData aboutData2(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::GPL_V3); aboutData2.addLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions); aboutData = aboutData2; } @@ -315,8 +351,11 @@ void KAboutDataTest::testSetDesktopFileName() { - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::Unknown); + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::Unknown); QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app")); // set different desktopFileName @@ -333,11 +372,14 @@ license = KAboutLicense::byKeyword(QStringLiteral("GPLv2")); QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0")); - //we should be able to match by spdx too - //create a KAboutLicense from enum, then make sure going to spdx and back gives the same enum - for(int i = 1; i <= KAboutLicense::LGPL_V2_1 ; ++i) { /*current highest enum value*/ - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::GPL_V2); + // we should be able to match by spdx too + // create a KAboutLicense from enum, then make sure going to spdx and back gives the same enum + for (int i = 1; i <= KAboutLicense::LGPL_V2_1; ++i) { /*current highest enum value*/ + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::GPL_V2); aboutData.setLicense(KAboutLicense::LicenseKey(i)); QVERIFY(aboutData.licenses().count() == 1); const auto license = aboutData.licenses().constFirst(); @@ -350,8 +392,11 @@ void KAboutDataTest::testLicenseOrLater() { // For kaboutdata we can replace the license with an orLater version. Or add a second one. - KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version), - QLatin1String(ShortDescription), KAboutLicense::GPL_V2); + KAboutData aboutData(QString::fromLatin1(AppName), + QLatin1String(ProgramName), + QString::fromLatin1(Version), + QLatin1String(ShortDescription), + KAboutLicense::GPL_V2); QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0")); aboutData.setLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions); QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0+")); diff -Nru kcoreaddons-5.79.0/autotests/kautosavefiletest.cpp kcoreaddons-5.80.0/autotests/kautosavefiletest.cpp --- kcoreaddons-5.79.0/autotests/kautosavefiletest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kautosavefiletest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -9,12 +9,12 @@ #include #include +#include #include #include #include -#include QTEST_MAIN(KAutoSaveFileTest) @@ -38,7 +38,7 @@ QUrl normalFile = QUrl::fromLocalFile(QFileInfo(file).absoluteFilePath()); - //Test basic functionality + // Test basic functionality KAutoSaveFile saveFile(normalFile); QVERIFY(!QFile::exists(saveFile.fileName())); @@ -86,11 +86,7 @@ // - exceeds NAME_MAX (255) // - is less than the maximum allowed path length, PATH_MAX (4096) // see e.g. /usr/include/linux/limits.h - const QString path = QDir::tempPath() + QLatin1Char('/') - + s + QLatin1Char('/') - + s + QLatin1Char('/') - + s + QLatin1Char('/') - + s; + const QString path = QDir::tempPath() + QLatin1Char('/') + s + QLatin1Char('/') + s + QLatin1Char('/') + s + QLatin1Char('/') + s; QFile file(path + QLatin1Char('/') + QLatin1String("testFile.txt")); @@ -111,10 +107,16 @@ KAutoSaveFile saveFile(normalFile); QVERIFY(saveFile.open(QIODevice::ReadWrite)); saveFile.write("testdata"); + // Make sure the stale file is found - QVERIFY(saveFile.staleFiles(normalFile, QStringLiteral("qttest")).count() == 1); + + const auto listOfStaleFiles = saveFile.staleFiles(normalFile, QStringLiteral("qttest")); + QVERIFY(listOfStaleFiles.count() == 1); saveFile.releaseLock(); + qDeleteAll(listOfStaleFiles); + // Make sure the stale file is deleted + QVERIFY(saveFile.staleFiles(normalFile, QStringLiteral("qttest")).isEmpty()); } @@ -150,6 +152,5 @@ QVERIFY(saveFile2->open(QIODevice::ReadWrite)); - delete saveFile2; - + qDeleteAll(staleFiles); } diff -Nru kcoreaddons-5.79.0/autotests/kcompositejobtest.cpp kcoreaddons-5.80.0/autotests/kcompositejobtest.cpp --- kcoreaddons-5.79.0/autotests/kcompositejobtest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kcompositejobtest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -7,8 +7,8 @@ #include "kcompositejobtest.h" -#include #include +#include #include TestJob::TestJob(QObject *parent) @@ -76,9 +76,10 @@ QCOMPARE(job->parent(), compositeJob); - QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject*))); + QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject *))); // check if job got reparented properly - delete someParent; someParent = nullptr; + delete someParent; + someParent = nullptr; // the job should still exist, because it is a child of KCompositeJob now QCOMPARE(destroyed_spy.size(), 0); @@ -86,10 +87,10 @@ compositeJob->start(); // delete the job during the execution - delete compositeJob; compositeJob = nullptr; + delete compositeJob; + compositeJob = nullptr; // at this point, the subjob should be deleted, too QCOMPARE(destroyed_spy.size(), 1); } QTEST_GUILESS_MAIN(KCompositeJobTest) - diff -Nru kcoreaddons-5.79.0/autotests/kcompositejobtest.h kcoreaddons-5.80.0/autotests/kcompositejobtest.h --- kcoreaddons-5.79.0/autotests/kcompositejobtest.h 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kcompositejobtest.h 2021-03-06 16:20:44.000000000 +0000 @@ -32,7 +32,10 @@ Q_OBJECT public: - explicit CompositeJob(QObject *parent = nullptr) : KCompositeJob(parent) {} + explicit CompositeJob(QObject *parent = nullptr) + : KCompositeJob(parent) + { + } void start() override; bool addSubjob(KJob *job) override; diff -Nru kcoreaddons-5.79.0/autotests/kdelibs4configmigratortest.cpp kcoreaddons-5.80.0/autotests/kdelibs4configmigratortest.cpp --- kcoreaddons-5.79.0/autotests/kdelibs4configmigratortest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kdelibs4configmigratortest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -7,11 +7,11 @@ // test object #include "kdelibs4configmigrator.h" // Qt -#include #include +#include +#include #include #include -#include class Kdelibs4ConfigMigratorTest : public QObject { @@ -57,7 +57,7 @@ const QString kdehome = kdehomeDir.path(); qputenv("KDEHOME", QFile::encodeName(kdehome)); - //Generate kde4 config dir + // Generate kde4 config dir const QString configPath = kdehome + QLatin1Char('/') + QLatin1String("share/config/"); QDir().mkpath(configPath); QVERIFY(QDir(configPath).exists()); @@ -92,7 +92,7 @@ const QString appName = QLatin1String("foo"); - //Generate kde4 data dir + // Generate kde4 data dir const QString dataPath = kdehome + QLatin1Char('/') + QLatin1String("share/apps/"); QDir().mkpath(dataPath); QVERIFY(QDir(dataPath).exists()); @@ -126,4 +126,3 @@ QTEST_MAIN(Kdelibs4ConfigMigratorTest) #include "kdelibs4configmigratortest.moc" - diff -Nru kcoreaddons-5.79.0/autotests/kdelibs4migrationtest.cpp kcoreaddons-5.80.0/autotests/kdelibs4migrationtest.cpp --- kcoreaddons-5.79.0/autotests/kdelibs4migrationtest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kdelibs4migrationtest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -7,8 +7,8 @@ // test object #include // Qt -#include #include +#include #include #include @@ -43,4 +43,3 @@ QTEST_MAIN(MigrationTest) #include "kdelibs4migrationtest.moc" - diff -Nru kcoreaddons-5.79.0/autotests/kdirwatch_unittest.cpp kcoreaddons-5.80.0/autotests/kdirwatch_unittest.cpp --- kcoreaddons-5.79.0/autotests/kdirwatch_unittest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kdirwatch_unittest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -8,12 +8,12 @@ #include -#include #include +#include #include +#include #include #include -#include #include #include #ifdef Q_OS_UNIX @@ -53,10 +53,12 @@ class StaticObjectUsingSelf // like KSambaShare does, bug 353080 { public: - StaticObjectUsingSelf() { + StaticObjectUsingSelf() + { KDirWatch::self(); } - ~StaticObjectUsingSelf() { + ~StaticObjectUsingSelf() + { if (KDirWatch::exists() && KDirWatch::self()->contains(QDir::homePath())) { KDirWatch::self()->removeDir(QDir::homePath()); } @@ -156,7 +158,7 @@ // When using it, one has to open() a file to start watching it, so workaround // test breakage by giving inotify time to react to file creation. // Full context: https://github.com/libinotify-kqueue/libinotify-kqueue/issues/10 - if(!m_slow) + if (!m_slow) QThread::msleep(1); #endif file.write(QByteArray("foo")); @@ -178,7 +180,7 @@ QFile::remove(m_path + fileName); } -int KDirWatch_UnitTest::createDirectoryTree(const QString& basePath, int depth) +int KDirWatch_UnitTest::createDirectoryTree(const QString &basePath, int depth) { int filesCreated = 0; @@ -211,7 +213,6 @@ QVERIFY(fi.exists()); const QDateTime ctime = fi.lastModified(); waitUntilAfter(ctime); - } void KDirWatch_UnitTest::waitUntilNewSecond() @@ -226,7 +227,7 @@ QDateTime now; Q_FOREVER { now = QDateTime::currentDateTime(); - if (now.toMSecsSinceEpoch() / 1000 == ctime.toMSecsSinceEpoch() / 1000) // truncate milliseconds + if (now.toMSecsSinceEpoch() / 1000 == ctime.toMSecsSinceEpoch() / 1000) // truncate milliseconds { totalWait += 50; QTest::qWait(50); @@ -236,7 +237,7 @@ break; } } - //if (totalWait > 0) + // if (totalWait > 0) qCDebug(KCOREADDONS_DEBUG) << "Waited" << totalWait << "ms so that now" << now.toString(Qt::ISODate) << "is >" << ctime.toString(Qt::ISODate); } @@ -304,57 +305,57 @@ bool KDirWatch_UnitTest::verifySignalPath(QSignalSpy &spy, const char *sig, const QString &expectedPath) { - for (int i = 0; i < spy.count(); ++i) { - const QString got = spy[i][0].toString(); - if (got == expectedPath) { - return true; - } - if (got.startsWith(expectedPath + QLatin1Char('/'))) { - qCDebug(KCOREADDONS_DEBUG) << "Ignoring (inotify) notification of" << (sig + 1) << '(' << got << ')'; - continue; + for (int i = 0; i < spy.count(); ++i) { + const QString got = spy[i][0].toString(); + if (got == expectedPath) { + return true; + } + if (got.startsWith(expectedPath + QLatin1Char('/'))) { + qCDebug(KCOREADDONS_DEBUG) << "Ignoring (inotify) notification of" << (sig + 1) << '(' << got << ')'; + continue; + } + qWarning() << "Expected" << sig << '(' << expectedPath << ')' << "but got" << sig << '(' << got << ')'; + return false; } - qWarning() << "Expected" << sig << '(' << expectedPath << ')' << "but got" << sig << '(' << got << ')'; return false; - } - return false; } bool KDirWatch_UnitTest::waitForRecreationSignal(KDirWatch &watch, const QString &path) { - // When watching for a deleted + created signal pair, the two might come so close that - // using waitForOneSignal will miss the created signal. This function monitors both all - // the time to ensure both are received. - // - // In addition, it allows dirty() to be emitted (for that same path) as an alternative - - const QString expectedPath = removeTrailingSlash(path); - QSignalSpy spyDirty(&watch, &KDirWatch::dirty); - QSignalSpy spyDeleted(&watch, &KDirWatch::deleted); - QSignalSpy spyCreated(&watch, &KDirWatch::created); - - int numTries = 0; - while (spyDeleted.isEmpty() && spyDirty.isEmpty()) { - if (++numTries > s_maxTries) { - return false; - } - spyDeleted.wait(50); - while (!spyDirty.isEmpty()) { - if (spyDirty.at(0).at(0).toString() != expectedPath) { // unrelated - spyDirty.removeFirst(); - } - } - } - if (!spyDirty.isEmpty()) { - return true; - } - - // Don't bother waiting for the created signal if the signal spy already received a signal. - if(spyCreated.isEmpty() && !spyCreated.wait(50 * s_maxTries)) { - qWarning() << "Timeout waiting for KDirWatch signal created(QString) (" << path << ")"; - return false; - } + // When watching for a deleted + created signal pair, the two might come so close that + // using waitForOneSignal will miss the created signal. This function monitors both all + // the time to ensure both are received. + // + // In addition, it allows dirty() to be emitted (for that same path) as an alternative + + const QString expectedPath = removeTrailingSlash(path); + QSignalSpy spyDirty(&watch, &KDirWatch::dirty); + QSignalSpy spyDeleted(&watch, &KDirWatch::deleted); + QSignalSpy spyCreated(&watch, &KDirWatch::created); - return verifySignalPath(spyDeleted, "deleted(QString)", expectedPath) && verifySignalPath(spyCreated, "created(QString)", expectedPath); + int numTries = 0; + while (spyDeleted.isEmpty() && spyDirty.isEmpty()) { + if (++numTries > s_maxTries) { + return false; + } + spyDeleted.wait(50); + while (!spyDirty.isEmpty()) { + if (spyDirty.at(0).at(0).toString() != expectedPath) { // unrelated + spyDirty.removeFirst(); + } + } + } + if (!spyDirty.isEmpty()) { + return true; + } + + // Don't bother waiting for the created signal if the signal spy already received a signal. + if (spyCreated.isEmpty() && !spyCreated.wait(50 * s_maxTries)) { + qWarning() << "Timeout waiting for KDirWatch signal created(QString) (" << path << ")"; + return false; + } + + return verifySignalPath(spyDeleted, "deleted(QString)", expectedPath) && verifySignalPath(spyCreated, "created(QString)", expectedPath); } QList KDirWatch_UnitTest::waitForDeletedSignal(KDirWatch &watch, int expected) @@ -436,7 +437,7 @@ watch.addDir(QStringLiteral(":/kio5/newfile-templates")); watch.startScan(); if (watch.internalMethod() != KDirWatch::INotify) { - waitUntilNewSecond(); // necessary for mtime checks in scanEntry + waitUntilNewSecond(); // necessary for mtime checks in scanEntry } createFile(0); QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path)); @@ -445,7 +446,7 @@ watch.removeDir(m_path); watch.addDir(m_path); if (watch.internalMethod() != KDirWatch::INotify) { - waitUntilMTimeChange(m_path); // necessary for FAM and QFSWatcher + waitUntilMTimeChange(m_path); // necessary for FAM and QFSWatcher } createFile(1); QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path)); @@ -547,12 +548,11 @@ // Make sure this even works multiple times, as needed for ksycoca for (int i = 0; i < 5; ++i) { - if (m_slow || watch.internalMethod() == KDirWatch::QFSWatch) { waitUntilNewSecond(); } - qCDebug(KCOREADDONS_DEBUG) << "Attempt #" << (i+1) << "removing+recreating" << file1; + qCDebug(KCOREADDONS_DEBUG) << "Attempt #" << (i + 1) << "removing+recreating" << file1; // When watching for a deleted + created signal pair, the two might come so close that // using waitForOneSignal will miss the created signal. This function monitors both all @@ -780,7 +780,7 @@ const QString file2 = createFile(2); QSignalSpy spyDirty(&watch, SIGNAL(dirty(QString))); QTest::qWait(200); - QCOMPARE(spyDirty.count(), 0);// suspended -> no signal + QCOMPARE(spyDirty.count(), 0); // suspended -> no signal watch.restartDirScan(m_path); @@ -831,7 +831,7 @@ QBENCHMARK { KDirWatch watch; - watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch:: WatchFiles); + watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch::WatchFiles); } } @@ -846,7 +846,7 @@ waitUntilMTimeChange(dir.path()); KDirWatch watch; - watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch:: WatchFiles); + watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch::WatchFiles); // now touch all the files repeatedly and wait for the dirty updates to come in QSignalSpy spy(&watch, &KDirWatch::dirty); diff -Nru kcoreaddons-5.79.0/autotests/kfileutilstest.cpp kcoreaddons-5.80.0/autotests/kfileutilstest.cpp --- kcoreaddons-5.79.0/autotests/kfileutilstest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kfileutilstest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -24,10 +24,12 @@ QTest::newRow("existing_1") << "foobar" << (QStringList() << QStringLiteral("foobar") << QStringLiteral("foobar (1)")) << "foobar (2)"; QTest::newRow("extension") << "foobar.txt" << QStringList() << "foobar (1).txt"; QTest::newRow("extension_exists") << "foobar.txt" << (QStringList() << QStringLiteral("foobar.txt")) << "foobar (1).txt"; - QTest::newRow("extension_exists_1") << "foobar.txt" << (QStringList() << QStringLiteral("foobar.txt") << QStringLiteral("foobar (1).txt")) << "foobar (2).txt"; + QTest::newRow("extension_exists_1") << "foobar.txt" << (QStringList() << QStringLiteral("foobar.txt") << QStringLiteral("foobar (1).txt")) + << "foobar (2).txt"; QTest::newRow("two_extensions") << "foobar.tar.gz" << QStringList() << "foobar (1).tar.gz"; QTest::newRow("two_extensions_exists") << "foobar.tar.gz" << (QStringList() << QStringLiteral("foobar.tar.gz")) << "foobar (1).tar.gz"; - QTest::newRow("two_extensions_exists_1") << "foobar.tar.gz" << (QStringList() << QStringLiteral("foobar.tar.gz") << QStringLiteral("foobar (1).tar.gz")) << "foobar (2).tar.gz"; + QTest::newRow("two_extensions_exists_1") << "foobar.tar.gz" << (QStringList() << QStringLiteral("foobar.tar.gz") << QStringLiteral("foobar (1).tar.gz")) + << "foobar (2).tar.gz"; QTest::newRow("with_space") << "foo bar" << QStringList(QStringLiteral("foo bar")) << "foo bar (1)"; QTest::newRow("dot_at_beginning") << ".aFile.tar.gz" << QStringList() << ".aFile (1).tar.gz"; QTest::newRow("dots_at_beginning") << "..aFile.tar.gz" << QStringList() << "..aFile (1).tar.gz"; diff -Nru kcoreaddons-5.79.0/autotests/kfileutilstest.h kcoreaddons-5.80.0/autotests/kfileutilstest.h --- kcoreaddons-5.79.0/autotests/kfileutilstest.h 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kfileutilstest.h 2021-03-06 16:20:44.000000000 +0000 @@ -19,4 +19,3 @@ }; #endif - diff -Nru kcoreaddons-5.79.0/autotests/kformattest.cpp kcoreaddons-5.80.0/autotests/kformattest.cpp --- kcoreaddons-5.79.0/autotests/kformattest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kformattest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -38,7 +38,7 @@ QCOMPARE(format.formatByteSize(5000000), QStringLiteral("4.8 MiB")); QCOMPARE(format.formatByteSize(50000000), QStringLiteral("47.7 MiB")); QCOMPARE(format.formatByteSize(500000000), QStringLiteral("476.8 MiB")); -#if (defined(__WORDSIZE) && (__WORDSIZE == 64)) || defined (_LP64) || defined(__LP64__) || defined(__ILP64__) +#if (defined(__WORDSIZE) && (__WORDSIZE == 64)) || defined(_LP64) || defined(__LP64__) || defined(__ILP64__) QCOMPARE(format.formatByteSize(5000000000), QStringLiteral("4.7 GiB")); QCOMPARE(format.formatByteSize(50000000000), QStringLiteral("46.6 GiB")); QCOMPARE(format.formatByteSize(500000000000), QStringLiteral("465.7 GiB")); @@ -113,14 +113,15 @@ QCOMPARE(format.formatValue(0.010, KFormat::Unit::Meter, 1, KFormat::UnitPrefix::Milli, KFormat::MetricBinaryDialect), QStringLiteral("10.0 mm")); QCOMPARE(format.formatValue(10.12e-6, KFormat::Unit::Meter, 2, KFormat::UnitPrefix::Micro, KFormat::MetricBinaryDialect), QString::fromUtf8("10.12 µm")); - QCOMPARE(format.formatValue(10.55e-6, KFormat::Unit::Meter, 1, KFormat::UnitPrefix::AutoAdjust, KFormat::MetricBinaryDialect), QString::fromUtf8("10.6 µm")); + QCOMPARE(format.formatValue(10.55e-6, KFormat::Unit::Meter, 1, KFormat::UnitPrefix::AutoAdjust, KFormat::MetricBinaryDialect), + QString::fromUtf8("10.6 µm")); } enum TimeConstants { MSecsInDay = 86400000, MSecsInHour = 3600000, MSecsInMinute = 60000, - MSecsInSecond = 1000 + MSecsInSecond = 1000, }; void KFormatTest::formatDuration() @@ -135,7 +136,7 @@ quint64 doubleHour = 15 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700; quint64 singleDay = 1 * MSecsInDay + 5 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700; quint64 doubleDay = 10 * MSecsInDay + 5 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700; - quint64 roundingIssues = 2* MSecsInHour + 59 * MSecsInMinute + 59 * MSecsInSecond + 900; + quint64 roundingIssues = 2 * MSecsInHour + 59 * MSecsInMinute + 59 * MSecsInSecond + 900; quint64 largeValue = 9999999999; // Default format @@ -150,7 +151,6 @@ QCOMPARE(format.formatDuration(roundingIssues), QStringLiteral("3:00:00")); QCOMPARE(format.formatDuration(largeValue), QStringLiteral("2777:46:40")); - // ShowMilliseconds format KFormat::DurationFormatOptions options = KFormat::ShowMilliseconds; QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:00:03.700")); @@ -162,8 +162,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29:08:03.700")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245:08:03.700")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("2:59:59.900")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("2777:46:39.999")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777:46:39.999")); // HideSeconds format options = KFormat::HideSeconds; @@ -176,8 +175,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29:08")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245:08")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3:00")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("2777:47")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777:47")); // FoldHours format options = KFormat::FoldHours; @@ -190,8 +188,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748:04")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708:04")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("180:00")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("166666:40")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666:40")); // FoldHours ShowMilliseconds format options = KFormat::FoldHours; @@ -205,8 +202,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748:03.700")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708:03.700")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("179:59.900")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("166666:39.999")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666:39.999")); // InitialDuration format options = KFormat::InitialDuration; @@ -219,8 +215,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m04s")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m04s")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3h00m00s")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("2777h46m40s")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777h46m40s")); // InitialDuration and ShowMilliseconds format options = KFormat::InitialDuration; @@ -234,8 +229,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m03.700s")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m03.700s")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("2h59m59.900s")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("2777h46m39.999s")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777h46m39.999s")); // InitialDuration and HideSeconds format options = KFormat::InitialDuration; @@ -249,8 +243,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3h00m")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("2777h47m")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777h47m")); // InitialDuration and FoldHours format options = KFormat::InitialDuration; @@ -264,8 +257,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748m04s")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708m04s")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("180m00s")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("166666m40s")); - + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666m40s")); // InitialDuration and FoldHours and ShowMilliseconds format options = KFormat::InitialDuration; @@ -279,7 +271,7 @@ QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748m03.700s")); QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708m03.700s")); QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("179m59.900s")); - QCOMPARE(format.formatDuration(largeValue,options), QStringLiteral("166666m39.999s")); + QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666m39.999s")); } void KFormatTest::formatDecimalDuration() @@ -351,30 +343,31 @@ QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Two days ago")); testDate = QDate::currentDate().addDays(-3); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), - QLocale::c().toString(testDate, QLocale::LongFormat)); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), - QLocale::c().toString(testDate, QLocale::ShortFormat)); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), - QLocale::c().toString(testDate, QLocale::NarrowFormat)); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QLocale::c().toString(testDate, QLocale::LongFormat)); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QLocale::c().toString(testDate, QLocale::ShortFormat)); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QLocale::c().toString(testDate, QLocale::NarrowFormat)); testDate = QDate::currentDate().addDays(3); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), - QLocale::c().toString(testDate, QLocale::LongFormat)); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), - QLocale::c().toString(testDate, QLocale::ShortFormat)); - QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), - QLocale::c().toString(testDate, QLocale::NarrowFormat)); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QLocale::c().toString(testDate, QLocale::LongFormat)); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QLocale::c().toString(testDate, QLocale::ShortFormat)); + QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QLocale::c().toString(testDate, QLocale::NarrowFormat)); testDate = QDate(); // invalid date QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Invalid date")); - QDateTime testDateTime = QDateTime(QDate::currentDate(), QTime(3, 0, 0)); - QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QStringLiteral("Today, 03:00:00")); - QDateTime now = QDateTime::currentDateTime(); - // 1 minute ago + // An hour ago is **usually** today, except after midnight; just bump + // to after 1am to make the "today" test work. + if (now.time().hour() == 0) + { + now = now.addSecs(3601); + } + + QDateTime testDateTime = now.addSecs(-3600); + QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QStringLiteral("Today, %1").arg(testDateTime.toString(QStringLiteral("hh:mm:ss")))); + + // 1 second ago testDateTime = now.addSecs(-1); QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QStringLiteral("Just now")); @@ -383,8 +376,7 @@ QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QStringLiteral("5 minutes ago")); testDateTime = QDateTime(QDate::currentDate().addDays(8), QTime(3, 0, 0)); - QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::LongFormat), - QLocale::c().toString(testDateTime, QLocale::LongFormat)); + QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::LongFormat), QLocale::c().toString(testDateTime, QLocale::LongFormat)); } QTEST_MAIN(KFormatTest) diff -Nru kcoreaddons-5.79.0/autotests/kfuzzymatchertest.cpp kcoreaddons-5.80.0/autotests/kfuzzymatchertest.cpp --- kcoreaddons-5.79.0/autotests/kfuzzymatchertest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kfuzzymatchertest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -47,7 +47,7 @@ QTest::addColumn("input"); QTest::addColumn("expected"); QTest::addColumn("size"); -// clang-format off + // clang-format off QTest::newRow("pattern=sort") << QStringLiteral("sort") << QStringList{ QStringLiteral("Sort"), @@ -159,10 +159,10 @@ QStringLiteral("thsi") } << 3; -// clang-format on + // clang-format on } -static QStringList matchHelper(const QString& pattern, const QStringList& input) +static QStringList matchHelper(const QString &pattern, const QStringList &input) { QVector> actual; for (int i = 0; i < input.size(); ++i) { @@ -173,14 +173,12 @@ } // sort descending based on score - std::sort(actual.begin(), actual.end(), [](const QPair &l, - const QPair &r) { + std::sort(actual.begin(), actual.end(), [](const QPair &l, const QPair &r) { return l.second > r.second; }); - QStringList actualOut; - for (const auto& s : actual) { + for (const auto &s : actual) { actualOut << s.first; } return actualOut; diff -Nru kcoreaddons-5.79.0/autotests/kjobtest.cpp kcoreaddons-5.80.0/autotests/kjobtest.cpp --- kcoreaddons-5.79.0/autotests/kjobtest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kjobtest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -8,9 +8,9 @@ #include "kjobtest.h" #include -#include #include #include +#include #include #include @@ -20,7 +20,6 @@ KJobTest::KJobTest() : loop(this) { - } void KJobTest::testEmitResult_data() @@ -48,7 +47,7 @@ job->setError(errorCode); job->setErrorText(errorText); - QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject*))); + QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject *))); job->start(); QVERIFY(!job->isFinished()); loop.exec(); @@ -73,9 +72,14 @@ qRegisterMetaType("KJob*"); qRegisterMetaType("qulonglong"); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QSignalSpy processed_spy(job, SIGNAL(processedAmount(KJob*,KJob::Unit,qulonglong))); QSignalSpy total_spy(job, SIGNAL(totalAmount(KJob*,KJob::Unit,qulonglong))); QSignalSpy percent_spy(job, SIGNAL(percent(KJob*,ulong))); +#endif + QSignalSpy processedChanged_spy(job, &KJob::processedAmountChanged); + QSignalSpy totalChanged_spy(job, &KJob::totalAmountChanged); + QSignalSpy percentChanged_spy(job, &KJob::percentChanged); /* Process a first item. Corresponding signal should be emitted. * Total size didn't change. @@ -83,17 +87,25 @@ */ testJob->setProcessedSize(1); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(processed_spy.size(), 1); QCOMPARE(processed_spy.at(0).at(0).value(), static_cast(job)); QCOMPARE(processed_spy.at(0).at(2).value(), qulonglong(1)); QCOMPARE(total_spy.size(), 0); QCOMPARE(percent_spy.size(), 0); +#endif + QCOMPARE(processedChanged_spy.size(), 1); + QCOMPARE(processedChanged_spy.at(0).at(0).value(), static_cast(job)); + QCOMPARE(processedChanged_spy.at(0).at(2).value(), qulonglong(1)); + QCOMPARE(totalChanged_spy.size(), 0); + QCOMPARE(percentChanged_spy.size(), 0); /* Now, we know the total size. It's signaled. * The new percentage is signaled too. */ testJob->setTotalSize(10); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(processed_spy.size(), 1); QCOMPARE(total_spy.size(), 1); QCOMPARE(total_spy.at(0).at(0).value(), job); @@ -101,23 +113,39 @@ QCOMPARE(percent_spy.size(), 1); QCOMPARE(percent_spy.at(0).at(0).value(), job); QCOMPARE(percent_spy.at(0).at(1).value(), static_cast(10)); +#endif + QCOMPARE(processedChanged_spy.size(), 1); + QCOMPARE(totalChanged_spy.size(), 1); + QCOMPARE(totalChanged_spy.at(0).at(0).value(), job); + QCOMPARE(totalChanged_spy.at(0).at(2).value(), qulonglong(10)); + QCOMPARE(percentChanged_spy.size(), 1); + QCOMPARE(percentChanged_spy.at(0).at(0).value(), job); + QCOMPARE(percentChanged_spy.at(0).at(1).value(), static_cast(10)); /* We announce a new percentage by hand. * Total, and processed didn't change, so no signal is emitted for them. */ testJob->setPercent(15); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(processed_spy.size(), 1); QCOMPARE(total_spy.size(), 1); QCOMPARE(percent_spy.size(), 2); QCOMPARE(percent_spy.at(1).at(0).value(), job); QCOMPARE(percent_spy.at(1).at(1).value(), static_cast(15)); +#endif + QCOMPARE(processedChanged_spy.size(), 1); + QCOMPARE(totalChanged_spy.size(), 1); + QCOMPARE(percentChanged_spy.size(), 2); + QCOMPARE(percentChanged_spy.at(1).at(0).value(), job); + QCOMPARE(percentChanged_spy.at(1).at(1).value(), static_cast(15)); /* We make some progress. * Processed size and percent are signaled. */ testJob->setProcessedSize(3); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(processed_spy.size(), 2); QCOMPARE(processed_spy.at(1).at(0).value(), job); QCOMPARE(processed_spy.at(1).at(2).value(), qulonglong(3)); @@ -125,21 +153,34 @@ QCOMPARE(percent_spy.size(), 3); QCOMPARE(percent_spy.at(2).at(0).value(), job); QCOMPARE(percent_spy.at(2).at(1).value(), static_cast(30)); +#endif + QCOMPARE(processedChanged_spy.size(), 2); + QCOMPARE(processedChanged_spy.at(1).at(0).value(), job); + QCOMPARE(processedChanged_spy.at(1).at(2).value(), qulonglong(3)); + QCOMPARE(totalChanged_spy.size(), 1); + QCOMPARE(percentChanged_spy.size(), 3); + QCOMPARE(percentChanged_spy.at(2).at(0).value(), job); + QCOMPARE(percentChanged_spy.at(2).at(1).value(), static_cast(30)); /* We set a new total size, but equals to the previous one. * No signal is emitted. */ testJob->setTotalSize(10); - +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(processed_spy.size(), 2); QCOMPARE(total_spy.size(), 1); QCOMPARE(percent_spy.size(), 3); +#endif + QCOMPARE(processedChanged_spy.size(), 2); + QCOMPARE(totalChanged_spy.size(), 1); + QCOMPARE(percentChanged_spy.size(), 3); /* We 'lost' the previous work done. * Signals both percentage and new processed size. */ testJob->setProcessedSize(0); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(processed_spy.size(), 3); QCOMPARE(processed_spy.at(2).at(0).value(), job); QCOMPARE(processed_spy.at(2).at(2).value(), qulonglong(0)); @@ -147,6 +188,14 @@ QCOMPARE(percent_spy.size(), 4); QCOMPARE(percent_spy.at(3).at(0).value(), job); QCOMPARE(percent_spy.at(3).at(1).value(), static_cast(0)); +#endif + QCOMPARE(processedChanged_spy.size(), 3); + QCOMPARE(processedChanged_spy.at(2).at(0).value(), job); + QCOMPARE(processedChanged_spy.at(2).at(2).value(), qulonglong(0)); + QCOMPARE(totalChanged_spy.size(), 1); + QCOMPARE(percentChanged_spy.size(), 4); + QCOMPARE(percentChanged_spy.at(3).at(0).value(), job); + QCOMPARE(percentChanged_spy.at(3).at(1).value(), static_cast(0)); /* We process more than the total size!? * Signals both percentage and new processed size. @@ -156,6 +205,7 @@ */ testJob->setProcessedSize(15); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(processed_spy.size(), 4); QCOMPARE(processed_spy.at(3).at(0).value(), job); QCOMPARE(processed_spy.at(3).at(2).value(), qulonglong(15)); @@ -163,25 +213,49 @@ QCOMPARE(percent_spy.size(), 5); QCOMPARE(percent_spy.at(4).at(0).value(), job); QCOMPARE(percent_spy.at(4).at(1).value(), static_cast(150)); +#endif + QCOMPARE(processedChanged_spy.size(), 4); + QCOMPARE(processedChanged_spy.at(3).at(0).value(), job); + QCOMPARE(processedChanged_spy.at(3).at(2).value(), qulonglong(15)); + QCOMPARE(totalChanged_spy.size(), 1); + QCOMPARE(percentChanged_spy.size(), 5); + QCOMPARE(percentChanged_spy.at(4).at(0).value(), job); + QCOMPARE(percentChanged_spy.at(4).at(1).value(), static_cast(150)); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) processed_spy.clear(); total_spy.clear(); percent_spy.clear(); +#endif + processedChanged_spy.clear(); + totalChanged_spy.clear(); + percentChanged_spy.clear(); /** * Try again with Files as the progress unit */ testJob->setProgressUnit(KJob::Files); testJob->setProcessedSize(16); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(percent_spy.size(), 0); // no impact on percent +#endif + QCOMPARE(percentChanged_spy.size(), 0); testJob->setTotalFiles(5); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(percent_spy.size(), 1); QCOMPARE(percent_spy.at(0).at(1).value(), static_cast(0)); +#endif + QCOMPARE(percentChanged_spy.size(), 1); + QCOMPARE(percentChanged_spy.at(0).at(1).value(), static_cast(0)); testJob->setProcessedFiles(2); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80) QCOMPARE(percent_spy.size(), 2); QCOMPARE(percent_spy.at(1).at(1).value(), static_cast(40)); +#endif + QCOMPARE(percentChanged_spy.size(), 2); + QCOMPARE(percentChanged_spy.at(1).at(1).value(), static_cast(40)); delete job; } @@ -208,9 +282,11 @@ int resultEmitted = 0; // Prove to Kai Uwe that one can connect a job to a lambdas, despite the "private" signal - connect(job, &KJob::result, this, [&resultEmitted](KJob *) { ++resultEmitted; }); + connect(job, &KJob::result, this, [&resultEmitted](KJob *) { + ++resultEmitted; + }); - QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject*))); + QSignalSpy destroyed_spy(job, SIGNAL(destroyed(QObject *))); QVERIFY(!job->isFinished()); bool status = job->exec(); @@ -218,8 +294,8 @@ QCOMPARE(resultEmitted, 1); QCOMPARE(status, (errorCode == KJob::NoError)); - QCOMPARE(job->error(), errorCode); - QCOMPARE(job->errorText(), errorText); + QCOMPARE(job->error(), errorCode); + QCOMPARE(job->errorText(), errorText); // Verify that the job is not deleted immediately... QCOMPARE(destroyed_spy.size(), 0); @@ -237,16 +313,8 @@ QTest::addColumn("resultEmitCount"); QTest::addColumn("finishedEmitCount"); - QTest::newRow("killed with result") << int(KJob::EmitResult) - << int(KJob::KilledJobError) - << QString() - << 1 - << 1; - QTest::newRow("killed quietly") << int(KJob::Quietly) - << int(KJob::KilledJobError) - << QString() - << 0 - << 1; + QTest::newRow("killed with result") << int(KJob::EmitResult) << int(KJob::KilledJobError) << QString() << 1 << 1; + QTest::newRow("killed quietly") << int(KJob::Quietly) << int(KJob::KilledJobError) << QString() << 0 << 1; } void KJobTest::testKill() @@ -268,8 +336,8 @@ QCOMPARE(m_lastError, errorCode); QCOMPARE(m_lastErrorText, errorText); - QCOMPARE(job->error(), errorCode); - QCOMPARE(job->errorText(), errorText); + QCOMPARE(job->error(), errorCode); + QCOMPARE(job->errorText(), errorText); QCOMPARE(m_resultCount, resultEmitCount); QCOMPARE(m_finishedCount, finishedEmitCount); @@ -280,6 +348,9 @@ // ... but when we enter the event loop again. loop.exec(); QCOMPARE(destroyed_spy.size(), 1); + + QVERIFY(m_jobFinishCount.size() == (finishedEmitCount - resultEmitCount)); + m_jobFinishCount.clear(); } void KJobTest::testDestroy() @@ -291,6 +362,9 @@ QCOMPARE(m_lastErrorText, QString{}); QCOMPARE(m_resultCount, 0); QCOMPARE(m_finishedCount, 1); + + QVERIFY(m_jobFinishCount.size() == 1); + m_jobFinishCount.clear(); } void KJobTest::testEmitAtMostOnce_data() @@ -305,8 +379,7 @@ for (bool autoDelete : {true, false}) { for (Action a : {Action::Start, Action::KillQuietly, Action::KillVerbosely}) { for (Action b : {Action::Start, Action::KillQuietly, Action::KillVerbosely}) { - const auto dataTag = std::string{actionName(a)} + '-' + actionName(b) - + (autoDelete ? "-autoDelete" : ""); + const auto dataTag = std::string{actionName(a)} + '-' + actionName(b) + (autoDelete ? "-autoDelete" : ""); QTest::newRow(dataTag.c_str()) << autoDelete << QVector{a, b}; } } @@ -324,15 +397,19 @@ QFETCH(QVector, actions); for (auto action : actions) { switch (action) { - case Action::Start: - job->start(); // in effect calls QTimer::singleShot(0, ... emitResult) - break; - case Action::KillQuietly: - QTimer::singleShot(0, job, [=] { job->kill(KJob::Quietly); }); - break; - case Action::KillVerbosely: - QTimer::singleShot(0, job, [=] { job->kill(KJob::EmitResult); }); - break; + case Action::Start: + job->start(); // in effect calls QTimer::singleShot(0, ... emitResult) + break; + case Action::KillQuietly: + QTimer::singleShot(0, job, [=] { + job->kill(KJob::Quietly); + }); + break; + case Action::KillVerbosely: + QTimer::singleShot(0, job, [=] { + job->kill(KJob::EmitResult); + }); + break; } } @@ -347,8 +424,7 @@ // The first action alone should determine the job's error and result. const auto firstAction = actions.front(); - const int errorCode = firstAction == Action::Start ? KJob::NoError - : KJob::KilledJobError; + const int errorCode = firstAction == Action::Start ? KJob::NoError : KJob::KilledJobError; QCOMPARE(m_lastError, errorCode); QCOMPARE(m_lastErrorText, QString{}); if (!autoDelete) { @@ -416,6 +492,13 @@ QVERIFY(testJob); QVERIFY(testJob->isFinished()); + // Ensure the job has already emitted finished() if we are tracking from + // setupErrorResultFinished + if(m_jobFinishCount.contains(job)) { + QVERIFY(m_jobFinishCount.value(job) == 1); + QVERIFY(m_jobFinishCount.remove(job) == 1 /* num items removed */); + } + if (job->error()) { m_lastError = job->error(); m_lastErrorText = job->errorText(); @@ -429,14 +512,8 @@ void KJobTest::slotFinished(KJob *job) { - // qobject_cast and dynamic_cast to TestJob* fail when finished() signal is emitted from - // ~KJob(). The static_cast allows to call the otherwise protected KJob::isFinished(). - // WARNING: don't use this trick in production code, because static_cast-ing - // to a wrong type and then dereferencing the pointer is undefined behavior. - // Normally a KJob and its subclasses should manage their finished state on their own. - // If you *really* need KJob::isFinished() to be public, request this access - // modifier change in the KJob class. - QVERIFY(static_cast(job)->isFinished()); + QVERIFY2(m_jobFinishCount.value(job) == 0, "Ensure we have not double-emitted KJob::finished()"); + m_jobFinishCount[job]++; if (job->error()) { m_lastError = job->error(); @@ -457,24 +534,26 @@ m_finishedCount = 0; auto *job = new TestJob; + m_jobFinishCount[job] = 0; connect(job, &KJob::result, this, &KJobTest::slotResult); connect(job, &KJob::finished, this, &KJobTest::slotFinished); return job; } -TestJob::TestJob() : KJob() +TestJob::TestJob() + : KJob() { - } TestJob::~TestJob() { - } void TestJob::start() { - QTimer::singleShot(0, this, [this] { emitResult(); }); + QTimer::singleShot(0, this, [this] { + emitResult(); + }); } bool TestJob::doKill() diff -Nru kcoreaddons-5.79.0/autotests/kjobtest.h kcoreaddons-5.80.0/autotests/kjobtest.h --- kcoreaddons-5.79.0/autotests/kjobtest.h 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kjobtest.h 2021-03-06 16:20:44.000000000 +0000 @@ -8,10 +8,11 @@ #ifndef KJOBTEST_H #define KJOBTEST_H -#include -#include #include "kjob.h" #include "kjobuidelegate.h" +#include +#include +#include class TestJob : public KJob { @@ -53,7 +54,7 @@ enum class Action { Start, KillQuietly, - KillVerbosely + KillVerbosely, }; Q_ENUM(Action) @@ -94,16 +95,15 @@ WaitJob *m_outerJob; WaitJob *m_innerJob; + QMap m_jobFinishCount; }; class WaitJob : public KJob { Q_OBJECT public: - void start() override; void makeItFinish(); }; #endif - diff -Nru kcoreaddons-5.79.0/autotests/klistopenfilesjobtest_unix.cpp kcoreaddons-5.80.0/autotests/klistopenfilesjobtest_unix.cpp --- kcoreaddons-5.79.0/autotests/klistopenfilesjobtest_unix.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/klistopenfilesjobtest_unix.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -22,8 +22,8 @@ Q_CONSTRUCTOR_FUNCTION(initLocale) -namespace { - +namespace +{ bool hasLsofInstalled() { return !QStandardPaths::findExecutable(QStringLiteral("lsof")).isEmpty(); @@ -44,13 +44,11 @@ QCOMPARE(job->error(), KJob::NoError); auto processInfoList = job->processInfoList(); QVERIFY(!processInfoList.empty()); - auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), - [](const KProcessList::KProcessInfo& info) - { + auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), [](const KProcessList::KProcessInfo &info) { return info.pid() == QCoreApplication::applicationPid(); }); QVERIFY(testProcessIterator != processInfoList.end()); - const auto& processInfo = *testProcessIterator; + const auto &processInfo = *testProcessIterator; QVERIFY(processInfo.isValid()); QCOMPARE(processInfo.pid(), QCoreApplication::applicationPid()); } @@ -86,7 +84,7 @@ class ScopedEnvVariable { public: - ScopedEnvVariable(const QLatin1String& Name, const QByteArray& NewValue) + ScopedEnvVariable(const QLatin1String &Name, const QByteArray &NewValue) : name(Name) , originalValue(qgetenv(name.latin1())) { @@ -96,6 +94,7 @@ { qputenv(name.latin1(), originalValue); } + private: const QLatin1String name; const QByteArray originalValue; diff -Nru kcoreaddons-5.79.0/autotests/kmacroexpandertest.cpp kcoreaddons-5.80.0/autotests/kmacroexpandertest.cpp --- kcoreaddons-5.79.0/autotests/kmacroexpandertest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kmacroexpandertest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -26,8 +26,14 @@ class MyCExpander : public KCharMacroExpander { QString exp; + public: - MyCExpander() : KCharMacroExpander(), exp("expanded") { } + MyCExpander() + : KCharMacroExpander() + , exp("expanded") + { + } + protected: bool expandMacro(QChar ch, QStringList &ret) { @@ -42,8 +48,14 @@ class MyWExpander : public KWordMacroExpander { QString exp; + public: - MyWExpander() : KWordMacroExpander(), exp("expanded") { } + MyWExpander() + : KWordMacroExpander() + , exp("expanded") + { + } + protected: bool expandMacro(const QString &str, QStringList &ret) { @@ -55,8 +67,7 @@ } }; -void -KMacroExpanderTest::expandMacros() +void KMacroExpanderTest::expandMacros() { QHash map; QStringList list; @@ -69,11 +80,9 @@ map.insert('l', list); s = "%% text %l text %n"; - QCOMPARE(KMacroExpander::expandMacros(s, map), - QLatin1String("% text element1 'element2' text Restaurant \"Chew It\"")); + QCOMPARE(KMacroExpander::expandMacros(s, map), QLatin1String("% text element1 'element2' text Restaurant \"Chew It\"")); s = "text \"%l %n\" text"; - QCOMPARE(KMacroExpander::expandMacros(s, map), - QLatin1String("text \"element1 'element2' Restaurant \"Chew It\"\" text")); + QCOMPARE(KMacroExpander::expandMacros(s, map), QLatin1String("text \"element1 'element2' Restaurant \"Chew It\"\" text")); QHash map2; map2.insert('a', "%n"); @@ -81,8 +90,7 @@ map2.insert('u', "https://www.kde.org/index.html"); map2.insert('n', "Restaurant \"Chew It\""); s = "Title: %a - %f - %u - %n - %%"; - QCOMPARE(KMacroExpander::expandMacros(s, map2), - QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); + QCOMPARE(KMacroExpander::expandMacros(s, map2), QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); QHash smap; smap.insert("foo", "%n"); @@ -91,35 +99,27 @@ smap.insert("name", "Restaurant \"Chew It\""); s = "Title: %foo - %file - %url - %name - %"; - QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); + QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); s = "%foo - %file - %url - %name"; - QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\"")); + QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\"")); s = "Title: %{foo} - %{file} - %{url} - %{name} - %"; - QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); + QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %")); s = "%{foo} - %{file} - %{url} - %{name}"; - QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\"")); + QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\"")); s = "Title: %foo-%file-%url-%name-%"; - QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("Title: %n-filename.txt-https://www.kde.org/index.html-Restaurant \"Chew It\"-%")); + QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: %n-filename.txt-https://www.kde.org/index.html-Restaurant \"Chew It\"-%")); s = "Title: %{file} %{url"; - QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String("Title: filename.txt %{url")); + QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: filename.txt %{url")); s = " * Copyright (C) 2008 %{AUTHOR}"; smap.clear(); - QCOMPARE(KMacroExpander::expandMacros(s, smap), - QLatin1String(" * Copyright (C) 2008 %{AUTHOR}")); + QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String(" * Copyright (C) 2008 %{AUTHOR}")); } -void -KMacroExpanderTest::expandMacrosShellQuote() +void KMacroExpanderTest::expandMacrosShellQuote() { QHash map; QStringList list; @@ -141,12 +141,10 @@ QLatin1String("text \"element1 'element2' \"\\^\"\"element3\"\\^\"\" Restaurant \"\\^\"\"Chew It\"\\^\"\"\" text")); #else s = "text %l %n text"; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map), - QLatin1String("text element1 ''\\''element2'\\''' '\"element3\"' 'Restaurant \"Chew It\"' text")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map), QLatin1String("text element1 ''\\''element2'\\''' '\"element3\"' 'Restaurant \"Chew It\"' text")); s = "text \"%l %n\" text"; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map), - QLatin1String("text \"element1 'element2' \\\"element3\\\" Restaurant \\\"Chew It\\\"\" text")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map), QLatin1String("text \"element1 'element2' \\\"element3\\\" Restaurant \\\"Chew It\\\"\" text")); #endif QHash map2; @@ -157,41 +155,35 @@ #ifdef Q_OS_WIN s = "Title: %a - %f - %u - %n - %% - %VARIABLE% foo"; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("Title: %PERCENT_SIGN%n - filename.txt - https://www.kde.org/index.html - \"Restaurant \"\\^\"\"Chew It\"\\^\" - %PERCENT_SIGN% - %VARIABLE% foo")); + QCOMPARE( + KMacroExpander::expandMacrosShellQuote(s, map2), + QLatin1String( + "Title: %PERCENT_SIGN%n - filename.txt - https://www.kde.org/index.html - \"Restaurant \"\\^\"\"Chew It\"\\^\" - %PERCENT_SIGN% - %VARIABLE% foo")); s = "kedit --caption %n %f"; map2.insert('n', "Restaurant 'Chew It'"); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt")); s = "kedit --caption \"%n\" %f"; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt")); map2.insert('n', "Restaurant \"Chew It\""); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant \"\\^\"\"Chew It\"\\^\"\"\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \"\\^\"\"Chew It\"\\^\"\"\" filename.txt")); map2.insert('n', "Restaurant %HOME%"); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant %PERCENT_SIGN%HOME%PERCENT_SIGN%\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant %PERCENT_SIGN%HOME%PERCENT_SIGN%\" filename.txt")); s = "kedit c:\\%f"; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit c:\\filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit c:\\filename.txt")); s = "kedit \"c:\\%f\""; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit \"c:\\filename.txt\"")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit \"c:\\filename.txt\"")); map2.insert('f', "\"filename.txt\""); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit \"c:\\\\\"\\^\"\"filename.txt\"\\^\"\"\"")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit \"c:\\\\\"\\^\"\"filename.txt\"\\^\"\"\"")); map2.insert('f', "path\\"); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit \"c:\\path\\\\\"\"\"")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit \"c:\\path\\\\\"\"\"")); #else s = "Title: %a - %f - %u - %n - %%"; QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), @@ -199,35 +191,33 @@ s = "kedit --caption %n %f"; map2.insert('n', "Restaurant 'Chew It'"); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption 'Restaurant '\\''Chew It'\\''' filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption 'Restaurant '\\''Chew It'\\''' filename.txt")); s = "kedit --caption \"%n\" %f"; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt")); map2.insert('n', "Restaurant \"Chew It\""); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant \\\"Chew It\\\"\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \\\"Chew It\\\"\" filename.txt")); map2.insert('n', "Restaurant $HOME"); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant \\$HOME\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \\$HOME\" filename.txt")); map2.insert('n', "Restaurant `echo hello`"); - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"Restaurant \\`echo hello\\`\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \\`echo hello\\`\" filename.txt")); s = "kedit --caption \"`echo %n`\" %f"; - QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), - QLatin1String("kedit --caption \"$( echo 'Restaurant `echo hello`')\" filename.txt")); + QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"$( echo 'Restaurant `echo hello`')\" filename.txt")); #endif } class DummyMacroExpander : public KMacroExpanderBase { public: - DummyMacroExpander() : KMacroExpanderBase(QChar(0x4567)) { } + DummyMacroExpander() + : KMacroExpanderBase(QChar(0x4567)) + { + } + protected: int expandPlainMacro(const QString &, int, QStringList &) { @@ -239,8 +229,7 @@ } }; -void -KMacroExpanderTest::expandMacrosShellQuoteParens() +void KMacroExpanderTest::expandMacrosShellQuoteParens() { QHash map; QStringList list; @@ -252,11 +241,9 @@ QVERIFY(kmx.expandMacrosShellQuote(s, pos)); QCOMPARE(s.mid(pos), QLatin1String(") after")); QVERIFY(!kmx.expandMacrosShellQuote(s)); - } -void -KMacroExpanderTest::expandMacrosSubClass() +void KMacroExpanderTest::expandMacrosSubClass() { QString s; diff -Nru kcoreaddons-5.79.0/autotests/kosreleasetest.cpp kcoreaddons-5.80.0/autotests/kosreleasetest.cpp --- kcoreaddons-5.79.0/autotests/kosreleasetest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kosreleasetest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -18,7 +18,7 @@ QCOMPARE(r.name(), QStringLiteral("Name")); QCOMPARE(r.version(), QStringLiteral("100.5")); QCOMPARE(r.id(), QStringLiteral("theid")); - QCOMPARE(r.idLike(), QStringList({ QStringLiteral("otherid"), QStringLiteral("otherotherid") })); + QCOMPARE(r.idLike(), QStringList({QStringLiteral("otherid"), QStringLiteral("otherotherid")})); QCOMPARE(r.versionCodename(), QStringLiteral("versioncodename")); QCOMPARE(r.versionId(), QStringLiteral("500.1")); QCOMPARE(r.prettyName(), QStringLiteral("Pretty Name #1")); @@ -33,7 +33,7 @@ QCOMPARE(r.variant(), QStringLiteral("Test = Edition")); QCOMPARE(r.variantId(), QStringLiteral("test")); QCOMPARE(r.logo(), QStringLiteral("start-here-test")); - QCOMPARE(r.extraKeys(), QStringList({ QStringLiteral("DEBIAN_BTS") })); + QCOMPARE(r.extraKeys(), QStringList({QStringLiteral("DEBIAN_BTS")})); QCOMPARE(r.extraValue(QStringLiteral("DEBIAN_BTS")), QStringLiteral("debbugs://bugs.debian.org/")); } }; diff -Nru kcoreaddons-5.79.0/autotests/kpluginfactorytest.cpp kcoreaddons-5.80.0/autotests/kpluginfactorytest.cpp --- kcoreaddons-5.79.0/autotests/kpluginfactorytest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kpluginfactorytest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -6,8 +6,8 @@ #include -#include #include +#include class KPluginFactoryTest : public QObject { @@ -49,4 +49,3 @@ QTEST_MAIN(KPluginFactoryTest) #include "kpluginfactorytest.moc" - diff -Nru kcoreaddons-5.79.0/autotests/kpluginloadertest.cpp kcoreaddons-5.80.0/autotests/kpluginloadertest.cpp --- kcoreaddons-5.79.0/autotests/kpluginloadertest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kpluginloadertest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -4,17 +4,25 @@ SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ -#include #include +#include +#include "kcoreaddons_debug.h" #include #include -#include "kcoreaddons_debug.h" -class LibraryPathRestorer { +class LibraryPathRestorer +{ public: - explicit LibraryPathRestorer(const QStringList &paths) : mPaths(paths) {} - ~LibraryPathRestorer() { QCoreApplication::setLibraryPaths(mPaths); } + explicit LibraryPathRestorer(const QStringList &paths) + : mPaths(paths) + { + } + ~LibraryPathRestorer() + { + QCoreApplication::setLibraryPaths(mPaths); + } + private: QStringList mPaths; }; @@ -96,12 +104,10 @@ void testFileName() { KPluginLoader vplugin(QStringLiteral("versionedplugin")); - QCOMPARE(QFileInfo(vplugin.fileName()).canonicalFilePath(), - QFileInfo(QStringLiteral(VERSIONEDPLUGIN_FILE)).canonicalFilePath()); + QCOMPARE(QFileInfo(vplugin.fileName()).canonicalFilePath(), QFileInfo(QStringLiteral(VERSIONEDPLUGIN_FILE)).canonicalFilePath()); KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin"))); - QCOMPARE(QFileInfo(jplugin.fileName()).canonicalFilePath(), - QFileInfo(QStringLiteral(JSONPLUGIN_FILE)).canonicalFilePath()); + QCOMPARE(QFileInfo(jplugin.fileName()).canonicalFilePath(), QFileInfo(QStringLiteral(JSONPLUGIN_FILE)).canonicalFilePath()); KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error"))); QVERIFY2(eplugin.fileName().isEmpty(), qPrintable(eplugin.fileName())); @@ -236,29 +242,29 @@ qPrintable(dir.absoluteFilePath(QFileInfo(plugin3Path).fileName()))); // only jsonplugin, since unversionedplugin has no json metadata - QList plugins = KPluginLoader::instantiatePlugins(temp.path()); + QList plugins = KPluginLoader::instantiatePlugins(temp.path()); QCOMPARE(plugins.size(), 2); QStringList classNames = QStringList() << QString::fromLatin1(plugins[0]->metaObject()->className()) - << QString::fromLatin1(plugins[1]->metaObject()->className()); + << QString::fromLatin1(plugins[1]->metaObject()->className()); classNames.sort(); QCOMPARE(classNames[0], QStringLiteral("jsonplugin2")); QCOMPARE(classNames[1], QStringLiteral("jsonpluginfa")); qDeleteAll(plugins); - //try filter - plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData & md) { + // try filter + plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData &md) { return md.pluginId() == QLatin1String("jsonplugin"); }); QCOMPARE(plugins.size(), 1); QCOMPARE(plugins[0]->metaObject()->className(), "jsonpluginfa"); qDeleteAll(plugins); - plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData & md) { + plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData &md) { return md.pluginId() == QLatin1String("unversionedplugin"); }); QCOMPARE(plugins.size(), 0); - plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData & md) { + plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData &md) { return md.pluginId() == QLatin1String("foobar"); // ID does not match file name, is set in JSON }); QCOMPARE(plugins.size(), 1); @@ -266,7 +272,12 @@ qDeleteAll(plugins); // check that parent gets set - plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData&) { return true; }, this); + plugins = KPluginLoader::instantiatePlugins( + temp.path(), + [](const KPluginMetaData &) { + return true; + }, + this); QCOMPARE(plugins.size(), 2); QCOMPARE(plugins[0]->parent(), this); QCOMPARE(plugins[1]->parent(), this); @@ -281,8 +292,7 @@ QVERIFY(!QDir::isAbsolutePath(subDirName)); plugins = KPluginLoader::instantiatePlugins(subDirName); QCOMPARE(plugins.size(), 2); - classNames = QStringList() << QString::fromLatin1(plugins[0]->metaObject()->className()) - << QString::fromLatin1(plugins[1]->metaObject()->className()); + classNames = QStringList() << QString::fromLatin1(plugins[0]->metaObject()->className()) << QString::fromLatin1(plugins[1]->metaObject()->className()); classNames.sort(); QCOMPARE(classNames[0], QStringLiteral("jsonplugin2")); QCOMPARE(classNames[1], QStringLiteral("jsonpluginfa")); @@ -296,11 +306,11 @@ QDir dir(temp.path()); QVERIFY(dir.mkdir(QStringLiteral("kpluginmetadatatest"))); QVERIFY(dir.cd(QStringLiteral("kpluginmetadatatest"))); - for (const QString &name : { QStringLiteral("jsonplugin"), QStringLiteral("unversionedplugin"), QStringLiteral("jsonplugin2") }) { + for (const QString &name : {QStringLiteral("jsonplugin"), QStringLiteral("unversionedplugin"), QStringLiteral("jsonplugin2")}) { const QString pluginPath = KPluginLoader::findPlugin(name); QVERIFY2(!pluginPath.isEmpty(), qPrintable(pluginPath)); QVERIFY2(QFile::copy(pluginPath, dir.absoluteFilePath(QFileInfo(pluginPath).fileName())), - qPrintable(dir.absoluteFilePath(QFileInfo(pluginPath).fileName()))); + qPrintable(dir.absoluteFilePath(QFileInfo(pluginPath).fileName()))); } LibraryPathRestorer restorer(QCoreApplication::libraryPaths()); @@ -320,25 +330,33 @@ QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin")); // filter accepts none - plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) { return false; }); + plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) { + return false; + }); std::sort(plugins.begin(), plugins.end(), sortPlugins); QCOMPARE(plugins.size(), 0); // filter accepts all - plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) { return true; }); + plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) { + return true; + }); std::sort(plugins.begin(), plugins.end(), sortPlugins); QCOMPARE(plugins.size(), 2); QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin")); QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin")); // mimetype filter. Only one match, jsonplugin2 is specific to text/html. - auto supportTextPlain = [](const KPluginMetaData &metaData) { return metaData.supportsMimeType(QLatin1String("text/plain")); }; + auto supportTextPlain = [](const KPluginMetaData &metaData) { + return metaData.supportsMimeType(QLatin1String("text/plain")); + }; plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), supportTextPlain); QCOMPARE(plugins.size(), 1); QCOMPARE(plugins[0].description(), QStringLiteral("This is a plugin")); // mimetype filter. Two matches, both support text/html, via inheritance. - auto supportTextHtml = [](const KPluginMetaData &metaData) { return metaData.supportsMimeType(QLatin1String("text/html")); }; + auto supportTextHtml = [](const KPluginMetaData &metaData) { + return metaData.supportsMimeType(QLatin1String("text/html")); + }; plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), supportTextHtml); std::sort(plugins.begin(), plugins.end(), sortPlugins); QCOMPARE(plugins.size(), 2); @@ -346,7 +364,9 @@ QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin")); // mimetype filter with invalid mimetype - auto supportDoesNotExist = [](const KPluginMetaData &metaData) { return metaData.supportsMimeType(QLatin1String("does/not/exist")); }; + auto supportDoesNotExist = [](const KPluginMetaData &metaData) { + return metaData.supportsMimeType(QLatin1String("does/not/exist")); + }; plugins = KPluginLoader::findPlugins(QStringLiteral("kpluginmetadatatest"), supportDoesNotExist); QCOMPARE(plugins.size(), 0); @@ -415,7 +435,6 @@ foundPlugins.sort(); QCOMPARE(foundPlugins, expectedPlugins); - expectedPlugins = QStringList() << jsonPlugin2Dest; expectedPlugins.sort(); foundPlugins.clear(); diff -Nru kcoreaddons-5.79.0/autotests/kpluginmetadatatest.cpp kcoreaddons-5.80.0/autotests/kpluginmetadatatest.cpp --- kcoreaddons-5.79.0/autotests/kpluginmetadatatest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kpluginmetadatatest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -4,24 +4,25 @@ SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ -#include -#include -#include #include -#include #include +#include +#include +#include +#include -#include -#include -#include #include "kcoreaddons_debug.h" +#include +#include +#include #include #include namespace QTest { -template<> inline char *toString(const QJsonValue &val) +template<> +inline char *toString(const QJsonValue &val) { // simply reuse the QDebug representation QString result; @@ -69,7 +70,7 @@ void testFromPluginLoader() { QString location = KPluginLoader::findPlugin(QStringLiteral("jsonplugin")); - QVERIFY2(!location.isEmpty(),"Could not find jsonplugin"); + QVERIFY2(!location.isEmpty(), "Could not find jsonplugin"); // now that this file is translated we need to read it instead of hardcoding the contents here QString jsonLocation = QFINDTESTDATA("jsonplugin.json"); @@ -122,32 +123,34 @@ QCOMPARE(fromRawData, fromQPluginLoader); QCOMPARE(fromRawData, fromKPluginLoader); QCOMPARE(fromRawData, fromFullPath); - } void testAllKeys() { QJsonParseError e; - QJsonObject jo = QJsonDocument::fromJson("{\n" - " \"KPlugin\": {\n" - " \"Name\": \"Date and Time\",\n" - " \"Description\": \"Date and time by timezone\",\n" - " \"Icon\": \"preferences-system-time\",\n" - " \"Authors\": { \"Name\": \"Aaron Seigo\", \"Email\": \"aseigo@kde.org\" },\n" - " \"Translators\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" - " \"OtherContributors\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" - " \"Category\": \"Date and Time\",\n" - " \"Dependencies\": [ \"foo\", \"bar\"],\n" - " \"EnabledByDefault\": \"true\",\n" - " \"ExtraInformation\": \"Something else\",\n" - " \"License\": \"LGPL\",\n" - " \"Copyright\": \"(c) Alex Richardson 2015\",\n" - " \"Id\": \"time\",\n" - " \"Version\": \"1.0\",\n" - " \"Website\": \"https://plasma.kde.org/\",\n" - " \"MimeTypes\": [ \"image/png\" ],\n" - " \"ServiceTypes\": [\"Plasma/DataEngine\"]\n" - " }\n}\n", &e).object(); + QJsonObject jo = QJsonDocument::fromJson( + "{\n" + " \"KPlugin\": {\n" + " \"Name\": \"Date and Time\",\n" + " \"Description\": \"Date and time by timezone\",\n" + " \"Icon\": \"preferences-system-time\",\n" + " \"Authors\": { \"Name\": \"Aaron Seigo\", \"Email\": \"aseigo@kde.org\" },\n" + " \"Translators\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" + " \"OtherContributors\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n" + " \"Category\": \"Date and Time\",\n" + " \"Dependencies\": [ \"foo\", \"bar\"],\n" + " \"EnabledByDefault\": \"true\",\n" + " \"ExtraInformation\": \"Something else\",\n" + " \"License\": \"LGPL\",\n" + " \"Copyright\": \"(c) Alex Richardson 2015\",\n" + " \"Id\": \"time\",\n" + " \"Version\": \"1.0\",\n" + " \"Website\": \"https://plasma.kde.org/\",\n" + " \"MimeTypes\": [ \"image/png\" ],\n" + " \"ServiceTypes\": [\"Plasma/DataEngine\"]\n" + " }\n}\n", + &e) + .object(); QCOMPARE(e.error, QJsonParseError::NoError); KPluginMetaData m(jo, QString()); QVERIFY(m.isValid()); @@ -181,14 +184,17 @@ void testTranslations() { QJsonParseError e; - QJsonObject jo = QJsonDocument::fromJson("{ \"KPlugin\": {\n" - "\"Name\": \"Name\",\n" - "\"Name[de]\": \"Name (de)\",\n" - "\"Name[de_DE]\": \"Name (de_DE)\",\n" - "\"Description\": \"Description\",\n" - "\"Description[de]\": \"Beschreibung (de)\",\n" - "\"Description[de_DE]\": \"Beschreibung (de_DE)\"\n" - "}\n}", &e).object(); + QJsonObject jo = QJsonDocument::fromJson( + "{ \"KPlugin\": {\n" + "\"Name\": \"Name\",\n" + "\"Name[de]\": \"Name (de)\",\n" + "\"Name[de_DE]\": \"Name (de_DE)\",\n" + "\"Description\": \"Description\",\n" + "\"Description[de]\": \"Beschreibung (de)\",\n" + "\"Description[de_DE]\": \"Beschreibung (de_DE)\"\n" + "}\n}", + &e) + .object(); KPluginMetaData m(jo, QString()); QLocale::setDefault(QLocale::c()); QCOMPARE(m.name(), QStringLiteral("Name")); @@ -213,25 +219,29 @@ return; } QJsonParseError e; - QJsonObject jo = QJsonDocument::fromJson("{\n" - "\"String\": \"foo\",\n" - "\"OneArrayEntry\": [ \"foo\" ],\n" - "\"Bool\": true,\n" // make sure booleans are accepted - "\"QuotedBool\": \"true\",\n" // make sure booleans are accepted - "\"Number\": 12345,\n" // number should also work - "\"QuotedNumber\": \"12345\",\n" // number should also work - "\"EmptyArray\": [],\n" - "\"NumberArray\": [1, 2, 3],\n" - "\"BoolArray\": [true, false, true],\n" - "\"StringArray\": [\"foo\", \"bar\"],\n" - "\"Null\": null,\n" // should return empty list - "\"QuotedNull\": \"null\",\n" // this is okay, it is a string - "\"ArrayWithNull\": [ \"foo\", null, \"bar\"],\n" // TODO: null is converted to empty string, is this okay? - "\"Object\": { \"foo\": \"bar\" }\n" // should return empty list - "}", &e).object(); + QJsonObject jo = QJsonDocument::fromJson( + "{\n" + "\"String\": \"foo\",\n" + "\"OneArrayEntry\": [ \"foo\" ],\n" + "\"Bool\": true,\n" // make sure booleans are accepted + "\"QuotedBool\": \"true\",\n" // make sure booleans are accepted + "\"Number\": 12345,\n" // number should also work + "\"QuotedNumber\": \"12345\",\n" // number should also work + "\"EmptyArray\": [],\n" + "\"NumberArray\": [1, 2, 3],\n" + "\"BoolArray\": [true, false, true],\n" + "\"StringArray\": [\"foo\", \"bar\"],\n" + "\"Null\": null,\n" // should return empty list + "\"QuotedNull\": \"null\",\n" // this is okay, it is a string + "\"ArrayWithNull\": [ \"foo\", null, \"bar\"],\n" // TODO: null is converted to empty string, is this okay? + "\"Object\": { \"foo\": \"bar\" }\n" // should return empty list + "}", + &e) + .object(); QCOMPARE(e.error, QJsonParseError::NoError); QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"String\" to be a string list. Treating it as a list with a single entry: \"foo\" "); - QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("String")), QStringList(QStringLiteral("foo")));; + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("String")), QStringList(QStringLiteral("foo"))); + ; QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("OneArrayEntry")), QStringList(QStringLiteral("foo"))); QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"Bool\" to be a string list. Treating it as a list with a single entry: \"true\" "); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Bool")), QStringList(QStringLiteral("true"))); @@ -239,16 +249,20 @@ QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("QuotedBool")), QStringList(QStringLiteral("true"))); QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"Number\" to be a string list. Treating it as a list with a single entry: \"12345\" "); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Number")), QStringList(QStringLiteral("12345"))); - QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedNumber\" to be a string list. Treating it as a list with a single entry: \"12345\" "); + QTest::ignoreMessage(QtWarningMsg, + "Expected JSON property \"QuotedNumber\" to be a string list. Treating it as a list with a single entry: \"12345\" "); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("QuotedNumber")), QStringList(QStringLiteral("12345"))); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("EmptyArray")), QStringList()); - QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("NumberArray")), QStringList() << QStringLiteral("1") << QStringLiteral("2") << QStringLiteral("3")); - QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("BoolArray")), QStringList() << QStringLiteral("true") << QStringLiteral("false") << QStringLiteral("true")); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("NumberArray")), + QStringList() << QStringLiteral("1") << QStringLiteral("2") << QStringLiteral("3")); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("BoolArray")), + QStringList() << QStringLiteral("true") << QStringLiteral("false") << QStringLiteral("true")); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("StringArray")), QStringList() << QStringLiteral("foo") << QStringLiteral("bar")); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Null")), QStringList()); QTest::ignoreMessage(QtWarningMsg, "Expected JSON property \"QuotedNull\" to be a string list. Treating it as a list with a single entry: \"null\" "); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("QuotedNull")), QStringList(QStringLiteral("null"))); - QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("ArrayWithNull")), QStringList() << QStringLiteral("foo") << QString() << QStringLiteral("bar")); + QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("ArrayWithNull")), + QStringList() << QStringLiteral("foo") << QString() << QStringLiteral("bar")); QCOMPARE(KPluginMetaData::readStringList(jo, QStringLiteral("Object")), QStringList()); } @@ -258,7 +272,7 @@ KPluginMetaData md(dfile); QVERIFY(md.isValid()); QCOMPARE(md.pluginId(), QStringLiteral("fakeplugin")); - QCOMPARE(md.fileName(), QStringLiteral("fakeplugin")); + QCOMPARE(md.fileName(), QStringLiteral("fakeplugin")); QCOMPARE(md.metaDataFileName(), dfile); QCOMPARE(md.iconName(), QStringLiteral("preferences-system-time")); QCOMPARE(md.license(), QStringLiteral("LGPL")); @@ -313,7 +327,8 @@ QVERIFY(!typesPath.isEmpty()); const QString inputPath = QFINDTESTDATA("data/servicetypes/example-input.desktop"); QVERIFY(!inputPath.isEmpty()); - QTest::ignoreMessage(QtWarningMsg, qPrintable(QStringLiteral("Unable to find service type for service \"bar/foo\" listed in \"") + inputPath + QLatin1Char('"'))); + QTest::ignoreMessage(QtWarningMsg, + qPrintable(QStringLiteral("Unable to find service type for service \"bar/foo\" listed in \"") + inputPath + QLatin1Char('"'))); KPluginMetaData md = KPluginMetaData::fromDesktopFile(inputPath, QStringList() << typesPath); QVERIFY(md.isValid()); QCOMPARE(md.name(), QStringLiteral("Example")); @@ -324,10 +339,11 @@ QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Bool")), QJsonValue(true)); QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Double")), QJsonValue(42.42)); QCOMPARE(md.rawData().value(QStringLiteral("X-Test-String")), QJsonValue(QStringLiteral("foobar"))); - QCOMPARE(md.rawData().value(QStringLiteral("X-Test-List")), QJsonValue(QJsonArray::fromStringList(QStringList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c") << QStringLiteral("def")))); + QCOMPARE(md.rawData().value(QStringLiteral("X-Test-List")), + QJsonValue( + QJsonArray::fromStringList(QStringList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c") << QStringLiteral("def")))); QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Size")), QJsonValue(QStringLiteral("10,20"))); // QSize no longer supported (and also no longer used) QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Unknown")), QJsonValue(QStringLiteral("true"))); // unknown property -> string - } void testBadGroupsInServiceType() @@ -343,13 +359,21 @@ QTest::ignoreMessage(QtWarningMsg, "Illegal .desktop group definition (does not end with ']'): \"[PropertyDef::\""); QTest::ignoreMessage(QtWarningMsg, "Illegal .desktop group definition (does not end with ']'): \"[\""); QTest::ignoreMessage(QtWarningMsg, "Read empty .desktop file group name! Invalid file?"); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral("Skipping invalid group \"\" in service type \".*/bad-groups-servicetype.desktop\""))); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral("Skipping invalid group \"DoesNotStartWithPropertyDef::SomeOtherProperty\" in service type \".+/data/servicetypes/bad-groups-servicetype.desktop\""))); + QTest::ignoreMessage(QtWarningMsg, + QRegularExpression(QStringLiteral("Skipping invalid group \"\" in service type \".*/bad-groups-servicetype.desktop\""))); + QTest::ignoreMessage(QtWarningMsg, + QRegularExpression(QStringLiteral("Skipping invalid group \"DoesNotStartWithPropertyDef::SomeOtherProperty\" in service type " + "\".+/data/servicetypes/bad-groups-servicetype.desktop\""))); QTest::ignoreMessage(QtWarningMsg, "Could not find Type= key in group \"PropertyDef::MissingType\""); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral("Property type \"integer\" is not a known QVariant type. Found while parsing property definition for \"InvalidType\" in \".+/data/servicetypes/bad-groups-servicetype.desktop\""))); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=11\""))); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=13\""))); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=14\""))); + QTest::ignoreMessage(QtWarningMsg, + QRegularExpression(QStringLiteral("Property type \"integer\" is not a known QVariant type. Found while parsing property " + "definition for \"InvalidType\" in \".+/data/servicetypes/bad-groups-servicetype.desktop\""))); + QTest::ignoreMessage(QtWarningMsg, + QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=11\""))); + QTest::ignoreMessage(QtWarningMsg, + QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=13\""))); + QTest::ignoreMessage(QtWarningMsg, + QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=14\""))); KPluginMetaData md = KPluginMetaData::fromDesktopFile(inputPath, QStringList() << typesPath); QVERIFY(md.isValid()); QCOMPARE(md.name(), QStringLiteral("Bad Groups")); @@ -359,7 +383,8 @@ QCOMPARE(md.rawData().value(QStringLiteral("MissingTerminator")), QJsonValue(12)); // accept missing group terminator (for now) -> integer // 13 is empty group name // 14 is empty group name - QCOMPARE(md.rawData().value(QStringLiteral("SomeOtherProperty")), QJsonValue(QStringLiteral("15"))); // does not start with PropertyDef:: -> fall back to string + QCOMPARE(md.rawData().value(QStringLiteral("SomeOtherProperty")), + QJsonValue(QStringLiteral("15"))); // does not start with PropertyDef:: -> fall back to string QCOMPARE(md.rawData().value(QStringLiteral("TrailingSpacesAreOkay")), QJsonValue(16)); // accept trailing spaces in group name -> integer QCOMPARE(md.rawData().value(QStringLiteral("MissingType")), QJsonValue(QStringLiteral("17"))); // Type= missing -> fall back to string QCOMPARE(md.rawData().value(QStringLiteral("InvalidType")), QJsonValue(QStringLiteral("18"))); // Type= is invalid -> fall back to string diff -Nru kcoreaddons-5.79.0/autotests/kprocesslisttest.cpp kcoreaddons-5.80.0/autotests/kprocesslisttest.cpp --- kcoreaddons-5.79.0/autotests/kprocesslisttest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kprocesslisttest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -12,8 +12,8 @@ #include #include -namespace { - +namespace +{ QString getTestExeName() { static QString testExeName = QCoreApplication::instance()->applicationFilePath().section(QLatin1Char('/'), -1); @@ -53,12 +53,11 @@ { KProcessList::KProcessInfoList processInfoList = KProcessList::processInfoList(); QVERIFY(processInfoList.empty() == false); - auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), [](const KProcessList::KProcessInfo& info) - { + auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), [](const KProcessList::KProcessInfo &info) { return info.command().endsWith(QLatin1String("/") + getTestExeName()); }); QVERIFY(testProcessIterator != processInfoList.end()); - const auto& processInfo = *testProcessIterator; + const auto &processInfo = *testProcessIterator; QVERIFY(processInfo.isValid() == true); QVERIFY(processInfo.command().endsWith(QLatin1String("/") + getTestExeName())); QCOMPARE(processInfo.name(), getTestExeName()); diff -Nru kcoreaddons-5.79.0/autotests/kprocesstest.cpp kcoreaddons-5.80.0/autotests/kprocesstest.cpp --- kcoreaddons-5.79.0/autotests/kprocesstest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kprocesstest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -7,15 +7,15 @@ */ #include "kprocesstest_helper.h" -#include -#include #include -#include +#include #include +#include +#include +#include #include #include -#include class KProcessTest : public QObject { @@ -46,9 +46,9 @@ #define EO EOUT "\n" #define EE EERR "\n" -#define TESTCHAN(me,ms,pout,rout,rerr) \ - e = QStringLiteral("mode: " ms "\n" POUT pout ROUT rout RERR rerr); \ - a = QStringLiteral("mode: " ms "\n") + callHelper(KProcess::me); \ +#define TESTCHAN(me, ms, pout, rout, rerr) \ + e = QStringLiteral("mode: " ms "\n" POUT pout ROUT rout RERR rerr); \ + a = QStringLiteral("mode: " ms "\n") + callHelper(KProcess::me); \ QCOMPARE(a, e) void KProcessTest::test_channels() @@ -79,8 +79,7 @@ QCOMPARE(p.program().at(0), QStandardPaths::findExecutable(QStringLiteral("cat"))); QVERIFY(p.program().at(0).endsWith(QLatin1String("/bin/cat"))); p.setShellCommand(QStringLiteral("true || false")); - QCOMPARE(p.program(), QStringList() << QStringLiteral("/bin/sh") << QStringLiteral("-c") - << QString::fromLatin1("true || false")); + QCOMPARE(p.program(), QStringList() << QStringLiteral("/bin/sh") << QStringLiteral("-c") << QString::fromLatin1("true || false")); #endif } diff -Nru kcoreaddons-5.79.0/autotests/kprocesstest_helper.cpp kcoreaddons-5.80.0/autotests/kprocesstest_helper.cpp --- kcoreaddons-5.79.0/autotests/kprocesstest_helper.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kprocesstest_helper.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -6,8 +6,8 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include #include "kprocesstest_helper.h" +#include #include #include diff -Nru kcoreaddons-5.79.0/autotests/krandomtest.cpp kcoreaddons-5.80.0/autotests/krandomtest.cpp --- kcoreaddons-5.79.0/autotests/krandomtest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/krandomtest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -14,14 +14,14 @@ #include #include -#include +#include #include -#include +#include #include -#include +#include -#include #include +#include typedef QVarLengthArray intSequenceType; @@ -30,7 +30,7 @@ #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 75) static bool seqsAreEqual(const intSequenceType &l, const intSequenceType &r) { - if(l.size() != r.size()) { + if (l.size() != r.size()) { return false; } const intSequenceType::const_iterator last(l.end()); @@ -38,8 +38,9 @@ intSequenceType::const_iterator l_first(l.begin()); intSequenceType::const_iterator r_first(r.begin()); - while(l_first != last && *l_first == *r_first) { - l_first++; r_first++; + while (l_first != last && *l_first == *r_first) { + l_first++; + r_first++; } return l_first == last; @@ -61,8 +62,10 @@ QTextStream childStream(subtestProcess.readAllStandardOutput()); std::generate(seq.begin(), seq.end(), [&]() { - int temp; childStream >> temp; return temp; - }); + int temp; + childStream >> temp; + return temp; + }); char c; childStream >> c; @@ -119,39 +122,63 @@ #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 75) void KRandomTest::test_KRS() { - using std::generate; using std::all_of; + using std::generate; const int maxInt = 50000; KRandomSequence krs1, krs2; intSequenceType out1(10), out2(10); - generate(out1.begin(), out1.end(), [&]() { return krs1.getInt(maxInt); }); - generate(out2.begin(), out2.end(), [&]() { return krs2.getInt(maxInt); }); + generate(out1.begin(), out1.end(), [&]() { + return krs1.getInt(maxInt); + }); + generate(out2.begin(), out2.end(), [&]() { + return krs2.getInt(maxInt); + }); QVERIFY(!seqsAreEqual(out1, out2)); - QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { return x < maxInt; })); - QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { return x < maxInt; })); + QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { + return x < maxInt; + })); + QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { + return x < maxInt; + })); // Compare same-seed krs1.setSeed(5000); krs2.setSeed(5000); - generate(out1.begin(), out1.end(), [&]() { return krs1.getInt(maxInt); }); - generate(out2.begin(), out2.end(), [&]() { return krs2.getInt(maxInt); }); + generate(out1.begin(), out1.end(), [&]() { + return krs1.getInt(maxInt); + }); + generate(out2.begin(), out2.end(), [&]() { + return krs2.getInt(maxInt); + }); QVERIFY(seqsAreEqual(out1, out2)); - QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { return x < maxInt; })); - QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { return x < maxInt; })); + QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { + return x < maxInt; + })); + QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { + return x < maxInt; + })); // Compare same-seed and assignment ctor krs1 = KRandomSequence(8000); krs2 = KRandomSequence(8000); - generate(out1.begin(), out1.end(), [&]() { return krs1.getInt(maxInt); }); - generate(out2.begin(), out2.end(), [&]() { return krs2.getInt(maxInt); }); + generate(out1.begin(), out1.end(), [&]() { + return krs1.getInt(maxInt); + }); + generate(out2.begin(), out2.end(), [&]() { + return krs2.getInt(maxInt); + }); QVERIFY(seqsAreEqual(out1, out2)); - QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { return x < maxInt; })); - QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { return x < maxInt; })); + QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) { + return x < maxInt; + })); + QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) { + return x < maxInt; + })); } #endif @@ -189,6 +216,7 @@ { result = KRandom::randomString(32); }; + public: QString result; }; @@ -196,19 +224,19 @@ void KRandomTest::test_randomStringThreaded() { static const int size = 5; - KRandomTestThread* threads[size]; - for (int i=0; i < size; ++i) { + KRandomTestThread *threads[size]; + for (int i = 0; i < size; ++i) { threads[i] = new KRandomTestThread(); threads[i]->start(); } QSet results; - for (int i=0; i < size; ++i) { + for (int i = 0; i < size; ++i) { threads[i]->wait(2000); results.insert(threads[i]->result); } // each thread should have returned a unique result QCOMPARE(results.size(), size); - for (int i=0; i < size; ++i) { + for (int i = 0; i < size; ++i) { delete threads[i]; } } diff -Nru kcoreaddons-5.79.0/autotests/kshareddatacachetest.cpp kcoreaddons-5.80.0/autotests/kshareddatacachetest.cpp --- kcoreaddons-5.79.0/autotests/kshareddatacachetest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kshareddatacachetest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -7,12 +7,12 @@ #include -#include #include +#include #include -#include #include +#include #include // strcpy class KSharedDataCacheTest : public QObject diff -Nru kcoreaddons-5.79.0/autotests/kshelltest.cpp kcoreaddons-5.80.0/autotests/kshelltest.cpp --- kcoreaddons-5.79.0/autotests/kshelltest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kshelltest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -12,10 +12,10 @@ #include +#include #include #include #include -#include class KShellTest : public QObject { @@ -42,8 +42,7 @@ #endif } -void -KShellTest::tildeExpand() +void KShellTest::tildeExpand() { QString me(KUser().loginName()); QCOMPARE(KShell::tildeExpand(QStringLiteral("~")), QDir::homePath()); @@ -57,16 +56,14 @@ #endif } -void -KShellTest::tildeCollapse() +void KShellTest::tildeCollapse() { QCOMPARE(KShell::tildeCollapse(QDir::homePath()), QStringLiteral("~")); QCOMPARE(KShell::tildeCollapse(QDir::homePath() + QStringLiteral("/Documents")), QStringLiteral("~/Documents")); QCOMPARE(KShell::tildeCollapse(QStringLiteral("/test/") + QDir::homePath()), QStringLiteral("/test/") + QDir::homePath()); } -void -KShellTest::quoteArg() +void KShellTest::quoteArg() { #ifdef Q_OS_WIN QCOMPARE(KShell::quoteArg(QStringLiteral("a space")), QStringLiteral("\"a space\"")); @@ -84,8 +81,7 @@ #endif } -void -KShellTest::joinArgs() +void KShellTest::joinArgs() { QStringList list; list << QStringLiteral("this") << QStringLiteral("is") << QStringLiteral("a") << QStringLiteral("test"); @@ -97,82 +93,64 @@ return KShell::joinArgs(KShell::splitArgs(str, flags, ret)); } -void -KShellTest::splitJoin() +void KShellTest::splitJoin() { KShell::Errors err = KShell::NoError; #ifdef Q_OS_WIN - QCOMPARE(sj(QStringLiteral("\"(sulli)\" text"), KShell::NoOptions, &err), - QStringLiteral("\"(sulli)\" text")); + QCOMPARE(sj(QStringLiteral("\"(sulli)\" text"), KShell::NoOptions, &err), QStringLiteral("\"(sulli)\" text")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral(" ha\\ lo "), KShell::NoOptions, &err), - QStringLiteral("\"ha\\\\\" lo")); + QCOMPARE(sj(QStringLiteral(" ha\\ lo "), KShell::NoOptions, &err), QStringLiteral("\"ha\\\\\" lo")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("say \" error"), KShell::NoOptions, &err), - QString()); + QCOMPARE(sj(QStringLiteral("say \" error"), KShell::NoOptions, &err), QString()); QVERIFY(err == KShell::BadQuoting); - QCOMPARE(sj(QStringLiteral("no \" error\""), KShell::NoOptions, &err), - QStringLiteral("no \" error\"")); + QCOMPARE(sj(QStringLiteral("no \" error\""), KShell::NoOptions, &err), QStringLiteral("no \" error\"")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("say \" still error"), KShell::NoOptions, &err), - QString()); + QCOMPARE(sj(QStringLiteral("say \" still error"), KShell::NoOptions, &err), QString()); QVERIFY(err == KShell::BadQuoting); - QCOMPARE(sj(QStringLiteral("BLA;asdf sdfess d"), KShell::NoOptions, &err), - QStringLiteral("\"BLA;asdf\" sdfess d")); + QCOMPARE(sj(QStringLiteral("BLA;asdf sdfess d"), KShell::NoOptions, &err), QStringLiteral("\"BLA;asdf\" sdfess d")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("B\"L\"A&sdf FOO|bar sdf wer "), KShell::NoOptions, &err), - QStringLiteral("\"BLA&sdf\" \"FOO|bar\" sdf wer")); + QCOMPARE(sj(QStringLiteral("B\"L\"A&sdf FOO|bar sdf wer "), KShell::NoOptions, &err), QStringLiteral("\"BLA&sdf\" \"FOO|bar\" sdf wer")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("\"\"\"just \"\" fine\"\"\""), KShell::NoOptions, &err), - QStringLiteral("\\^\"\"just \"\\^\"\" fine\"\\^\"")); + QCOMPARE(sj(QStringLiteral("\"\"\"just \"\" fine\"\"\""), KShell::NoOptions, &err), QStringLiteral("\\^\"\"just \"\\^\"\" fine\"\\^\"")); QVERIFY(err == KShell::NoError); #else QCOMPARE(sj(QString::fromUtf8("\"~qU4rK\" 'text' 'jo'\"jo\" $'crap' $'\\\\\\'\\e\\x21' ha\\ lo \\a"), KShell::NoOptions, &err), QString::fromUtf8("'~qU4rK' text jojo crap '\\'\\''\x1b!' 'ha lo' a")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("\"~qU4rK\" 'text'"), KShell::TildeExpand, &err), - QStringLiteral("'~qU4rK' text")); + QCOMPARE(sj(QStringLiteral("\"~qU4rK\" 'text'"), KShell::TildeExpand, &err), QStringLiteral("'~qU4rK' text")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("~\"qU4rK\" 'text'"), KShell::TildeExpand, &err), - QStringLiteral("'~qU4rK' text")); + QCOMPARE(sj(QStringLiteral("~\"qU4rK\" 'text'"), KShell::TildeExpand, &err), QStringLiteral("'~qU4rK' text")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("~/\"dir\" 'text'"), KShell::TildeExpand, &err), - QString(QDir::homePath() + QStringLiteral("/dir text"))); + QCOMPARE(sj(QStringLiteral("~/\"dir\" 'text'"), KShell::TildeExpand, &err), QString(QDir::homePath() + QStringLiteral("/dir text"))); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("~ 'text' ~"), KShell::TildeExpand, &err), - QString(QDir::homePath() + QStringLiteral(" text ") + QDir::homePath())); + QCOMPARE(sj(QStringLiteral("~ 'text' ~"), KShell::TildeExpand, &err), QString(QDir::homePath() + QStringLiteral(" text ") + QDir::homePath())); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("\\~ blah"), KShell::TildeExpand, &err), - QStringLiteral("'~' blah")); + QCOMPARE(sj(QStringLiteral("\\~ blah"), KShell::TildeExpand, &err), QStringLiteral("'~' blah")); QVERIFY(err == KShell::NoError); - QCOMPARE(sj(QStringLiteral("~qU4rK ~") + KUser().loginName(), KShell::TildeExpand, &err), - QString(QStringLiteral("'~qU4rK' ") + myHomePath())); + QCOMPARE(sj(QStringLiteral("~qU4rK ~") + KUser().loginName(), KShell::TildeExpand, &err), QString(QStringLiteral("'~qU4rK' ") + myHomePath())); QVERIFY(err == KShell::NoError); const QString unicodeSpaceFileName = QStringLiteral("test テスト.txt"); // #345140 - QCOMPARE(sj(unicodeSpaceFileName, KShell::AbortOnMeta | KShell::TildeExpand, &err), - unicodeSpaceFileName); + QCOMPARE(sj(unicodeSpaceFileName, KShell::AbortOnMeta | KShell::TildeExpand, &err), unicodeSpaceFileName); QVERIFY(err == KShell::NoError); #endif } - -void -KShellTest::quoteSplit_data() +void KShellTest::quoteSplit_data() { QTest::addColumn("string"); @@ -181,8 +159,7 @@ QTest::newRow("special space") << QString::fromUtf8("如何定期清潔典型的電風扇 講義.pdf"); } -void -KShellTest::quoteSplit() +void KShellTest::quoteSplit() { QFETCH(QString, string); @@ -191,13 +168,11 @@ QCOMPARE(args.count(), 1); } -void -KShellTest::abortOnMeta() +void KShellTest::abortOnMeta() { KShell::Errors err1 = KShell::NoError, err2 = KShell::NoError; - QCOMPARE(sj(QStringLiteral("text"), KShell::AbortOnMeta, &err1), - QStringLiteral("text")); + QCOMPARE(sj(QStringLiteral("text"), KShell::AbortOnMeta, &err1), QStringLiteral("text")); QVERIFY(err1 == KShell::NoError); #ifdef Q_OS_WIN @@ -206,44 +181,35 @@ QVERIFY(KShell::splitArgs(QStringLiteral("foo %PATH% bar"), KShell::AbortOnMeta, &err1).isEmpty()); QVERIFY(err1 == KShell::FoundMeta); - QCOMPARE(sj(QStringLiteral("foo %PERCENT_SIGN% bar"), KShell::AbortOnMeta, &err1), - QStringLiteral("foo %PERCENT_SIGN% bar")); + QCOMPARE(sj(QStringLiteral("foo %PERCENT_SIGN% bar"), KShell::AbortOnMeta, &err1), QStringLiteral("foo %PERCENT_SIGN% bar")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj(QStringLiteral("@foo ^& bar"), KShell::AbortOnMeta, &err1), - QStringLiteral("foo \"&\" bar")); + QCOMPARE(sj(QStringLiteral("@foo ^& bar"), KShell::AbortOnMeta, &err1), QStringLiteral("foo \"&\" bar")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj(QStringLiteral("\"BLA|asdf\" sdfess d"), KShell::AbortOnMeta, &err1), - QStringLiteral("\"BLA|asdf\" sdfess d")); + QCOMPARE(sj(QStringLiteral("\"BLA|asdf\" sdfess d"), KShell::AbortOnMeta, &err1), QStringLiteral("\"BLA|asdf\" sdfess d")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj(QStringLiteral("B\"L\"A\"|\"sdf \"FOO | bar\" sdf wer"), KShell::AbortOnMeta, &err1), - QStringLiteral("\"BLA|sdf\" \"FOO | bar\" sdf wer")); + QCOMPARE(sj(QStringLiteral("B\"L\"A\"|\"sdf \"FOO | bar\" sdf wer"), KShell::AbortOnMeta, &err1), QStringLiteral("\"BLA|sdf\" \"FOO | bar\" sdf wer")); QVERIFY(err1 == KShell::NoError); - QCOMPARE(sj(QStringLiteral("b-q me \\\\^|\\\\\\^\""), KShell::AbortOnMeta, &err1), - QStringLiteral("b-q me \"\\\\|\"\\\\\\^\"")); + QCOMPARE(sj(QStringLiteral("b-q me \\\\^|\\\\\\^\""), KShell::AbortOnMeta, &err1), QStringLiteral("b-q me \"\\\\|\"\\\\\\^\"")); QVERIFY(err1 == KShell::NoError); #else - QCOMPARE(sj(QStringLiteral("say \" error"), KShell::NoOptions, &err1), - QString()); + QCOMPARE(sj(QStringLiteral("say \" error"), KShell::NoOptions, &err1), QString()); QVERIFY(err1 != KShell::NoError); - QCOMPARE(sj(QStringLiteral("say \" still error"), KShell::AbortOnMeta, &err1), - QString()); + QCOMPARE(sj(QStringLiteral("say \" still error"), KShell::AbortOnMeta, &err1), QString()); QVERIFY(err1 != KShell::NoError); - QVERIFY(sj(QStringLiteral("say `echo no error`"), KShell::NoOptions, &err1) != - sj(QStringLiteral("say `echo no error`"), KShell::AbortOnMeta, &err2)); + QVERIFY(sj(QStringLiteral("say `echo no error`"), KShell::NoOptions, &err1) != sj(QStringLiteral("say `echo no error`"), KShell::AbortOnMeta, &err2)); QVERIFY(err1 != err2); - QVERIFY(sj(QStringLiteral("BLA=say echo meta"), KShell::NoOptions, &err1) != - sj(QStringLiteral("BLA=say echo meta"), KShell::AbortOnMeta, &err2)); + QVERIFY(sj(QStringLiteral("BLA=say echo meta"), KShell::NoOptions, &err1) != sj(QStringLiteral("BLA=say echo meta"), KShell::AbortOnMeta, &err2)); QVERIFY(err1 != err2); - QVERIFY(sj(QStringLiteral("B\"L\"A=say FOO=bar echo meta"), KShell::NoOptions, &err1) == - sj(QStringLiteral("B\"L\"A=say FOO=bar echo meta"), KShell::AbortOnMeta, &err2)); + QVERIFY(sj(QStringLiteral("B\"L\"A=say FOO=bar echo meta"), KShell::NoOptions, &err1) + == sj(QStringLiteral("B\"L\"A=say FOO=bar echo meta"), KShell::AbortOnMeta, &err2)); #endif } diff -Nru kcoreaddons-5.79.0/autotests/kstringhandlertest.cpp kcoreaddons-5.80.0/autotests/kstringhandlertest.cpp --- kcoreaddons-5.79.0/autotests/kstringhandlertest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/kstringhandlertest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -12,8 +12,7 @@ void KStringHandlerTest::capwords() { - QCOMPARE(KStringHandler::capwords(test), - QStringLiteral("The Quick Brown Fox Jumped Over The Lazy Bridge. ")); + QCOMPARE(KStringHandler::capwords(test), QStringLiteral("The Quick Brown Fox Jumped Over The Lazy Bridge. ")); } void KStringHandlerTest::tagURLs() @@ -23,8 +22,7 @@ QStringLiteral("Click on https://foo@bar:www.kde.org/yoyo/dyne.html#a1 for info.")); test = QStringLiteral("http://www.foo.org/story$806"); - QCOMPARE(KStringHandler::tagUrls(test), - QStringLiteral("http://www.foo.org/story$806")); + QCOMPARE(KStringHandler::tagUrls(test), QStringLiteral("http://www.foo.org/story$806")); #if 0 // XFAIL - i.e. this needs to be fixed, but has never been @@ -34,34 +32,28 @@ #endif test = QStringLiteral("http://www.foo.org/bla-(bli)"); - QCOMPARE(KStringHandler::tagUrls(test), - QStringLiteral("http://www.foo.org/bla-(bli)")); + QCOMPARE(KStringHandler::tagUrls(test), QStringLiteral("http://www.foo.org/bla-(bli)")); test = QStringLiteral("http://www.foo.org/bla-bli"); - QCOMPARE(KStringHandler::tagUrls(test), - QStringLiteral("http://www.foo.org/bla-bli")); + QCOMPARE(KStringHandler::tagUrls(test), QStringLiteral("http://www.foo.org/bla-bli")); } void KStringHandlerTest::perlSplit() { QStringList expected; - expected << QStringLiteral("some") << QStringLiteral("string") << QStringLiteral("for") - << QStringLiteral("you__here"); + expected << QStringLiteral("some") << QStringLiteral("string") << QStringLiteral("for") << QStringLiteral("you__here"); QCOMPARE(KStringHandler::perlSplit(QStringLiteral("__"), QStringLiteral("some__string__for__you__here"), 4), expected); expected.clear(); expected << QStringLiteral("kparts") << QStringLiteral("reaches") << QStringLiteral("the parts other parts can't"); - QCOMPARE(KStringHandler::perlSplit(QLatin1Char(' '), - QStringLiteral("kparts reaches the parts other parts can't"), 3), expected); + QCOMPARE(KStringHandler::perlSplit(QLatin1Char(' '), QStringLiteral("kparts reaches the parts other parts can't"), 3), expected); expected.clear(); expected << QStringLiteral("Split") << QStringLiteral("me") << QStringLiteral("up ! I'm bored ! OK ?"); #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 67) - QCOMPARE(KStringHandler::perlSplit(QRegExp(QStringLiteral("[! ]")), - QStringLiteral("Split me up ! I'm bored ! OK ?"), 3), expected); + QCOMPARE(KStringHandler::perlSplit(QRegExp(QStringLiteral("[! ]")), QStringLiteral("Split me up ! I'm bored ! OK ?"), 3), expected); #endif - QCOMPARE(KStringHandler::perlSplit(QRegularExpression(QStringLiteral("[! ]")), - QStringLiteral("Split me up ! I'm bored ! OK ?"), 3), expected); + QCOMPARE(KStringHandler::perlSplit(QRegularExpression(QStringLiteral("[! ]")), QStringLiteral("Split me up ! I'm bored ! OK ?"), 3), expected); } void KStringHandlerTest::obscure() @@ -82,71 +74,58 @@ QTest::addColumn("expected"); // Should result in no additional breaks - QTest::newRow("spaces") << "foo bar baz" << "foo bar baz"; + QTest::newRow("spaces") << "foo bar baz" + << "foo bar baz"; // Should insert a ZWSP after each '_' - QTest::newRow("underscores") << "foo_bar_baz" - << QString(QStringLiteral("foo_") + zwsp + QStringLiteral("bar_") + zwsp + QStringLiteral("baz")); + QTest::newRow("underscores") << "foo_bar_baz" << QString(QStringLiteral("foo_") + zwsp + QStringLiteral("bar_") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP after each '-' - QTest::newRow("hyphens") << "foo-bar-baz" - << QString(QStringLiteral("foo-") + zwsp + - QStringLiteral("bar-") + zwsp + QStringLiteral("baz")); + QTest::newRow("hyphens") << "foo-bar-baz" << QString(QStringLiteral("foo-") + zwsp + QStringLiteral("bar-") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP after each '.' - QTest::newRow("periods") << "foo.bar.baz" - << QString(QStringLiteral("foo.") + - zwsp + QStringLiteral("bar.") + zwsp + QStringLiteral("baz")); + QTest::newRow("periods") << "foo.bar.baz" << QString(QStringLiteral("foo.") + zwsp + QStringLiteral("bar.") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP after each ',' - QTest::newRow("commas") << "foo,bar,baz" - << QString(QStringLiteral("foo,") + zwsp + - QStringLiteral("bar,") + zwsp + QStringLiteral("baz")); + QTest::newRow("commas") << "foo,bar,baz" << QString(QStringLiteral("foo,") + zwsp + QStringLiteral("bar,") + zwsp + QStringLiteral("baz")); // Should result in no additional breaks since the '_'s are followed by spaces - QTest::newRow("mixed underscores and spaces") - << "foo_ bar_ baz" << "foo_ bar_ baz"; + QTest::newRow("mixed underscores and spaces") << "foo_ bar_ baz" + << "foo_ bar_ baz"; // Should result in no additional breaks since the '_' is the last char - QTest::newRow("ends with underscore") << "foo_" << "foo_"; + QTest::newRow("ends with underscore") << "foo_" + << "foo_"; // Should insert a ZWSP before '(' and after ')' - QTest::newRow("parens") << "foo(bar)baz" - << QString(QStringLiteral("foo") + zwsp + - QStringLiteral("(bar)") + zwsp + QStringLiteral("baz")); + QTest::newRow("parens") << "foo(bar)baz" << QString(QStringLiteral("foo") + zwsp + QStringLiteral("(bar)") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP before '[' and after ']' - QTest::newRow("brackets") << "foo[bar]baz" - << QString(QStringLiteral("foo") + zwsp + - QStringLiteral("[bar]") + zwsp + QStringLiteral("baz")); + QTest::newRow("brackets") << "foo[bar]baz" << QString(QStringLiteral("foo") + zwsp + QStringLiteral("[bar]") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP before '{' and after '}' - QTest::newRow("curly braces") << "foo{bar}baz" - << QString(QStringLiteral("foo") + zwsp + - QStringLiteral("{bar}") + zwsp + QStringLiteral("baz")); + QTest::newRow("curly braces") << "foo{bar}baz" << QString(QStringLiteral("foo") + zwsp + QStringLiteral("{bar}") + zwsp + QStringLiteral("baz")); // Should insert a ZWSP before '(' but not after ')' since it's the last char - QTest::newRow("ends with ')'") << "foo(bar)" - << QString(QStringLiteral("foo") + zwsp + QStringLiteral("(bar)")); + QTest::newRow("ends with ')'") << "foo(bar)" << QString(QStringLiteral("foo") + zwsp + QStringLiteral("(bar)")); // Should insert a single ZWSP between the '_' and the '(' - QTest::newRow("'_' followed by '('") << "foo_(bar)" - << QString(QStringLiteral("foo_") + zwsp + QStringLiteral("(bar)")); + QTest::newRow("'_' followed by '('") << "foo_(bar)" << QString(QStringLiteral("foo_") + zwsp + QStringLiteral("(bar)")); // Should insert ZWSP's between the '_' and the '[', between the double // '['s and the double ']'s, but not before and after 'bar' QTest::newRow("'_' before double brackets") << "foo_[[bar]]" - << QString(QStringLiteral("foo_") + zwsp + - QStringLiteral("[") + zwsp + QStringLiteral("[bar]") + zwsp + - QStringLiteral("]")); + << QString(QStringLiteral("foo_") + zwsp + QStringLiteral("[") + zwsp + QStringLiteral("[bar]") + zwsp + + QStringLiteral("]")); // Should only insert ZWSP's between the double '['s and the double ']'s QTest::newRow("space before double brackets") << "foo [[bar]]" - << QString(QStringLiteral("foo [") + zwsp + QStringLiteral("[bar]") + zwsp + QStringLiteral("]")); + << QString(QStringLiteral("foo [") + zwsp + QStringLiteral("[bar]") + zwsp + QStringLiteral("]")); // Shouldn't result in any additional breaks since the '(' is preceded // by a space, and the ')' is followed by a space. - QTest::newRow("parens with spaces") << "foo (bar) baz" << "foo (bar) baz"; + QTest::newRow("parens with spaces") << "foo (bar) baz" + << "foo (bar) baz"; // Should insert a WJ (Word Joiner) before a single quote const QChar wj(0x2060); @@ -173,8 +152,7 @@ QFETCH(QString, string); QFETCH(QString, expected); - QCOMPARE(replaceZwsp(KStringHandler::preProcessWrap(string)), - replaceZwsp(expected)); + QCOMPARE(replaceZwsp(KStringHandler::preProcessWrap(string)), replaceZwsp(expected)); } void KStringHandlerTest::logicalLength_data() @@ -195,4 +173,3 @@ QFETCH(int, expected); QCOMPARE(KStringHandler::logicalLength(string), expected); } - diff -Nru kcoreaddons-5.79.0/autotests/ktexttohtmltest.cpp kcoreaddons-5.80.0/autotests/ktexttohtmltest.cpp --- kcoreaddons-5.79.0/autotests/ktexttohtmltest.cpp 2021-02-06 18:12:40.000000000 +0000 +++ kcoreaddons-5.80.0/autotests/ktexttohtmltest.cpp 2021-03-06 16:20:44.000000000 +0000 @@ -11,8 +11,8 @@ #include "../src/lib/text/ktexttohtml.h" #include "../src/lib/text/ktexttohtml_p.h" -#include #include +#include #include QTEST_MAIN(KTextToHTMLTest) @@ -27,7 +27,6 @@ Q_CONSTRUCTOR_FUNCTION(initLocale) #endif - void KTextToHTMLTest::testGetEmailAddress() { // empty input @@ -50,13 +49,11 @@ QVERIFY(ll5.getEmailAddress().isEmpty()); KTextToHTMLHelper ll6(QStringLiteral(" @bar.baz"), 1); QVERIFY(ll6.getEmailAddress().isEmpty()); - KTextToHTMLHelper ll7(QStringLiteral(".!#$%&'*+-/=?^_`{|}~@bar.baz"), - qstrlen(".!#$%&'*+-/=?^_`{|}~")); + KTextToHTMLHelper ll7(QStringLiteral(".!#$%&'*+-/=?^_`{|}~@bar.baz"), qstrlen(".!#$%&'*+-/=?^_`{|}~")); QVERIFY(ll7.getEmailAddress().isEmpty()); // allowed special chars in local part of address - KTextToHTMLHelper ll8(QStringLiteral("a.!#$%&'*+-/=?^_`{|}~@bar.baz"), - qstrlen("a.!#$%&'*+-/=?^_`{|}~")); + KTextToHTMLHelper ll8(QStringLiteral("a.!#$%&'*+-/=?^_`{|}~@bar.baz"), qstrlen("a.!#$%&'*+-/=?^_`{|}~")); QCOMPARE(ll8.getEmailAddress(), QStringLiteral("a.!#$%&'*+-/=?^_`{|}~@bar.baz")); // '@' in domain part @@ -107,14 +104,14 @@ void KTextToHTMLTest::testGetUrl() { QStringList brackets; - brackets << QString() << QString(); // no brackets + brackets << QString() << QString(); // no brackets brackets << QStringLiteral("<") << QStringLiteral(">"); brackets << QStringLiteral("[") << QStringLiteral("]"); brackets << QStringLiteral("\"") << QStringLiteral("\""); brackets << QStringLiteral("") << QStringLiteral(""); for (int i = 0; i < brackets.count(); i += 2) { - testGetUrl2(brackets[ i ], brackets[ i + 1 ]); + testGetUrl2(brackets[i], brackets[i + 1]); } } @@ -145,20 +142,18 @@ urls << QStringLiteral("user:pass@www.kde.org:1234/sub/path:with:colon/special(123)?a=1#anchor[bla"); urls << QStringLiteral("user:pass@www.kde.org:1234/sub/path:with:colon/special(123)?a=1#anchor[bla]"); urls << QStringLiteral("user:pass@www.kde.org:1234/\nsub/path:with:colon/\nspecial(123)?\na=1#anchor[bla]"); - urls << QStringLiteral("user:pass@www.kde.org:1234/ \n sub/path:with:colon/ \n\t \t special(123)?") + - QStringLiteral("\n\t \n\t a=1#anchor[bla]"); + urls << QStringLiteral("user:pass@www.kde.org:1234/ \n sub/path:with:colon/ \n\t \t special(123)?") + QStringLiteral("\n\t \n\t a=1#anchor[bla]"); for (const QString &schema : qAsConst(schemas)) { for (QString url : qAsConst(urls)) { // by definition: if the URL is enclosed in brackets, the URL itself is not allowed // to contain the closing bracket, as this would be detected as the end of the URL - if ((left.length() == 1) && (url.contains(right[ 0 ]))) { + if ((left.length() == 1) && (url.contains(right[0]))) { continue; } // if the url contains a whitespace, it must be enclosed with brackets - if ((url.contains(QLatin1Char('\n')) || url.contains(QLatin1Char('\t')) || url.contains(QLatin1Char(' '))) && - left.isEmpty()) { + if ((url.contains(QLatin1Char('\n')) || url.contains(QLatin1Char('\t')) || url.contains(QLatin1Char(' '))) && left.isEmpty()) { continue; } @@ -189,8 +184,7 @@ urlsWithoutSchema << QStringLiteral(".kde.org:1234/sub/path:with:colon/special(123)?a=1#anchor[bla"); urlsWithoutSchema << QStringLiteral(".kde.org:1234/sub/path:with:colon/special(123)?a=1#anchor[bla]"); urlsWithoutSchema << QStringLiteral(".kde.org:1234/\nsub/path:with:colon/\nspecial(123)?\na=1#anchor[bla]"); - urlsWithoutSchema << QStringLiteral(".kde.org:1234/ \n sub/path:with:colon/ \n\t \t special(123)?") + - QStringLiteral("\n\t \n\t a=1#anchor[bla]"); + urlsWithoutSchema << QStringLiteral(".kde.org:1234/ \n sub/path:with:colon/ \n\t \t special(123)?") + QStringLiteral("\n\t \n\t a=1#anchor[bla]"); QStringList starts; starts << QStringLiteral("www") << QStringLiteral("ftp") << QStringLiteral("news:www"); @@ -199,13 +193,12 @@ for (QString url : qAsConst(urlsWithoutSchema)) { // by definition: if the URL is enclosed in brackets, the URL itself is not allowed // to contain the closing bracket, as this would be detected as the end of the URL - if ((left.length() == 1) && (url.contains(right[ 0 ]))) { + if ((left.length() == 1) && (url.contains(right[0]))) { continue; } // if the url contains a whitespace, it must be enclosed with brackets - if ((url.contains(QLatin1Char('\n')) || url.contains(QLatin1Char('\t')) || url.contains(QLatin1Char(' '))) && - left.isEmpty()) { + if ((url.contains(QLatin1Char('\n')) || url.contains(QLatin1Char('\t')) || url.contains(QLatin1Char(' '))) && left.isEmpty()) { continue; } @@ -230,11 +223,11 @@ QString url = QStringLiteral("https://www.kde.org/this/is/a_very_loooooong_url/test/test/test"); { KTextToHTMLHelper ll(url, 0, 10); - QVERIFY(ll.getUrl().isEmpty()); // url too long + QVERIFY(ll.getUrl().isEmpty()); // url too long } { KTextToHTMLHelper ll(url, 0, url.length() - 1); - QVERIFY(ll.getUrl().isEmpty()); // url too long + QVERIFY(ll.getUrl().isEmpty()); // url too long } { KTextToHTMLHelper ll(url, 0, url.length()); @@ -270,29 +263,15 @@ // Linker error when using PreserveSpaces, therefore the hardcoded 0x01 or 0x09 // Test preserving whitespace correctly - QTest::newRow("") << " foo" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << " foo"; - QTest::newRow("") << " foo" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "  foo"; - QTest::newRow("") << " foo " - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "  foo  "; - QTest::newRow("") << " foo " - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "  foo "; - QTest::newRow("") << "bla bla bla bla bla" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "bla bla bla bla bla"; - QTest::newRow("") << "bla bla bla \n bla bla bla " - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("") << " foo" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << " foo"; + QTest::newRow("") << " foo" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "  foo"; + QTest::newRow("") << " foo " << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "  foo  "; + QTest::newRow("") << " foo " << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "  foo "; + QTest::newRow("") << "bla bla bla bla bla" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "bla bla bla bla bla"; + QTest::newRow("") << "bla bla bla \n bla bla bla " << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "bla bla bla 
\n  bla bla bla "; - QTest::newRow("") << "bla bla bla" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "bla bla  bla"; - QTest::newRow("") << " bla bla \n bla bla a\n bla bla " - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("") << "bla bla bla" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "bla bla  bla"; + QTest::newRow("") << " bla bla \n bla bla a\n bla bla " << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << " bla bla 
\n bla bla a
\n" "  bla bla "; @@ -312,247 +291,189 @@ << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) << "Un répertoire /est/ un" " *dossier* où on peut mettre des *fichiers*."; - QTest::newRow("punctation-bug") << "*BLA BLA BLA BLA*." - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + QTest::newRow("punctation-bug") << "*BLA BLA BLA BLA*." << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) << "BLA BLA BLA BLA."; - QTest::newRow("") << "Je vais tenter de repérer des faux positif*" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + QTest::newRow("") << "Je vais tenter de repérer des faux positif*" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) << "Je vais tenter de repérer des faux positif*"; - QTest::newRow("") << "*Ouais !* *Yes!*" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + QTest::newRow("") << "*Ouais !* *Yes!*" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) << "*Ouais !* *Yes!*"; - QTest::newRow("multispace") << "*Ouais foo*" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "*Ouais foo*"; + QTest::newRow("multispace") << "*Ouais foo*" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "*Ouais foo*"; - QTest::newRow("multispace3") << "*Ouais: foo*" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "*Ouais: foo*"; + QTest::newRow("multispace3") << "*Ouais: foo*" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "*Ouais: foo*"; - QTest::newRow("multi-") << "** Ouais: foo **" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "** Ouais:  foo **"; + QTest::newRow("multi-") << "** Ouais: foo **" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "** Ouais:  foo **"; - QTest::newRow("multi-") << "*** Ouais: foo ***" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "*** Ouais:  foo ***"; + QTest::newRow("multi-") << "*** Ouais: foo ***" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "*** Ouais:  foo ***"; - QTest::newRow("nohtmlversion") << "* Ouais: foo *" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "* Ouais:     foo *"; + QTest::newRow("nohtmlversion") << "* Ouais: foo *" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "* Ouais:     foo *"; - QTest::newRow("nohtmlversion2") << "*Ouais: foo *" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "*Ouais:     foo *"; + QTest::newRow("nohtmlversion2") << "*Ouais: foo *" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "*Ouais:     foo *"; - QTest::newRow("nohtmlversion3") << "* Ouais: foo*" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "* Ouais:     foo*"; + QTest::newRow("nohtmlversion3") << "* Ouais: foo*" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "* Ouais:     foo*"; - QTest::newRow("nohtmlversion3") << "* Ouais: *ff sfsdf* foo *" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) - << "* Ouais: *ff sfsdf* foo *"; + QTest::newRow("nohtmlversion3") << "* Ouais: *ff sfsdf* foo *" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) + << "* Ouais: *ff sfsdf* foo *"; QTest::newRow("") << "the /etc/{rsyslog.d,syslog-ng.d}/package.rpmnew file" << KTextToHTML::Options(KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText) << "the /etc/{rsyslog.d,syslog-ng.d}/package.rpmnew file"; // This test has problems with the encoding, apparently. - //QTest::newRow( "" ) << "*Ça fait plaisir de pouvoir utiliser des lettres accentuées dans du" + // QTest::newRow( "" ) << "*Ça fait plaisir de pouvoir utiliser des lettres accentuées dans du" // " texte mis en forme*." << 0x09 << "Ça fait plaisir de pouvoir" // " utiliser des lettres accentuées dans du texte mis en forme."; // Bug reported by dfaure, the would get lost - QTest::newRow("") << "QUrl url(\"http://strange/\");" - << KTextToHTML::Options(KTextToHTML::ReplaceSmileys | KTextToHTML::HighlightText) + QTest::newRow("") << "QUrl url(\"http://strange/\");" << KTextToHTML::Options(KTextToHTML::ReplaceSmileys | KTextToHTML::HighlightText) << "QUrl url("/\">" "http://strange<hostname>/");"; // Bug: 211128 - plain text emails should not replace ampersand & with & - QTest::newRow("bug211128") << "https://green-site/?Ticket=85&Page=next" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("bug211128") << "https://green-site/?Ticket=85&Page=next" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "" "https://green-site/?Ticket=85&Page=next"; - QTest::newRow("dotBeforeEnd") << "Look at this file: www.example.com/example.h" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("dotBeforeEnd") << "Look at this file: www.example.com/example.h" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "Look at this file: " "www.example.com/example.h"; - QTest::newRow("dotInMiddle") << "Look at this file: www.example.com/.bashrc" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("dotInMiddle") << "Look at this file: www.example.com/.bashrc" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "Look at this file: " "www.example.com/.bashrc"; // A dot at the end of an URL is explicitly ignored - QTest::newRow("dotAtEnd") << "Look at this file: www.example.com/test.cpp." - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("dotAtEnd") << "Look at this file: www.example.com/test.cpp." << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "Look at this file: " "www.example.com/test.cpp."; // Bug 313719 - URL in parenthesis - QTest::newRow("url-in-parenthesis-1") << "KDE (website https://www.kde.org)" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("url-in-parenthesis-1") << "KDE (website https://www.kde.org)" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "KDE (website https://www.kde.org)"; - QTest::newRow("url-in-parenthesis-2") << "KDE website (https://www.kde.org)" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("url-in-parenthesis-2") << "KDE website (https://www.kde.org)" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "KDE website (https://www.kde.org)"; - QTest::newRow("url-in-parenthesis-3") << "bla (https://www.kde.org - section 5.2)" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + QTest::newRow("url-in-parenthesis-3") << "bla (https://www.kde.org - section 5.2)" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "bla (https://www.kde.org - section 5.2)"; // Fix url as foo < > when we concatened them. - QTest::newRow("url-with-url") << "foo >" - << KTextToHTML::Options(KTextToHTML::PreserveSpaces) - << "foo <https://www.kde.org/ <https://www.kde.org/>>"; - - //Fix url exploit - QTest::newRow("url-exec-html") << "https://\">