// This file Copyright © Mnemosyne LLC. // It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only), // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. #include #include #include #include #include #include #include #include #include "Prefs.h" #include "Session.h" #include "qt-test-fixtures.h" #include "rpc-test-fixtures.h" #if QT_VERSION < QT_VERSION_CHECK(6, 3, 0) #define QCOMPARE_EQ(actual, expected) QCOMPARE(actual, expected) #define QCOMPARE_NE(actual, expected) QVERIFY((actual) != (expected)) #endif namespace api_compat = tr::api_compat; using Style = api_compat::Style; Q_DECLARE_METATYPE(Style) [[nodiscard]] QRegularExpression getSessionSetDownloadDirRegEx(Style const style, QString dir) { dir = QRegularExpression::escape(dir); switch (style) { case Style::Tr4: return QRegularExpression{ QStringLiteral(R"(^\{"arguments":\{"download-dir":"%1"\},"method":"session-set","tag":[0-9]+\}$)").arg(dir) }; case Style::Tr5: return QRegularExpression{ QStringLiteral(R"(^\{"id":[0-9]+,"jsonrpc":"2\.0","method":"session_set","params":\{"download_dir":"%1"\}\}$)") .arg(dir) }; } abort(); return {}; } class SessionTest : public QObject , SandboxedTest { Q_OBJECT private slots: static void download_dir_change_posts_session_set_data() { QTest::addColumn