aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickfontloader
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-01-16 10:21:58 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-01-21 07:27:30 +0100
commit15ea475b40f6ad28d46e5cbd65a1ccc8556a53df (patch)
tree8156cc4a122f06d49623352c2fc6fbaf4e02b402 /tests/auto/quick/qquickfontloader
parent9aceff567c859bb91fe7221d2265953437402b43 (diff)
Make FontLoader.name read-only
Being able to set the name of a FontLoader seems to have been made to allow for some alternative coding patterns, but it doesn't really provide any convenience over other ways of customizing font names, and it definitely adds confusion for users, as well as as a possible race condition if both the source and name of the same FontLoader is set at unpredictable times. [ChangeLog][QtQuick] FontLoader.name property has been made read-only to reduce confusion about its use and precedence over conflicting properties. Fixes: QTBUG-80031 Change-Id: I0dd0e76ff376402c0b458ed7e5c57ec017bbc92d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickfontloader')
-rw-r--r--tests/auto/quick/qquickfontloader/data/qtbug-20268.qml8
-rw-r--r--tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp24
2 files changed, 6 insertions, 26 deletions
diff --git a/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml
index 0eafdfa17b..e9282bf2c7 100644
--- a/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml
+++ b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml
@@ -4,7 +4,7 @@ Rectangle {
id: test
property variant fontloader: fontloaderelement
height: 100; width: 100
- property bool usename: false
+ property bool useotherfont: false
property int statenum: 1
property alias name: fontloaderelement.name
property alias source: fontloaderelement.source
@@ -15,11 +15,11 @@ Rectangle {
}
states: [
- State { name: "start"; when: !usename
+ State { name: "start"; when: !useotherfont
PropertyChanges { target: fontloaderelement; source: "tarzeau_ocr_a.ttf" }
},
- State { name: "changefont"; when: usename
- PropertyChanges { target: fontloaderelement; name: "Tahoma" }
+ State { name: "changefont"; when: useotherfont
+ PropertyChanges { target: fontloaderelement; source: "daniel.ttf" }
}
]
diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
index 87a5bd469a..8f6910bee4 100644
--- a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
+++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
@@ -45,7 +45,6 @@ public:
private slots:
void initTestCase();
void noFont();
- void namedFont();
void localFont();
void failLocalFont();
void webFont();
@@ -85,19 +84,6 @@ void tst_qquickfontloader::noFont()
delete fontObject;
}
-void tst_qquickfontloader::namedFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }";
- QQmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
-
- QVERIFY(fontObject != nullptr);
- QCOMPARE(fontObject->source(), QUrl(""));
- QCOMPARE(fontObject->name(), QString("Helvetica"));
- QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
-}
-
void tst_qquickfontloader::localFont()
{
QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("tarzeau_ocr_a.ttf").toString() + "\" }";
@@ -223,16 +209,10 @@ void tst_qquickfontloader::changeFontSourceViaState()
QVERIFY(fontObject->source() != QUrl(""));
QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- window.rootObject()->setProperty("usename", true);
-
- // This warning should probably not be printed once QTBUG-20268 is fixed
- QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) +
- QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\"");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ window.rootObject()->setProperty("useotherfont", true);
- QEXPECT_FAIL("", "QTBUG-20268", Abort);
QTRY_COMPARE(fontObject->status(), QQuickFontLoader::Ready);
- QCOMPARE(window.rootObject()->property("name").toString(), QString("Tahoma"));
+ QCOMPARE(window.rootObject()->property("name").toString(), QString("Daniel"));
}
QTEST_MAIN(tst_qquickfontloader)