aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktext
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-01-29 16:41:59 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-01-29 16:52:58 +0100
commitb684ba219493fb7b0108ae367d6d033aaa28053b (patch)
treef1fec8922da198e231416b50ef8f441ef6db065b /tests/auto/quick/qquicktext
parent97a5cf86345fd72cdff83c03664c19a8f5cdf79a (diff)
parent8354851b628ebae567a9125cbd0ba69268470c1b (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts: dependencies.yaml Change-Id: Ie3e9dc62031a85e5e81cbdf04694b95159d49fca
Diffstat (limited to 'tests/auto/quick/qquicktext')
-rw-r--r--tests/auto/quick/qquicktext/BLACKLIST2
-rw-r--r--tests/auto/quick/qquicktext/data/displaySuperscriptedTag.qml18
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp30
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;\">&#x2588;</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"