on xenial help sign in
add a test for the wizard skipping to the last page
commitc7e0c5bca5915458e49599c117af9462f3619771 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 18 Jul 2016, 14:08 (10 years ago) parent2500732
2 files changed+30−2
plugins/Wizard/PageList.cpp−1 tests/plugins/Wizard/tst_pagelist.cpp+30−1
plugins/Wizard/PageList.cpp−1
@@ -70,7 +70,6 @@ PageList::PageList(QObject *parent)
7070
7171 // If there was a system update installed, skip until the last page to just greet the user
7272 QSettings settings;
73−
7473 if (settings.value(QStringLiteral("Wizard/SkipUntilFinishedPage")).toBool()) {
7574 const QString lastPage = m_pages.lastKey();
7675 Q_FOREACH(const QString &page, m_pages.keys()) {
tests/plugins/Wizard/tst_pagelist.cpp+30−1
@@ -20,6 +20,7 @@
2020#include <QObject>
2121#include <QTemporaryDir>
2222#include <QTest>
23+#include <QSettings>
2324
2425#define PAGES_PATH "Wizard/Pages"
2526
@@ -28,7 +29,7 @@ class PageListTest: public QObject
2829 Q_OBJECT
2930
3031public:
31− PageListTest() {};
32+ PageListTest() {}
3233
3334private Q_SLOTS:
3435 void testCollect();
@@ -37,6 +38,7 @@ private Q_SLOTS:
3738 void testIgnoreNonQml();
3839 void testIgnoreDuplicates();
3940 void testDisabled();
41+ void testSkipUntilLastPage();
4042
4143private:
4244 void fillRoot(const QTemporaryDir &root);
@@ -150,5 +152,32 @@ void PageListTest::testDisabled()
150152 QCOMPARE(pageList.entries(), QStringList() << "4.qml");
151153}
152154
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+
153182QTEST_MAIN(PageListTest)
154183#include "tst_pagelist.moc"