on xenial help sign in
add the actual test ;)
dcff7e6Lukáš Tinkl
tests/plugins/Utils/WindowStateStorageTest.cppnew file+59
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright (C) 2017 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "windowstatestorage.h"
18+
19+#include <QTest>
20+
21+class WindowStateStorageTest : public QObject
22+{
23+ Q_OBJECT
24+
25+private Q_SLOTS:
26+ void init()
27+ {
28+ storage = new WindowStateStorage(this, true /* testMode */);
29+ }
30+
31+ void cleanup()
32+ {
33+ delete storage;
34+ }
35+
36+ void testSaveRestoreState() {
37+ const WindowStateStorage::WindowState state{WindowStateStorage::WindowState::WindowStateMaximizedTopLeft};
38+ storage->saveState(QTest::currentTestFunction(), state);
39+ QTRY_COMPARE(storage->getState(QTest::currentTestFunction(), WindowStateStorage::WindowState::WindowStateNormal), state);
40+ }
41+
42+ void testSaveRestoreGeometry() {
43+ const QRect geometry{10, 20, 30, 40};
44+ storage->saveGeometry(QTest::currentTestFunction(), geometry);
45+ QTRY_COMPARE(storage->getGeometry(QTest::currentTestFunction(), QRect()), geometry);
46+ }
47+
48+ void testSaveRestoreStage() {
49+ const int stage{1};
50+ storage->saveStage(QTest::currentTestFunction(), stage);
51+ QTRY_COMPARE(storage->getStage(QTest::currentTestFunction(), 0), stage);
52+ }
53+
54+private:
55+ WindowStateStorage * storage{nullptr};
56+};
57+
58+QTEST_GUILESS_MAIN(WindowStateStorageTest)
59+#include "WindowStateStorageTest.moc"