diff options
Diffstat (limited to 'tests/auto/quick/qquicktext')
-rw-r--r-- | tests/auto/quick/qquicktext/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml | 18 | ||||
-rw-r--r-- | tests/auto/quick/qquicktext/tst_qquicktext.cpp | 30 |
3 files changed, 48 insertions, 2 deletions
diff --git a/tests/auto/quick/qquicktext/BLACKLIST b/tests/auto/quick/qquicktext/BLACKLIST index 594f9af3b3..b551575e9d 100644 --- a/tests/auto/quick/qquicktext/BLACKLIST +++ b/tests/auto/quick/qquicktext/BLACKLIST @@ -1,7 +1,7 @@ [dependentImplicitSizes] b2qt qemu -osx-10.12 +macos [fontSizeMode] opensuse-42.1 [contentSize] diff --git a/tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml b/tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml new file mode 100644 index 0000000000..b0ed21a0c8 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + color: "white" + Text { + objectName: "text" + textFormat: Text.RichText + anchors.fill: parent + color: "black" + // display a black rectangle at the top left of the text + text: "<span style=\"background-color:rgba(255,255,255,255);vertical-align:super;\">█</span>This is a test" + verticalAlignment: Text.AlignTop + horizontalAlignment: Text.AlignLeft + font.pixelSize: 30 + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 06ce730091..19a33f1861 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -168,6 +168,8 @@ private slots: void transparentBackground(); + void displaySuperscriptedTag(); + private: QStringList standard; QStringList richText; @@ -1504,7 +1506,7 @@ void tst_qquicktext::weight() delete textObject; } { - QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; + QString componentStr = "import QtQuick 2.0\nText { font.weight: Font.Bold; text: \"Hello world!\" }"; QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create()); @@ -4507,6 +4509,32 @@ void tst_qquicktext::transparentBackground() QCOMPARE(color.blue(), 255); QCOMPARE(color.green(), 255); } + +void tst_qquicktext::displaySuperscriptedTag() +{ + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabToImage not functional on offscreen/minimimal platforms"); + + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("displaySuperscriptedTag.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickText *text = window->findChild<QQuickText *>("text"); + QVERIFY(text); + + QImage img = window->grabWindow(); + QCOMPARE(img.isNull(), false); + + QColor color = img.pixelColor(1, static_cast<int>(text->contentHeight()) / 4 * 3); + QCOMPARE(color.red(), 255); + QCOMPARE(color.blue(), 255); + QCOMPARE(color.green(), 255); +} + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" |