blob: 9a04c6102f76c714efa9f2dad7002622066cff42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include <qtest.h>
#include <QtDeclarative/QmlEngine>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QUrl>
class tst_qmlengine : public QObject
{
Q_OBJECT
public:
tst_qmlengine() {}
private slots:
void componentSearchPath();
};
void tst_qmlengine::componentSearchPath()
{
QFile file(SRCDIR "/imports.qml");
QVERIFY(file.open(QIODevice::ReadOnly));
QmlEngine engine;
QList<QUrl> searchPath = engine.componentSearchPath(file.readAll(),
QUrl::fromLocalFile(file.fileName()));
QList<QUrl> expected;
expected << QUrl::fromLocalFile(SRCDIR);
expected << QUrl::fromLocalFile(file.fileName()).resolved(QUrl("import1"));
expected << QUrl::fromLocalFile(file.fileName()).resolved(QUrl("import2"));
QCOMPARE(searchPath.size(), expected.size());
for (int i = 0; i < expected.size(); ++i) {
QCOMPARE(searchPath.at(i).toString(QUrl::StripTrailingSlash),
expected.at(i).toString(QUrl::StripTrailingSlash));
}
}
QTEST_MAIN(tst_qmlengine)
#include "tst_qmlengine.moc"
|