aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2020-06-02 22:35:34 +0800
committerWang Chuan <ouchuanm@outlook.com>2020-06-05 08:25:04 +0800
commitbf8b45e33af960c03c7dccf56e90e76eda1f510e (patch)
tree2b7e624daea3443eb7240abb799180ce9f21d246 /tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
parent69126c7bb1eed2afd06fd70d364c8e4e2ba4a21a (diff)
QQuickTextNodeEngine: prevent renderring transparent selection color
It is not necessary to render selection color which is transparent. Pick-to: 5.15 Fixes: QTBUG-83819 Change-Id: I45c086652e194192619aad025121e6064ab37a58 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 4891bb327c..d0ba99f42d 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -221,6 +221,7 @@ private slots:
void QTBUG_51115_readOnlyResetsSelection();
void keys_shortcutoverride();
+ void transparentSelectionColor();
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
#if QT_CONFIG(shortcut)
@@ -5835,6 +5836,32 @@ void tst_qquicktextedit::keys_shortcutoverride()
QCOMPARE(root->property("who").value<QString>(), QLatin1String("TextEdit"));
}
+void tst_qquicktextedit::transparentSelectionColor()
+{
+ if ((QGuiApplication::platformName() == QLatin1String("offscreen"))
+ || (QGuiApplication::platformName() == QLatin1String("minimal")))
+ QSKIP("Skipping due to grabToImage not functional on offscreen/minimal platforms");
+
+ QQuickView view;
+ view.setSource(testFileUrl("transparentSelectionColor.qml"));
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QObject *root = view.rootObject();
+ QVERIFY(root);
+
+ QQuickTextEdit *textEdit = root->findChild<QQuickTextEdit *>();
+ QVERIFY(textEdit);
+ textEdit->selectAll();
+
+ QImage img = view.grabWindow();
+ QCOMPARE(img.isNull(), false);
+
+ QColor color = img.pixelColor(int(textEdit->width() / 2), int(textEdit->height()) / 2);
+ QVERIFY(color.red() > 250);
+ QVERIFY(color.blue() < 10);
+ QVERIFY(color.green() < 10);
+}
+
QTEST_MAIN(tst_qquicktextedit)
#include "tst_qquicktextedit.moc"