on xenial help sign in
add a test for the wizard skipping to the last page
c7e0c5bLukáš Tinkl
plugins/Wizard/PageList.cpp−1
@@ -70,7 +70,6 @@ PageList::PageList(QObject *parent)
70
70
71 // If there was a system update installed, skip until the last page to just greet the user
71 // If there was a system update installed, skip until the last page to just greet the user
72 QSettings settings;
72 QSettings settings;
73−
74 if (settings.value(QStringLiteral("Wizard/SkipUntilFinishedPage")).toBool()) {
73 if (settings.value(QStringLiteral("Wizard/SkipUntilFinishedPage")).toBool()) {
75 const QString lastPage = m_pages.lastKey();
74 const QString lastPage = m_pages.lastKey();
76 Q_FOREACH(const QString &page, m_pages.keys()) {
75 Q_FOREACH(const QString &page, m_pages.keys()) {
tests/plugins/Wizard/tst_pagelist.cpp+30−1
@@ -20,6 +20,7 @@
20#include <QObject>
20#include <QObject>
21#include <QTemporaryDir>
21#include <QTemporaryDir>
22#include <QTest>
22#include <QTest>
23+#include <QSettings>
23
24
24#define PAGES_PATH "Wizard/Pages"
25#define PAGES_PATH "Wizard/Pages"
25
26
@@ -28,7 +29,7 @@ class PageListTest: public QObject
28 Q_OBJECT
29 Q_OBJECT
29
30
30public:
31public:
31− PageListTest() {};
32+ PageListTest() {}
32
33
33private Q_SLOTS:
34private Q_SLOTS:
34 void testCollect();
35 void testCollect();
@@ -37,6 +38,7 @@ private Q_SLOTS:
37 void testIgnoreNonQml();
38 void testIgnoreNonQml();
38 void testIgnoreDuplicates();
39 void testIgnoreDuplicates();
39 void testDisabled();
40 void testDisabled();
41+ void testSkipUntilLastPage();
40
42
41private:
43private:
42 void fillRoot(const QTemporaryDir &root);
44 void fillRoot(const QTemporaryDir &root);
@@ -150,5 +152,32 @@ void PageListTest::testDisabled()
150 QCOMPARE(pageList.entries(), QStringList() << "4.qml");
152 QCOMPARE(pageList.entries(), QStringList() << "4.qml");
151}
153}
152
154
155+void PageListTest::testSkipUntilLastPage() {
156+ PageList * pageList = nullptr;
157+ QTemporaryDir root;
158+ fillRoot(root);
159+
160+ makeFile(root, "a", "1.qml");
161+ makeFile(root, "a", "2.qml");
162+ makeFile(root, "a", "3.qml");
163+
164+ // normal run
165+ pageList = new PageList;
166+ QCOMPARE(pageList->numPages(), 3);
167+ delete pageList; pageList = nullptr;
168+
169+ // after system update had been installed, have the last page only
170+ QSettings settings;
171+ settings.setValue(QStringLiteral("Wizard/SkipUntilFinishedPage"), true);
172+ pageList = new PageList;
173+ QCOMPARE(pageList->entries(), {QStringLiteral("3.qml")}); // only the last page should be in the list
174+ delete pageList; pageList = nullptr;
175+
176+ // normal run again
177+ pageList = new PageList;
178+ QCOMPARE(pageList->numPages(), 3);
179+ delete pageList; pageList = nullptr;
180+}
181+
153QTEST_MAIN(PageListTest)
182QTEST_MAIN(PageListTest)
154#include "tst_pagelist.moc"
183#include "tst_pagelist.moc"