diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-04 14:06:34 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-06 22:10:10 +0200 |
commit | bce76d2e73a462de673d18dbf6d94da0c592bf08 (patch) | |
tree | 455687733ca90a74ecf8c4c90100695332378bf4 /autotests | |
parent | 2ac45198cf101f094cf8d94f3a546a57624e59f5 (diff) | |
download | kconfig-bce76d2e73a462de673d18dbf6d94da0c592bf08.tar.gz kconfig-bce76d2e73a462de673d18dbf6d94da0c592bf08.tar.bz2 |
Less implicit cast from ASCII
NO_CHANGELOG
Diffstat (limited to 'autotests')
-rw-r--r-- | autotests/kconfig_compiler/kconfigcompiler_test.cpp | 4 | ||||
-rw-r--r-- | autotests/kconfig_compiler/test4main.cpp | 2 | ||||
-rw-r--r-- | autotests/kconfig_compiler/test_emptyentries_main.cpp | 2 | ||||
-rw-r--r-- | autotests/kconfigguitest.cpp | 20 | ||||
-rw-r--r-- | autotests/kconfigloadertest.cpp | 46 | ||||
-rw-r--r-- | autotests/kconfigskeletontest.cpp | 47 | ||||
-rw-r--r-- | autotests/kdesktopfiletest.cpp | 48 | ||||
-rw-r--r-- | autotests/kstandardshortcuttest.cpp | 4 | ||||
-rw-r--r-- | autotests/test_kconf_update.cpp | 25 |
9 files changed, 110 insertions, 88 deletions
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index 6afc0096..014bc0f3 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -119,8 +119,8 @@ void KConfigCompiler_Test::testBaselineComparison() qWarning() << "Failed to open" << fileRef.fileName() << "(" << testName << ".ref )"; QFAIL("Can't open file for comparison"); } - QString content = file.readAll(); - QString contentRef = fileRef.readAll(); + const QByteArray content = file.readAll(); + const QByteArray contentRef = fileRef.readAll(); if (content != contentRef) { appendFileDiff(fileRef.fileName(), file.fileName()); diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp index 2d48e440..8792842f 100644 --- a/autotests/kconfig_compiler/test4main.cpp +++ b/autotests/kconfig_compiler/test4main.cpp @@ -19,7 +19,7 @@ int main(int argc, char **argv) group.writeEntry(QStringLiteral("foo bar"), QStringLiteral("Value")); } Test4 *t = Test4::self(); - bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/test4rc"); + const bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/test4rc"}); if (!ok) { qWarning() << "config file was not created!"; } diff --git a/autotests/kconfig_compiler/test_emptyentries_main.cpp b/autotests/kconfig_compiler/test_emptyentries_main.cpp index 18c750a5..5dbce8e4 100644 --- a/autotests/kconfig_compiler/test_emptyentries_main.cpp +++ b/autotests/kconfig_compiler/test_emptyentries_main.cpp @@ -11,7 +11,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); Q_UNUSED(app); - QMakeBuilderSettings::instance("abc"); + QMakeBuilderSettings::instance(QStringLiteral("abc")); auto *t = QMakeBuilderSettings::self(); delete t; return 0; diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp index 2a618ce2..87168a7f 100644 --- a/autotests/kconfigguitest.cpp +++ b/autotests/kconfigguitest.cpp @@ -16,10 +16,16 @@ QTEST_MAIN(KConfigTest) -#define COLORENTRY1 QColor("steelblue") -#define COLORENTRY2 QColor(235, 235, 100, 125) -#define COLORENTRY3 QColor(234, 234, 127) -#define FONTENTRY QFont("Times", 16, QFont::Normal) +// clazy:excludeall=non-pod-global-static + +const QColor COLORENTRY1(QLatin1String{"steelblue"}); +const QColor COLORENTRY2(235, 235, 100, 125); +const QColor COLORENTRY3(234, 234, 127); + +static QFont fontEntry() +{ + return QFont{QStringLiteral("Times"), 16, QFont::Normal}; +} void KConfigTest::initTestCase() { @@ -36,7 +42,7 @@ void KConfigTest::initTestCase() cg.writeEntry("colorEntry2", COLORENTRY2); cg.writeEntry("colorEntry3", (QList<int>() << 234 << 234 << 127)); cg.writeEntry("colorEntry4", (QList<int>() << 235 << 235 << 100 << 125)); - cg.writeEntry("fontEntry", FONTENTRY); + cg.writeEntry("fontEntry", fontEntry()); QVERIFY(sc.sync()); KConfig sc1(QStringLiteral("kdebugrc")); @@ -51,7 +57,7 @@ void KConfigTest::initTestCase() // This is fixed by https://codereview.qt-project.org/181645 // It's not in yet, and it depends on the app font, so rather than // a version check, let's do a runtime check. - QFont orig(FONTENTRY); + QFont orig(fontEntry()); QFont f; f.fromString(orig.toString()); m_fontFromStringBug = (f.toString() != orig.toString()); @@ -81,7 +87,7 @@ void KConfigTest::testComplex() if (m_fontFromStringBug) { QEXPECT_FAIL("", "QFont fromString bug from Qt 5.8.0", Continue); } - QCOMPARE(sc3.readEntry("fontEntry", QFont()), FONTENTRY); + QCOMPARE(sc3.readEntry("fontEntry", QFont()), fontEntry()); } void KConfigTest::testInvalid() diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp index afc58a1b..27a90916 100644 --- a/autotests/kconfigloadertest.cpp +++ b/autotests/kconfigloadertest.cpp @@ -12,7 +12,7 @@ Q_DECLARE_METATYPE(QList<int>) -#define TEST_NAME QString::fromLatin1("kconfigloadertest") +const QString TEST_NAME(QStringLiteral("kconfigloadertest")); #define GET_CONFIG_ITEM_VALUE(type, configName) \ KConfigSkeletonItem* item = cl->findItem(TEST_NAME, configName); \ @@ -38,70 +38,70 @@ void ConfigLoaderTest::cleanup() void ConfigLoaderTest::boolDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, "DefaultBoolItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, QStringLiteral("DefaultBoolItem")); QVERIFY(typeItem->isEqual(true)); } void ConfigLoaderTest::colorDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, "DefaultColorItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, QStringLiteral("DefaultColorItem")); QVERIFY(typeItem->isEqual(QColor("#00FF00"))); } void ConfigLoaderTest::dateTimeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, "DefaultDateTimeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, QStringLiteral("DefaultDateTimeItem")); - QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010"))); + QVERIFY(typeItem->isEqual(QDateTime::fromString(QStringLiteral("Thu Sep 09 2010")))); } void ConfigLoaderTest::enumDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, "DefaultEnumItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, QStringLiteral("DefaultEnumItem")); QVERIFY(typeItem->isEqual(3)); } void ConfigLoaderTest::fontDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, "DefaultFontItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, QStringLiteral("DefaultFontItem")); - QVERIFY(typeItem->isEqual(QFont("DejaVu Sans"))); + QVERIFY(typeItem->isEqual(QFont(QStringLiteral("DejaVu Sans")))); } void ConfigLoaderTest::intDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, "DefaultIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, QStringLiteral("DefaultIntItem")); QVERIFY(typeItem->isEqual(27)); } void ConfigLoaderTest::passwordDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, "DefaultPasswordItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, QStringLiteral("DefaultPasswordItem")); QVERIFY(typeItem->isEqual(QString::fromLatin1("h4x."))); } void ConfigLoaderTest::pathDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, "DefaultPathItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, QStringLiteral("DefaultPathItem")); QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null"))); } void ConfigLoaderTest::stringDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, "DefaultStringItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, QStringLiteral("DefaultStringItem")); QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString"))); } void ConfigLoaderTest::stringListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, "DefaultStringListItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, QStringLiteral("DefaultStringListItem")); // Create a string list with the expected values. QStringList expected; @@ -116,28 +116,28 @@ void ConfigLoaderTest::stringListDefaultValue() void ConfigLoaderTest::uintDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, "DefaultUIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, QStringLiteral("DefaultUIntItem")); QVERIFY(typeItem->isEqual(7U)); } void ConfigLoaderTest::urlDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, "DefaultUrlItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, QStringLiteral("DefaultUrlItem")); - QVERIFY(typeItem->isEqual(QUrl("http://kde.org"))); + QVERIFY(typeItem->isEqual(QUrl(QStringLiteral("http://kde.org")))); } void ConfigLoaderTest::doubleDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, "DefaultDoubleItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, QStringLiteral("DefaultDoubleItem")); QVERIFY(typeItem->isEqual(13.37)); } void ConfigLoaderTest::intListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, "DefaultIntListItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, QStringLiteral("DefaultIntListItem")); // Create a int list with the expected values. QList<int> expected; @@ -153,21 +153,21 @@ void ConfigLoaderTest::intListDefaultValue() void ConfigLoaderTest::longLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, "DefaultLongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, QStringLiteral("DefaultLongLongItem")); QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808))); } void ConfigLoaderTest::pointDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, "DefaultPointItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, QStringLiteral("DefaultPointItem")); QVERIFY(typeItem->isEqual(QPoint(185, 857))); } void ConfigLoaderTest::rectDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, "DefaultRectItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, QStringLiteral("DefaultRectItem")); // Create a new QRect with the expected value. QRect expected; @@ -178,14 +178,14 @@ void ConfigLoaderTest::rectDefaultValue() void ConfigLoaderTest::sizeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, "DefaultSizeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, QStringLiteral("DefaultSizeItem")); QVERIFY(typeItem->isEqual(QSize(640, 480))); } void ConfigLoaderTest::ulongLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, "DefaultULongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, QStringLiteral("DefaultULongLongItem")); QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806))); } diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp index 896d4ee1..75708bc1 100644 --- a/autotests/kconfigskeletontest.cpp +++ b/autotests/kconfigskeletontest.cpp @@ -14,13 +14,22 @@ QTEST_MAIN(KConfigSkeletonTest) #define DEFAULT_SETTING1 false #define DEFAULT_SETTING2 QColor(1,2,3) -#define DEFAULT_SETTING3 QFont("helvetica",12) -#define DEFAULT_SETTING4 QString("Hello World") +const QString DEFAULT_SETTING4{QStringLiteral("Hello World")}; + #define WRITE_SETTING1 true #define WRITE_SETTING2 QColor(3,2,1) -#define WRITE_SETTING3 QFont("helvetica",14) -#define WRITE_SETTING4 QString("KDE") +const QString WRITE_SETTING4{QStringLiteral("KDE")}; + +static QFont defaultSetting3() +{ + return QFont{QStringLiteral("helvetica"), 12}; +} + +static QFont writeSettings3() +{ + return QFont{QStringLiteral("helvetica"), 14}; +} void KConfigSkeletonTest::initTestCase() { @@ -29,19 +38,19 @@ void KConfigSkeletonTest::initTestCase() void KConfigSkeletonTest::init() { - QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/kconfigskeletontestrc"); + QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/kconfigskeletontestrc"}); s = new KConfigSkeleton(QStringLiteral("kconfigskeletontestrc")); s->setCurrentGroup(QStringLiteral("MyGroup")); itemBool = s->addItemBool(QStringLiteral("MySetting1"), mMyBool, DEFAULT_SETTING1); s->addItemColor(QStringLiteral("MySetting2"), mMyColor, DEFAULT_SETTING2); s->setCurrentGroup(QStringLiteral("MyOtherGroup")); - s->addItemFont(QStringLiteral("MySetting3"), mMyFont, DEFAULT_SETTING3); + s->addItemFont(QStringLiteral("MySetting3"), mMyFont, defaultSetting3()); s->addItemString(QStringLiteral("MySetting4"), mMyString, DEFAULT_SETTING4); QCOMPARE(mMyBool, DEFAULT_SETTING1); QCOMPARE(mMyColor, DEFAULT_SETTING2); - QCOMPARE(mMyFont, DEFAULT_SETTING3); + QCOMPARE(mMyFont, defaultSetting3()); QCOMPARE(mMyString, DEFAULT_SETTING4); QVERIFY(s->isDefaults()); @@ -57,7 +66,7 @@ void KConfigSkeletonTest::testSimple() { mMyBool = WRITE_SETTING1; mMyColor = WRITE_SETTING2; - mMyFont = WRITE_SETTING3; + mMyFont = writeSettings3(); mMyString = WRITE_SETTING4; QVERIFY(s->isSaveNeeded()); @@ -83,35 +92,35 @@ void KConfigSkeletonTest::testSimple() QCOMPARE(mMyBool, WRITE_SETTING1); QCOMPARE(mMyColor, WRITE_SETTING2); - QCOMPARE(mMyFont, WRITE_SETTING3); + QCOMPARE(mMyFont, writeSettings3()); QCOMPARE(mMyString, WRITE_SETTING4); } void KConfigSkeletonTest::testRemoveItem() { - QVERIFY(s->findItem("MySetting1")); + QVERIFY(s->findItem(QStringLiteral("MySetting1"))); s->removeItem(QStringLiteral("MySetting1")); - QVERIFY(!s->findItem("MySetting1")); + QVERIFY(!s->findItem(QStringLiteral("MySetting1"))); } void KConfigSkeletonTest::testClear() { - QVERIFY(s->findItem("MySetting2")); - QVERIFY(s->findItem("MySetting3")); - QVERIFY(s->findItem("MySetting4")); + QVERIFY(s->findItem(QStringLiteral("MySetting2"))); + QVERIFY(s->findItem(QStringLiteral("MySetting3"))); + QVERIFY(s->findItem(QStringLiteral("MySetting4"))); s->clearItems(); - QVERIFY(!s->findItem("MySetting2")); - QVERIFY(!s->findItem("MySetting3")); - QVERIFY(!s->findItem("MySetting4")); + QVERIFY(!s->findItem(QStringLiteral("MySetting2"))); + QVERIFY(!s->findItem(QStringLiteral("MySetting3"))); + QVERIFY(!s->findItem(QStringLiteral("MySetting4"))); } void KConfigSkeletonTest::testDefaults() { mMyBool = WRITE_SETTING1; mMyColor = WRITE_SETTING2; - mMyFont = WRITE_SETTING3; + mMyFont = writeSettings3(); mMyString = WRITE_SETTING4; QVERIFY(s->isSaveNeeded()); @@ -129,7 +138,7 @@ void KConfigSkeletonTest::testDefaults() QCOMPARE(mMyBool, DEFAULT_SETTING1); QCOMPARE(mMyColor, DEFAULT_SETTING2); - QCOMPARE(mMyFont, DEFAULT_SETTING3); + QCOMPARE(mMyFont, defaultSetting3()); QCOMPARE(mMyString, DEFAULT_SETTING4); s->save(); diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index 34391489..e45ba44e 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -53,7 +53,7 @@ void KDesktopFileTest::testRead() #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) void KDesktopFileTest::testReadDirectory() { - QTemporaryFile file("testReadDirectoryXXXXXX.directory"); + QTemporaryFile file(QStringLiteral("testReadDirectoryXXXXXX.directory")); QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); @@ -178,20 +178,20 @@ void KDesktopFileTest::testActionGroup() KDesktopFile df(fileName); QCOMPARE(df.readType(), QString()); QCOMPARE(df.fileName(), QFileInfo(fileName).canonicalFilePath()); - QCOMPARE(df.readActions(), QStringList() << "encrypt" << "semi;colon" << "decrypt"); - QCOMPARE(df.hasActionGroup("encrypt"), true); - QCOMPARE(df.hasActionGroup("semi;colon"), true); - QCOMPARE(df.hasActionGroup("decrypt"), true); - QCOMPARE(df.hasActionGroup("doesnotexist"), false); + QCOMPARE(df.readActions(), (QStringList{QStringLiteral("encrypt"), QStringLiteral("semi;colon"), QStringLiteral("decrypt")})); + QCOMPARE(df.hasActionGroup(QStringLiteral("encrypt")), true); + QCOMPARE(df.hasActionGroup(QStringLiteral("semi;colon")), true); + QCOMPARE(df.hasActionGroup(QStringLiteral("decrypt")), true); + QCOMPARE(df.hasActionGroup(QStringLiteral("doesnotexist")), false); KConfigGroup cg = df.actionGroup(QStringLiteral("encrypt")); QVERIFY(cg.hasKey("Name")); - QCOMPARE(cg.readEntry("Name"), QString("Encrypt file")); + QCOMPARE(cg.readEntry("Name"), QStringLiteral("Encrypt file")); cg = df.actionGroup(QStringLiteral("decrypt")); QVERIFY(cg.hasKey("Name")); - QCOMPARE(cg.readEntry("Name"), QString("Decrypt file")); + QCOMPARE(cg.readEntry("Name"), QStringLiteral("Decrypt file")); cg = df.actionGroup(QStringLiteral("semi;colon")); QVERIFY(cg.hasKey("Name")); - QCOMPARE(cg.readEntry("Name"), QString("With semicolon")); + QCOMPARE(cg.readEntry("Name"), QStringLiteral("With semicolon")); } void KDesktopFileTest::testIsAuthorizedDesktopFile() @@ -275,17 +275,25 @@ void KDesktopFileTest::testLocateLocal_data() QTest::addColumn<QString>("path"); QTest::addColumn<QString>("result"); - QTest::newRow("configLocation, system-wide") << systemConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop"; - QTest::newRow("autostart, system-wide") << systemConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop"; - QTest::newRow("dataLocation, system-wide") << systemDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop"; - QTest::newRow("applications, system-wide") << systemDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop"; - QTest::newRow("desktop-directories, system-wide") << systemDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory"; - QTest::newRow("configLocation, writable") << writableConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop"; - QTest::newRow("autostart, writable") << writableConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop"; - QTest::newRow("dataLocation, writable") << writableDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop"; - QTest::newRow("applications, writable") << writableDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop"; - QTest::newRow("desktop-directories, writable") << writableDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory"; - QTest::newRow("unknown location") << "/test.desktop" << writableDataLocation + "/test.desktop"; + QTest::newRow("configLocation, system-wide") << systemConfigLocation + QLatin1String{"/test.desktop"} + << writableConfigLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("autostart, system-wide") << systemConfigLocation + QLatin1String{"/autostart/test.desktop"} + << writableConfigLocation + QLatin1String{"/autostart/test.desktop"}; + QTest::newRow("dataLocation, system-wide") << systemDataLocation + QLatin1String{"/test.desktop"} << writableDataLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("applications, system-wide") << systemDataLocation + QLatin1String{"/applications/test.desktop"} + << writableDataLocation + QLatin1String{"/applications/test.desktop"}; + QTest::newRow("desktop-directories, system-wide") << systemDataLocation + QLatin1String{"/desktop-directories/test.directory"} + << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"}; + QTest::newRow("configLocation, writable") << writableConfigLocation + QLatin1String{"/test.desktop"} + << writableConfigLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("autostart, writable") << writableConfigLocation + QLatin1String{"/autostart/test.desktop"} + << writableConfigLocation + QLatin1String{"/autostart/test.desktop"}; + QTest::newRow("dataLocation, writable") << writableDataLocation + QLatin1String{"/test.desktop"} << writableDataLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("applications, writable") << writableDataLocation + QLatin1String{"/applications/test.desktop"} + << writableDataLocation + QLatin1String{"/applications/test.desktop"}; + QTest::newRow("desktop-directories, writable") << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"} + << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"}; + QTest::newRow("unknown location") << QStringLiteral("/test.desktop") << writableDataLocation + QLatin1String{"/test.desktop"}; } void KDesktopFileTest::testLocateLocal() diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index 69e234ab..1b7f88ff 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -49,8 +49,8 @@ void KStandardShortcutTest::testShortcut() void KStandardShortcutTest::testFindStdAccel() { - QCOMPARE(KStandardShortcut::find(QString("Ctrl+F")), KStandardShortcut::Find); - QCOMPARE(KStandardShortcut::find(QString("Ctrl+Shift+Alt+G")), KStandardShortcut::AccelNone); + QCOMPARE(KStandardShortcut::find(QKeySequence(Qt::CTRL | Qt::Key_F)), KStandardShortcut::Find); + QCOMPARE(KStandardShortcut::find(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::ALT | Qt::Key_G)), KStandardShortcut::AccelNone); } void KStandardShortcutTest::testFindByName() diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index ba716f28..88ba385f 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -65,8 +65,8 @@ static std::unique_ptr<QTemporaryFile> writeUpdFile(const QString &content) static void runKConfUpdate(const QString &updPath) { - QVERIFY(QFile::exists(KCONF_UPDATE_EXECUTABLE)); - QCOMPARE(0, QProcess::execute(KCONF_UPDATE_EXECUTABLE, QStringList() << "--testmode" << "--debug" << updPath)); + QVERIFY(QFile::exists(QStringLiteral(KCONF_UPDATE_EXECUTABLE))); + QCOMPARE(0, QProcess::execute(QStringLiteral(KCONF_UPDATE_EXECUTABLE), QStringList{QStringLiteral("--testmode"), QStringLiteral("--debug"), updPath})); } void TestKConfUpdate::test_data() @@ -313,10 +313,11 @@ void TestKConfUpdate::test() QFETCH(bool, shouldUpdateWork); // Prepend Version and the Id= field to the upd content - const QString header = QStringLiteral("Id=%1\n").arg(QTest::currentDataTag()); + const QString header = QLatin1String("Id=%1\n").arg(QLatin1String(QTest::currentDataTag())); updContent = header + updContent; - if (useVersion5) - updContent.prepend("Version=5\n"); + if (useVersion5) { + updContent.prepend(QLatin1String{"Version=5\n"}); + } const QString configDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); QVERIFY(QDir().mkpath(configDir)); @@ -331,7 +332,7 @@ void TestKConfUpdate::test() std::unique_ptr<QTemporaryFile> updFile(writeUpdFile(updContent)); runKConfUpdate(updFile->fileName()); - QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag()); + QString updateInfo = QLatin1String("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QLatin1String{QTest::currentDataTag()}); QString newConfContentAfter = readFile(newConfPath); if (shouldUpdateWork) { @@ -609,26 +610,24 @@ void TestKConfUpdate::testScript() QFETCH(QString, expectedNewConfContent); // Prepend the Version and Id= field to the upd content - updContent = QStringLiteral("Version=5\nId=%1\n").arg(QTest::currentDataTag()) + updContent; + updContent.prepend(QLatin1String("Version=5\nId=%1\n").arg(QLatin1String{QTest::currentDataTag()})); std::unique_ptr<QTemporaryFile> updFile(writeUpdFile(updContent)); - const QString scriptDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kconf_update"; + const QString scriptDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String{"/kconf_update"}; QVERIFY(QDir().mkpath(scriptDir)); - QString scriptPath = scriptDir + "/test.sh"; + const QString scriptPath = scriptDir + QLatin1String{"/test.sh"}; writeFile(scriptPath, updScript); QCOMPARE(readFile(scriptPath), updScript); - QString confPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + "testrc"; + const QString confPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/testrc"}; writeFile(confPath, oldConfContent); QCOMPARE(readFile(confPath), oldConfContent); runKConfUpdate(updFile->fileName()); - QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag()); + const QString updateInfo = QLatin1String("%1:%2").arg(updFile->fileName().section(QLatin1Char{'/'}, -1), QLatin1String{QTest::currentDataTag()}); QString newConfContent = readFile(confPath); expectedNewConfContent = expectedNewConfContent.arg(updateInfo); QCOMPARE(newConfContent, expectedNewConfContent); } - - |