summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2009-05-19 07:39:44 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2009-05-19 07:39:44 (GMT)
commit2d8a925309d2b5bfbff19df8bf607ccf3a343930 (patch)
treeebcba69f2b179793f78ad15450a0ab1cc32b448a /tests
parent38a978121bef0efd1f6fd573c4289e40352b63a6 (diff)
downloadQt-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')
-rw-r--r--tests/auto/declarative/declarative.pro3
-rw-r--r--tests/auto/declarative/qmlengine/qmlengine.pro5
-rw-r--r--tests/auto/declarative/qmlengine/tst_qmlengine.cpp43
3 files changed, 50 insertions, 1 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index b6e3584..14d8c24 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -14,7 +14,8 @@ SUBDIRS += datetimeformatter \
qmlmetaproperty \
qmllist \
qmllistaccessor \
- visual
+ visual\
+ qmlengine
# Tests which should run in Pulse
PULSE_TESTS = $$SUBDIRS
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"