summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlengine
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-16 08:30:04 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-16 08:30:04 (GMT)
commit7db99f103981b6b45cb70a5837eb6b439d33e207 (patch)
treeca9163d9bc8336a83e2f2ff364aefed5c38f204f /tests/auto/declarative/qmlengine
parentd51de46fe6d52126c57623156a5c7e4ed61a51a7 (diff)
downloadQt-7db99f103981b6b45cb70a5837eb6b439d33e207.zip
Qt-7db99f103981b6b45cb70a5837eb6b439d33e207.tar.gz
Qt-7db99f103981b6b45cb70a5837eb6b439d33e207.tar.bz2
Tests
Diffstat (limited to 'tests/auto/declarative/qmlengine')
-rw-r--r--tests/auto/declarative/qmlengine/tst_qmlengine.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
index ef1eee5..54f916f 100644
--- a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
+++ b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
@@ -47,6 +47,7 @@
#include <QDir>
#include <QDesktopServices>
#include <QDebug>
+#include <QmlComponent>
class tst_qmlengine : public QObject
{
@@ -60,6 +61,7 @@ private slots:
void baseUrl();
void contextForObject();
void offlineStoragePath();
+ void clearComponentCache();
};
void tst_qmlengine::rootContext()
@@ -171,6 +173,57 @@ void tst_qmlengine::offlineStoragePath()
QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
}
+void tst_qmlengine::clearComponentCache()
+{
+ QmlEngine engine;
+
+ // Create original qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import Qt 4.6\nObject {\nproperty int test: 10\n}\n");
+ file.close();
+ }
+
+ // Test "test" property
+ {
+ QmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Modify qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import Qt 4.6\nObject {\nproperty int test: 11\n}\n");
+ file.close();
+ }
+
+ // Test cache hit
+ {
+ QmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Clear cache
+ engine.clearComponentCache();
+
+ // Test cache refresh
+ {
+ QmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 11);
+ delete obj;
+ }
+}
+
QTEST_MAIN(tst_qmlengine)
#include "tst_qmlengine.moc"