on xenial help sign in
set the testing flag from the test itself

rather than changing the plugin code

commitdebd6988c70c95446a940f936a8b2d442b584c1b authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 3 Jan 2017, 17:56 (10 years ago) parentdcff7e6
3 files changed+8−4
plugins/Utils/windowstatestorage.cpp+1−2 plugins/Utils/windowstatestorage.h+1−1 tests/plugins/Utils/WindowStateStorageTest.cpp+6−1
plugins/Utils/windowstatestorage.cpp+1−2
@@ -33,10 +33,9 @@ inline QString sanitiseString(QString string) {
3333 .remove(QLatin1Char('\\'));
3434}
3535
36−WindowStateStorage::WindowStateStorage(QObject *parent, bool testMode):
36+WindowStateStorage::WindowStateStorage(QObject *parent):
3737 QObject(parent)
3838{
39− QStandardPaths::setTestModeEnabled(testMode);
4039 const QString dbPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QStringLiteral("/unity8/");
4140 m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
4241 QDir dir;
plugins/Utils/windowstatestorage.h+1−1
@@ -47,7 +47,7 @@ public:
4747 Q_FLAG(WindowStates)
4848#endif
4949
50− WindowStateStorage(QObject *parent = nullptr, bool testMode = false);
50+ WindowStateStorage(QObject *parent = nullptr);
5151 virtual ~WindowStateStorage();
5252
5353 Q_INVOKABLE void saveState(const QString &windowId, WindowState state);
tests/plugins/Utils/WindowStateStorageTest.cpp+6−1
@@ -17,15 +17,20 @@
1717#include "windowstatestorage.h"
1818
1919#include <QTest>
20+#include <QStandardPaths>
2021
2122class WindowStateStorageTest : public QObject
2223{
2324 Q_OBJECT
2425
2526private Q_SLOTS:
27+ void initTestCase() {
28+ QStandardPaths::setTestModeEnabled(true);
29+ }
30+
2631 void init()
2732 {
28− storage = new WindowStateStorage(this, true /* testMode */);
33+ storage = new WindowStateStorage(this);
2934 }
3035
3136 void cleanup()