2 * Copyright (C) 2014 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <QTemporaryDir>
24#define PAGES_PATH "Wizard/Pages"
26class PageListTest: public QObject
36 void testIgnoreNonNumbered();
37 void testIgnoreNonQml();
38 void testIgnoreDuplicates();
42 void fillRoot(const QTemporaryDir &root);
43 void makeFile(const QTemporaryDir &root, const QString &dir, const QString &filename);
46void PageListTest::fillRoot(const QTemporaryDir &root)
48 QVERIFY(root.isValid());
49 QDir rootDir = root.path();
50 QVERIFY(rootDir.mkpath(QString("a/") + PAGES_PATH));
51 QVERIFY(rootDir.mkpath(QString("b/") + PAGES_PATH));
52 QVERIFY(rootDir.mkpath(QString("c/") + PAGES_PATH));
53 qputenv("XDG_DATA_DIRS", QString(rootDir.path() + "/a:" +
54 rootDir.path() + "/b:" +
55 rootDir.path() + "/c").toLatin1());
58void PageListTest::makeFile(const QTemporaryDir &root, const QString &dir, const QString &filename)
60 QFile file(root.path() + "/" + dir + "/" + PAGES_PATH + "/" + filename);
61 QVERIFY(file.open(QIODevice::WriteOnly));
63 QVERIFY(file.exists());
66void PageListTest::testCollect()
70 makeFile(root, "a", "3.qml");
71 makeFile(root, "b", "1.qml");
72 makeFile(root, "c", "2.qml");
75 QCOMPARE(pageList.entries(), QStringList() << "1.qml" << "2.qml" << "3.qml");
76 QCOMPARE(pageList.paths(), QStringList() << root.path() + "/b/" + PAGES_PATH + "/1.qml"
77 << root.path() + "/c/" + PAGES_PATH + "/2.qml"
78 << root.path() + "/a/" + PAGES_PATH + "/3.qml");
81void PageListTest::testIterate()
85 makeFile(root, "a", "1.qml");
86 makeFile(root, "a", "2.qml");
87 makeFile(root, "a", "3.qml");
90 QCOMPARE(pageList.index(), -1);
91 QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/1.qml");
92 QCOMPARE(pageList.prev(), QString());
93 QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/2.qml");
94 QCOMPARE(pageList.prev(), root.path() + "/a/" + PAGES_PATH + "/1.qml");
95 QCOMPARE(pageList.index(), 0);
96 QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/2.qml");
97 QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/3.qml");
98 QCOMPARE(pageList.index(), 2);
99 QCOMPARE(pageList.next(), QString());
100 QCOMPARE(pageList.index(), 2);
103void PageListTest::testIgnoreNonNumbered()
107 makeFile(root, "a", "1.qml");
108 makeFile(root, "a", "nope.qml");
111 QCOMPARE(pageList.entries(), QStringList() << "1.qml");
114void PageListTest::testIgnoreNonQml()
118 makeFile(root, "a", "1.qml");
119 makeFile(root, "a", "2");
120 makeFile(root, "a", "2.txt");
123 QCOMPARE(pageList.entries(), QStringList() << "1.qml");
126void PageListTest::testIgnoreDuplicates()
130 makeFile(root, "a", "1.qml");
131 makeFile(root, "b", "1.qml");
134 QCOMPARE(pageList.paths(), QStringList() << root.path() + "/a/" + PAGES_PATH + "/1.qml");
137void PageListTest::testDisabled()
141 makeFile(root, "a", "1.qml.disabled"); // before the fact
142 makeFile(root, "b", "1.qml");
143 makeFile(root, "b", "2.qml");
144 makeFile(root, "b", "2.qml.disabled"); // same dir
145 makeFile(root, "b", "3.qml");
146 makeFile(root, "b", "4.qml"); // only survivor
147 makeFile(root, "c", "3.qml.disabled"); // after the fact
150 QCOMPARE(pageList.entries(), QStringList() << "4.qml");
153QTEST_MAIN(PageListTest)
154#include "tst_pagelist.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list