summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-09-17 19:50:14 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-09-17 19:50:14 (GMT)
commit572c466c3b202aab3426cdb4e9adb176f934b021 (patch)
treeb9ea97aa5f2ad3c138b5ca05ab7efac93e961161 /tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
parent4f33dbd5361c0875f39518b762a764478f04dd30 (diff)
parenta9e5329168cd9113bf41293c05193d8b099494c6 (diff)
downloadQt-572c466c3b202aab3426cdb4e9adb176f934b021.zip
Qt-572c466c3b202aab3426cdb4e9adb176f934b021.tar.gz
Qt-572c466c3b202aab3426cdb4e9adb176f934b021.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Make qml debugging work with command line arguments Fix example after changes to font.letterSpacing. Autotest and small fix for QDeclarativeFontLoader. Improve error messages Changes to objects returned from get() should emit itemsChanged() so Make it clear that private ListModel constructor is only for worker Remove duplicated move() implementations Doc changes Fix QDeclarativeXmlQuery mutex locking and don't wait for new jobs if the query has already quit PathView didn't accept mouse events, preventing it from working in a Flickable. Moving items in a PathView caused PathView.onPath to be set to false. Fix worker agent to emit ListModel itemsChanged() correctly when set()
Diffstat (limited to 'tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
index ae23017..8765426 100644
--- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -39,8 +39,10 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativecontext.h>
#include <private/qdeclarativefontloader_p.h>
#include "../../../shared/util.h"
#include "../shared/testhttpserver.h"
@@ -67,6 +69,7 @@ private slots:
void webFont();
void redirWebFont();
void failWebFont();
+ void changeFont();
private slots:
@@ -181,6 +184,45 @@ void tst_qdeclarativefontloader::failWebFont()
QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
}
+void tst_qdeclarativefontloader::changeFont()
+{
+ QString componentStr = "import Qt 4.7\nFontLoader { source: font }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+
+ QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
+ QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
+
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 0);
+ QCOMPARE(statusSpy.count(), 0);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Loading);
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 1);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+
+ ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 2);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 3);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+}
+
QTEST_MAIN(tst_qdeclarativefontloader)
#include "tst_qdeclarativefontloader.moc"