diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-11 16:21:42 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-11 16:21:42 +0200 |
commit | 6a0bb9a7d6a6473920da74bb48c52a4eaed990b0 (patch) | |
tree | 3a32c56b1fe21c96d5982511e0b4815c1c07dfbb /tests/auto/qml/qqmlvaluetypes | |
parent | f0d23d3ff9da26a71295a6abd356c8d366d17439 (diff) | |
parent | 2746518c76e02c642ff29faf568de4de90216e58 (diff) |
Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Change-Id: I4a91928610f79c8e21a05781953ffa41508c828a
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes')
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 83a37df797..8a602a0356 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -784,6 +784,7 @@ void tst_qqmlvaluetypes::font() { QQmlComponent component(&engine, testFileUrl("font_read.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); QVERIFY(object != nullptr); QCOMPARE(object->property("f_family").toString(), object->font().family()); @@ -793,8 +794,19 @@ void tst_qqmlvaluetypes::font() QCOMPARE(object->property("f_underline").toBool(), object->font().underline()); QCOMPARE(object->property("f_overline").toBool(), object->font().overline()); QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut()); - QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF()); - QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.))); + + // If QFont::pixelSize() was set, QFont::pointSizeF() would return -1. + // If QFont::pointSizeF() was set, QFont::pixelSize() would return -1. + // QQuickFontValueType doesn't follow this semantic (if its -1 it calculates the value of + // the property from the other one) + double expectedPointSizeF = object->font().pointSizeF(); + if (expectedPointSizeF == -1) expectedPointSizeF = object->font().pixelSize() * qreal(72.) / qreal(qt_defaultDpi()); + int expectedPixelSize = object->font().pixelSize(); + if (expectedPixelSize == -1) expectedPixelSize = int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.)); + + QCOMPARE(object->property("f_pointSize").toDouble(), expectedPointSizeF); + QCOMPARE(object->property("f_pixelSize").toInt(), expectedPixelSize); + QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization()); QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing()); QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing()); |