on xenial help sign in
set the testing flag from the test itself
debd698Lukáš Tinkl
plugins/Utils/windowstatestorage.cpp+1−2
@@ -33,10 +33,9 @@ inline QString sanitiseString(QString string) {
33 .remove(QLatin1Char('\\'));
33 .remove(QLatin1Char('\\'));
34}
34}
35
35
36−WindowStateStorage::WindowStateStorage(QObject *parent, bool testMode):
36+WindowStateStorage::WindowStateStorage(QObject *parent):
37 QObject(parent)
37 QObject(parent)
38{
38{
39− QStandardPaths::setTestModeEnabled(testMode);
40 const QString dbPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QStringLiteral("/unity8/");
39 const QString dbPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QStringLiteral("/unity8/");
41 m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
40 m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
42 QDir dir;
41 QDir dir;
plugins/Utils/windowstatestorage.h+1−1
@@ -47,7 +47,7 @@ public:
47 Q_FLAG(WindowStates)
47 Q_FLAG(WindowStates)
48#endif
48#endif
49
49
50− WindowStateStorage(QObject *parent = nullptr, bool testMode = false);
50+ WindowStateStorage(QObject *parent = nullptr);
51 virtual ~WindowStateStorage();
51 virtual ~WindowStateStorage();
52
52
53 Q_INVOKABLE void saveState(const QString &windowId, WindowState state);
53 Q_INVOKABLE void saveState(const QString &windowId, WindowState state);
tests/plugins/Utils/WindowStateStorageTest.cpp+6−1
@@ -17,15 +17,20 @@
17#include "windowstatestorage.h"
17#include "windowstatestorage.h"
18
18
19#include <QTest>
19#include <QTest>
20+#include <QStandardPaths>
20
21
21class WindowStateStorageTest : public QObject
22class WindowStateStorageTest : public QObject
22{
23{
23 Q_OBJECT
24 Q_OBJECT
24
25
25private Q_SLOTS:
26private Q_SLOTS:
27+ void initTestCase() {
28+ QStandardPaths::setTestModeEnabled(true);
29+ }
30+
26 void init()
31 void init()
27 {
32 {
28− storage = new WindowStateStorage(this, true /* testMode */);
33+ storage = new WindowStateStorage(this);
29 }
34 }
30
35
31 void cleanup()
36 void cleanup()