69
70
QTemporaryDir root;
71
makeFile(root, "a", "3");
72
makeFile(root, "b", "1");
73
makeFile(root, "c", "2");
72
makeFile(root, "a", "3.qml");
73
makeFile(root, "b", "1.qml");
74
makeFile(root, "c", "2.qml");
76
QCOMPARE(pageList.entries(), QStringList() << "1" << "2" << "3");
77
QCOMPARE(pageList.paths(), QStringList() << root.path() + "/b/" + PAGES_PATH + "/1"
78
<< root.path() + "/c/" + PAGES_PATH + "/2"
79
<< root.path() + "/a/" + PAGES_PATH + "/3");
77
QCOMPARE(pageList.entries(), QStringList() << "1.qml" << "2.qml" << "3.qml");
78
QCOMPARE(pageList.paths(), QStringList() << root.path() + "/b/" + PAGES_PATH + "/1.qml"
79
<< root.path() + "/c/" + PAGES_PATH + "/2.qml"
80
<< root.path() + "/a/" + PAGES_PATH + "/3.qml");
82
83
void PageListTest::testIterate()
84
85
QTemporaryDir root;
86
makeFile(root, "a", "1");
87
makeFile(root, "a", "2");
88
makeFile(root, "a", "3");
87
makeFile(root, "a", "1.qml");
88
makeFile(root, "a", "2.qml");
89
makeFile(root, "a", "3.qml");
91
92
QCOMPARE(pageList.index(), -1);
92
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/1");
93
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/1.qml");
93
94
QCOMPARE(pageList.prev(), QString());
94
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/2");
95
QCOMPARE(pageList.prev(), root.path() + "/a/" + PAGES_PATH + "/1");
95
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/2.qml");
96
QCOMPARE(pageList.prev(), root.path() + "/a/" + PAGES_PATH + "/1.qml");
96
97
QCOMPARE(pageList.index(), 0);
97
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/2");
98
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/3");
98
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/2.qml");
99
QCOMPARE(pageList.next(), root.path() + "/a/" + PAGES_PATH + "/3.qml");
99
100
QCOMPARE(pageList.index(), 2);
100
101
QCOMPARE(pageList.next(), QString());
101
102
QCOMPARE(pageList.index(), 2);
106
107
QTemporaryDir root;
108
makeFile(root, "a", "1");
109
makeFile(root, "a", "nope");
112
QCOMPARE(pageList.entries(), QStringList() << "1");
109
makeFile(root, "a", "1.qml");
110
makeFile(root, "a", "nope.qml");
113
QCOMPARE(pageList.entries(), QStringList() << "1.qml");
116
void PageListTest::testIgnoreNonQml()
120
makeFile(root, "a", "1.qml");
121
makeFile(root, "a", "2");
122
makeFile(root, "a", "2.txt");
125
QCOMPARE(pageList.entries(), QStringList() << "1.qml");
115
128
void PageListTest::testIgnoreDuplicates()
117
130
QTemporaryDir root;
119
makeFile(root, "a", "1");
120
makeFile(root, "b", "1");
132
makeFile(root, "a", "1.qml");
133
makeFile(root, "b", "1.qml");
122
135
PageList pageList;
123
QCOMPARE(pageList.paths(), QStringList() << root.path() + "/a/" + PAGES_PATH + "/1");
136
QCOMPARE(pageList.paths(), QStringList() << root.path() + "/a/" + PAGES_PATH + "/1.qml");
126
139
void PageListTest::testDisabled()
128
141
QTemporaryDir root;
130
makeFile(root, "a", "1.disabled"); // before the fact
131
makeFile(root, "b", "1");
132
makeFile(root, "b", "2");
133
makeFile(root, "b", "2.disabled"); // same dir
134
makeFile(root, "b", "3");
135
makeFile(root, "b", "4"); // only survivor
136
makeFile(root, "c", "3.disabled"); // after the fact
143
makeFile(root, "a", "1.qml.disabled"); // before the fact
144
makeFile(root, "b", "1.qml");
145
makeFile(root, "b", "2.qml");
146
makeFile(root, "b", "2.qml.disabled"); // same dir
147
makeFile(root, "b", "3.qml");
148
makeFile(root, "b", "4.qml"); // only survivor
149
makeFile(root, "c", "3.qml.disabled"); // after the fact
138
151
PageList pageList;
139
QCOMPARE(pageList.entries(), QStringList() << "4");
152
QCOMPARE(pageList.entries(), QStringList() << "4.qml");
142
155
QTEST_MAIN(PageListTest)