Commit 311dd0f5 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

allow KateApp to take sessionsDir

will allow for easier unit testing of the sessions manager
parent a2d0f284
Pipeline #170134 failed with stage
in 6 minutes and 4 seconds
......@@ -29,6 +29,7 @@
#include <QJsonDocument>
#include <QRegularExpression>
#include <QSessionManager>
#include <QStandardPaths>
#include <QTextCodec>
#include <QUrl>
#include <QVariant>
......@@ -581,7 +582,7 @@ int main(int argc, char **argv)
* behaves like a singleton, one unique instance
* we are passing our local command line parser to it
*/
KateApp kateApp(parser);
KateApp kateApp(parser, KateApp::ApplicationKate, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kate/sessions"));
/**
* init kate
......
......@@ -15,6 +15,7 @@
#include <QApplication>
#include <QCommandLineParser>
#include <QStandardPaths>
#ifndef Q_OS_WIN
#include <unistd.h>
......@@ -175,7 +176,9 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
* behaves like a singleton, one unique instance
* we are passing our local command line parser to it
*/
KateApp kateApp(parser, KateApp::ApplicationKWrite);
KateApp kateApp(parser,
KateApp::ApplicationKWrite,
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kwrite/sessions"));
/**
* init kate
......
......@@ -11,6 +11,7 @@
#include <QCommandLineParser>
#include <QSignalSpy>
#include <QTemporaryDir>
#include <QTest>
QTEST_MAIN(LocationHistoryTest)
......@@ -18,8 +19,11 @@ QTEST_MAIN(LocationHistoryTest)
LocationHistoryTest::LocationHistoryTest(QObject *parent)
: QObject(parent)
{
m_tempdir = new QTemporaryDir;
QVERIFY(m_tempdir->isValid());
static QCommandLineParser parser;
app = new KateApp(parser);
app = new KateApp(parser, KateApp::ApplicationKate, m_tempdir->path());
app->sessionManager()->activateAnonymousSession();
// create some usable example
......
......@@ -35,6 +35,7 @@ private Q_SLOTS:
void test_signalEmission();
private:
class QTemporaryDir *m_tempdir;
KateApp *app;
QTemporaryFile tempFile;
};
......@@ -24,7 +24,7 @@ void KateSessionManagerTest::init()
// we need an application object, as session loading will trigger modifications to that
static QCommandLineParser parser;
m_app = new KateApp(parser);
m_app = new KateApp(parser, KateApp::ApplicationKate, m_tempdir->path());
m_app->sessionManager()->activateAnonymousSession();
m_manager = new KateSessionManager(this, m_tempdir->path());
......
......@@ -23,7 +23,7 @@ void KateSessionsActionTest::init()
// we need an application object, as session loading will trigger modifications to that
static QCommandLineParser parser;
m_app = new KateApp(parser);
m_app = new KateApp(parser, KateApp::ApplicationKate, m_tempdir->path());
m_app->sessionManager()->activateAnonymousSession();
m_manager = new KateSessionManager(this, m_tempdir->path());
......
......@@ -53,16 +53,14 @@ static KateApp *appSelf = Q_NULLPTR;
Q_LOGGING_CATEGORY(LOG_KATE, "kate", QtWarningMsg)
KateApp::KateApp(const QCommandLineParser &args, const ApplicationMode mode)
KateApp::KateApp(const QCommandLineParser &args, const ApplicationMode mode, const QString &sessionsDir)
: m_args(args)
, m_mode(mode)
, m_wrapper(appSelf = this)
, m_docManager(this)
, m_adaptor(this)
, m_pluginManager(this)
, m_sessionManager(this,
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ (isKate() ? QStringLiteral("/kate/sessions") : QStringLiteral("/kwrite/sessions")))
, m_sessionManager(this, sessionsDir)
, m_stashManager(this)
{
/**
......
......@@ -53,8 +53,11 @@ public:
/**
* application constructor
* @param arg command line parser, reference will be stored, needs to survive as long as application object is alive
* @param mode application mode, either Kate or KWrite
* @param sessionDir directory used to store the session config files
*/
KateApp(const QCommandLineParser &arg, const ApplicationMode mode = ApplicationKate);
KateApp(const QCommandLineParser &arg, const ApplicationMode mode, const QString &sessionsDir);
/**
* return current application mode
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment