diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2009-05-19 07:39:44 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2009-05-19 07:39:44 (GMT) |
commit | 2d8a925309d2b5bfbff19df8bf607ccf3a343930 (patch) | |
tree | ebcba69f2b179793f78ad15450a0ab1cc32b448a /tests/auto/declarative/qmlengine | |
parent | 38a978121bef0efd1f6fd573c4289e40352b63a6 (diff) | |
download | Qt-2d8a925309d2b5bfbff19df8bf607ccf3a343930.zip Qt-2d8a925309d2b5bfbff19df8bf607ccf3a343930.tar.gz Qt-2d8a925309d2b5bfbff19df8bf607ccf3a343930.tar.bz2 |
Added QmlEngine::componentSearchPath()
componentSearchPath() returns the list of urls (folders) inspected
by qml to locate sub components. This is used in Bauhaus.
Autotests have been stored in new "declarative/qmlengine" directory.
Diffstat (limited to 'tests/auto/declarative/qmlengine')
-rw-r--r-- | tests/auto/declarative/qmlengine/qmlengine.pro | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qmlengine/tst_qmlengine.cpp | 43 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlengine/qmlengine.pro b/tests/auto/declarative/qmlengine/qmlengine.pro new file mode 100644 index 0000000..4ac81e9 --- /dev/null +++ b/tests/auto/declarative/qmlengine/qmlengine.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qmlengine.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp new file mode 100644 index 0000000..9a04c61 --- /dev/null +++ b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp @@ -0,0 +1,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" |