diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/resourceaccess.cpp | 4 | ||||
-rw-r--r-- | common/test.cpp | 16 | ||||
-rw-r--r-- | common/test.h | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index b294221..6dcc898 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "common/inspection_generated.h" | 33 | #include "common/inspection_generated.h" |
34 | #include "common/entitybuffer.h" | 34 | #include "common/entitybuffer.h" |
35 | #include "common/bufferutils.h" | 35 | #include "common/bufferutils.h" |
36 | #include "common/test.h" | ||
36 | #include "log.h" | 37 | #include "log.h" |
37 | 38 | ||
38 | #include <QCoreApplication> | 39 | #include <QCoreApplication> |
@@ -204,6 +205,9 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
204 | TracePrivate() << "Failed to connect, starting resource"; | 205 | TracePrivate() << "Failed to connect, starting resource"; |
205 | // We failed to connect, so let's start the resource | 206 | // We failed to connect, so let's start the resource |
206 | QStringList args; | 207 | QStringList args; |
208 | if (Sink::Test::testModeEnabled()) { | ||
209 | args << "--test"; | ||
210 | } | ||
207 | args << resourceInstanceIdentifier << resourceName; | 211 | args << resourceInstanceIdentifier << resourceName; |
208 | qint64 pid = 0; | 212 | qint64 pid = 0; |
209 | if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { | 213 | if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { |
diff --git a/common/test.cpp b/common/test.cpp index 1062e21..59ad9ec 100644 --- a/common/test.cpp +++ b/common/test.cpp | |||
@@ -32,7 +32,7 @@ using namespace Sink; | |||
32 | 32 | ||
33 | void Sink::Test::initTest() | 33 | void Sink::Test::initTest() |
34 | { | 34 | { |
35 | QStandardPaths::setTestModeEnabled(true); | 35 | setTestModeEnabled(true); |
36 | // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); | 36 | // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); |
37 | QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively(); | 37 | QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively(); |
38 | // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::DataLocation); | 38 | // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::DataLocation); |
@@ -47,6 +47,20 @@ void Sink::Test::initTest() | |||
47 | QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); | 47 | QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); |
48 | } | 48 | } |
49 | 49 | ||
50 | void Sink::Test::setTestModeEnabled(bool enabled) | ||
51 | { | ||
52 | QStandardPaths::setTestModeEnabled(enabled); | ||
53 | if (enabled) { | ||
54 | qputenv("SINK_TESTMODE", "TRUE"); | ||
55 | } else { | ||
56 | qunsetenv("SINK_TESTMODE"); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | bool Sink::Test::testModeEnabled() | ||
61 | { | ||
62 | return !qEnvironmentVariableIsEmpty("SINK_TESTMODE"); | ||
63 | } | ||
50 | 64 | ||
51 | template <typename T> | 65 | template <typename T> |
52 | class TestFacade : public Sink::StoreFacade<T> | 66 | class TestFacade : public Sink::StoreFacade<T> |
diff --git a/common/test.h b/common/test.h index e2bd1ea..bb505b6 100644 --- a/common/test.h +++ b/common/test.h | |||
@@ -34,6 +34,8 @@ namespace Test { | |||
34 | * and clears all data directories. | 34 | * and clears all data directories. |
35 | */ | 35 | */ |
36 | void SINK_EXPORT initTest(); | 36 | void SINK_EXPORT initTest(); |
37 | void SINK_EXPORT setTestModeEnabled(bool); | ||
38 | bool SINK_EXPORT testModeEnabled(); | ||
37 | 39 | ||
38 | class SINK_EXPORT TestAccount { | 40 | class SINK_EXPORT TestAccount { |
39 | public: | 41 | public: |