File indexing completed on 2024-03-24 15:28:37

0001 /*
0002     SPDX-FileCopyrightText: 2021 Ahmad Samir <a.samirh78@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #include "kurlhandlertest.h"
0008 
0009 #include "kurlhandler_p.h"
0010 
0011 #include <QTest>
0012 
0013 void KUrlHandlerTest::testOpeningDocsUrls_data()
0014 {
0015     QTest::addColumn<QString>("appname");
0016     QTest::addColumn<QString>("helpUrl");
0017     QTest::addColumn<QString>("expected");
0018 
0019     const QString common = "https://docs.kde.org/index.php?branch=stable5&language=" + QLocale().name();
0020 
0021     QTest::newRow("okular-help-handbook") << "okular"
0022                                           << "help:/" << common + "&application=okular&path=index.html";
0023 
0024     QTest::newRow("okular-help-config-dialog") << "okular"
0025                                                << "help:/okular/configure.html" << common + "&application=okular&path=configure.html";
0026 
0027     QTest::newRow("systemsettings-fonts") << "systemsettings"
0028                                           << "help:/kcontrol/fonts/index.html" << common + "&application=kcontrol/fonts&path=index.html";
0029 
0030     QTest::newRow("systemsettings-clock") << "systemsettings"
0031                                           << "help:/kcontrol/clock/index.html" << common + "&application=kcontrol/clock&path=index.html";
0032 
0033     QTest::newRow("systemsettings-powerdevil") << "systemsettings"
0034                                                << "help:/kcontrol/powerdevil/index.html#advanced-settings"
0035                                                << common + "&application=kcontrol/powerdevil&path=index.html#advanced-settings";
0036 
0037     QTest::newRow("with-fragment") << "kinfocenter"
0038                                    << "help:/kinfocenter/index.html#kcm_memory" << common + "&application=kinfocenter&path=kcm_memory.html";
0039 
0040     QTest::newRow("with-fragment-2") << "okular"
0041                                      << "help:/okular/signatures.html#adding_digital_signatures"
0042                                      << common + "&application=okular&path=signatures.html#adding_digital_signatures";
0043 }
0044 
0045 void KUrlHandlerTest::testOpeningDocsUrls()
0046 {
0047     QFETCH(QString, appname);
0048     QFETCH(QString, helpUrl);
0049     QFETCH(QString, expected);
0050 
0051     QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
0052     QCoreApplication::setApplicationName(appname);
0053 
0054     const QUrl actual = KUrlHandler().concatDocsUrl(QUrl(helpUrl));
0055     QCOMPARE(actual, QUrl(expected));
0056 }
0057 
0058 QTEST_MAIN(KUrlHandlerTest)
0059 
0060 #include "moc_kurlhandlertest.cpp"