aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2020-06-02 22:35:34 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-06-05 01:57:40 +0000
commit4f5648478e8f4dd52cfba480980f1a000ff3b3fd (patch)
treedce2f93adb9185b7a9fbb889530f41943fc9d545 /tests
parent1d5c0cf6821dd608835b96f4e20f417f4346408f (diff)
QQuickTextNodeEngine: prevent renderring transparent selection color
It is not necessary to render selection color which is transparent. Fixes: QTBUG-83819 Change-Id: I45c086652e194192619aad025121e6064ab37a58 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit bf8b45e33af960c03c7dccf56e90e76eda1f510e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktextedit/data/transparentSelectionColor.qml17
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp27
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/data/transparentSelectionColor.qml b/tests/auto/quick/qquicktextedit/data/transparentSelectionColor.qml
new file mode 100644
index 0000000000..185d66a1ed
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/transparentSelectionColor.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.10
+
+Rectangle {
+ width: 640
+ height: 480
+ color: "red"
+ TextEdit {
+ id: textEdit
+ anchors.top: parent.top
+ anchors.left: parent.left
+ width: contentWidth
+ height: contentHeight
+ font.pixelSize: 50
+ text: " "
+ selectionColor: "transparent"
+ }
+}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 8ea2ce3bfb..768062314b 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -220,6 +220,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)
@@ -5810,6 +5811,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"