aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
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
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')
-rw-r--r--tests/auto/qmltest/fontloader/daniel.ttfbin0 -> 51984 bytes
-rw-r--r--tests/auto/qmltest/fontloader/tst_fontloader.qml9
-rw-r--r--tests/auto/quick/qquickfontloader/data/qtbug-20268.qml8
-rw-r--r--tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp24
4 files changed, 8 insertions, 33 deletions
diff --git a/tests/auto/qmltest/fontloader/daniel.ttf b/tests/auto/qmltest/fontloader/daniel.ttf
new file mode 100644
index 0000000000..aae50d5035
--- /dev/null
+++ b/tests/auto/qmltest/fontloader/daniel.ttf
Binary files differ
diff --git a/tests/auto/qmltest/fontloader/tst_fontloader.qml b/tests/auto/qmltest/fontloader/tst_fontloader.qml
index 0d1831230e..48b92e02ba 100644
--- a/tests/auto/qmltest/fontloader/tst_fontloader.qml
+++ b/tests/auto/qmltest/fontloader/tst_fontloader.qml
@@ -81,10 +81,6 @@ Item {
fontloader.source = "dummy.ttf";
tryCompare(fontloader, 'status', FontLoader.Error)
compare(testinput.font.family, "")
- fontloader.source = "";
- fontloader.name = "Courier";
- tryCompare(fontloader, 'status', FontLoader.Ready)
- compare(testinput.font.family, "Courier")
}
function test_fontswitching() {
@@ -92,10 +88,9 @@ Item {
fontswitch.source = "tarzeau_ocr_a.ttf";
tryCompare(fontswitch, 'status', FontLoader.Ready)
compare(fontswitch.name, "OCRA")
- fontswitch.source = "";
- fontswitch.name = "Courier";
+ fontswitch.source = "daniel.ttf";
tryCompare(fontswitch, 'status', FontLoader.Ready)
- compare(fontswitch.name, "Courier")
+ compare(fontswitch.name, "Daniel")
fontswitch.source = "tarzeau_ocr_a.ttf";
tryCompare(fontswitch, 'status', FontLoader.Ready)
compare(fontswitch.name, "OCRA")
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)