on xenial help sign in
add a test for the real implementation of WindowStateStorage
a9b0985Lukáš Tinkl
plugins/Utils/windowstatestorage.cpp+2−1
@@ -33,9 +33,10 @@ inline QString sanitiseString(QString string) {
33 .remove(QLatin1Char('\\'));
33 .remove(QLatin1Char('\\'));
34}
34}
35
35
36−WindowStateStorage::WindowStateStorage(QObject *parent):
36+WindowStateStorage::WindowStateStorage(QObject *parent, bool testMode):
37 QObject(parent)
37 QObject(parent)
38{
38{
39+ QStandardPaths::setTestModeEnabled(testMode);
39 const QString dbPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QStringLiteral("/unity8/");
40 const QString dbPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QStringLiteral("/unity8/");
40 m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
41 m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
41 QDir dir;
42 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);
50+ WindowStateStorage(QObject *parent = nullptr, bool testMode = false);
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/CMakeLists.txt+1
@@ -11,6 +11,7 @@ foreach(util_test
11 UnitySortFilterProxyModel
11 UnitySortFilterProxyModel
12 WindowInputMonitor
12 WindowInputMonitor
13 DeviceConfigParser
13 DeviceConfigParser
14+ WindowStateStorage
14)
15)
15 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
16 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
16 qt5_use_modules(${util_test}TestExec Test Core Qml)
17 qt5_use_modules(${util_test}TestExec Test Core Qml)