--- /dev/null
+import QtQuick 2.0
+
+Rectangle {
+ id: test
+ property variant fontloader: fontloaderelement
+ height: 100; width: 100
+ property bool usename: false
+ property int statenum: 1
+ property alias name: fontloaderelement.name
+ property alias source: fontloaderelement.source
+ property alias status: fontloaderelement.status
+
+ FontLoader {
+ id: fontloaderelement
+ }
+
+ states: [
+ State { name: "start"; when: !usename
+ PropertyChanges { target: fontloaderelement; source: "tarzeau_ocr_a.ttf" }
+ },
+ State { name: "changefont"; when: usename
+ PropertyChanges { target: fontloaderelement; name: "Tahoma" }
+ }
+ ]
+
+ Text { id: textelement; text: fontloaderelement.name; color: "black" }
+}
#include <QtDeclarative/private/qdeclarativefontloader_p.h>
#include "../shared/util.h"
#include "../../declarative/shared/testhttpserver.h"
+#include <QQuickView>
+#include <QQuickItem>
#define SERVER_PORT 14448
void redirWebFont();
void failWebFont();
void changeFont();
+ void changeFontSourceViaState();
private:
QDeclarativeEngine engine;
QTRY_COMPARE(fontObject->name(), QString("Daniel"));
}
+void tst_qdeclarativefontloader::changeFontSourceViaState()
+{
+ QQuickView canvas(QUrl::fromLocalFile(TESTDATA("qtbug-20268.qml")));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(qvariant_cast<QObject *>(canvas.rootObject()->property("fontloader")));
+ QVERIFY(fontObject != 0);
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ canvas.rootObject()->setProperty("usename", true);
+ QEXPECT_FAIL("", "QTBUG-20268", Abort);
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(canvas.rootObject()->property("name").toString(), QString("Tahoma"));
+}
+
QTEST_MAIN(tst_qdeclarativefontloader)
#include "tst_qdeclarativefontloader.moc"