// SPDX-FileCopyrightText: 2024 Devin Lin // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include #include #include #include #include #include "tests.h" #include "utils.h" #include "version.h" using namespace Qt::Literals::StringLiterals; std::unique_ptr createParser() { auto parser = std::make_unique(); parser->addOption(QCommandLineOption(u"list"_s, u"Lists the possible test notifications that can be set."_s)); parser->addVersionOption(); parser->addHelpOption(); parser->addPositionalArgument("test", "The test notification to send."); return parser; } int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); auto parser = createParser(); parser->process(app); QCoreApplication::setApplicationName(u"plasma-mobile-notificationtest"_s); QCoreApplication::setApplicationVersion(QStringLiteral(PLASMA_MOBILE_VERSION_STRING)); QCoreApplication::setOrganizationDomain(u"kde.org"_s); std::vector> notificationTests; notificationTests.push_back(std::make_unique()); notificationTests.push_back(std::make_unique()); notificationTests.push_back(std::make_unique()); notificationTests.push_back(std::make_unique()); notificationTests.push_back(std::make_unique()); notificationTests.push_back(std::make_unique()); notificationTests.push_back(std::make_unique()); if (parser->isSet(u"list"_s)) { for (auto ¬ification : notificationTests) { qInfo() << notification->name(); } return 0; } else if (parser->positionalArguments().size() == 0) { parser->showHelp(); return 0; } const auto args = parser->positionalArguments(); const QString name = args[0]; bool found = false; for (auto ¬ification : notificationTests) { if (notification->name() == name) { qInfo() << "Sending notification" << notification->name(); notification->sendNotification(app); found = true; break; } } if (!found) { qInfo() << "Test not found."; return 0; } return app.exec(); }