aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2016-02-28 22:43:42 +0100
committerRobin Burchell <robin.burchell@viroteck.net>2016-03-01 21:47:49 +0000
commit83cb2069ead120e7777a13ef6b7c0a0b14052685 (patch)
treeb443c6a18b91967e6f46dc1b29bb53bd01ff8b62 /tests
parent23712c568072422e49d41f039ad72c92fd117afe (diff)
QQuickText{Edit,Input}: Reset selection when becoming readOnly.
When read only, controls may not be edited or altered, and indeed, a read-only control cannot acquire a selection (as it cannot be interacted with). Leaving an existing selection breaks that implication, so clear it when becoming read-only. [ChangeLog][QtQuick][TextEdit/TextInput] If a control has a selection, it is now cleared when becoming read-only. Task-number: QTBUG-51115 Change-Id: Ife43b97ee3d6b780f09a938868c3ccb2f1b6e6e7 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktextedit/data/qtbug51115.qml11
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp12
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug51115.qml11
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp13
4 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/data/qtbug51115.qml b/tests/auto/quick/qquicktextedit/data/qtbug51115.qml
new file mode 100644
index 0000000000..e3179cfc8e
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/qtbug51115.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+
+TextEdit {
+ Component.onCompleted: {
+ readOnly = false;
+ text= "bla bla";
+ selectAll();
+ readOnly = true;
+ }
+}
+
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 50e06e5663..b7bfc357f3 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -201,6 +201,7 @@ private slots:
void doubleSelect_QTBUG_38704();
void padding();
+ void QTBUG_51115_readOnlyResetsSelection();
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
@@ -5536,6 +5537,17 @@ void tst_qquicktextedit::padding()
delete root;
}
+void tst_qquicktextedit::QTBUG_51115_readOnlyResetsSelection()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("qtbug51115.qml"));
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QQuickTextEdit *obj = qobject_cast<QQuickTextEdit*>(view.rootObject());
+
+ QCOMPARE(obj->selectedText(), QString());
+}
+
QTEST_MAIN(tst_qquicktextedit)
#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/quick/qquicktextinput/data/qtbug51115.qml b/tests/auto/quick/qquicktextinput/data/qtbug51115.qml
new file mode 100644
index 0000000000..008ac25844
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/data/qtbug51115.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+
+TextInput {
+ Component.onCompleted: {
+ readOnly = false;
+ text= "bla bla";
+ selectAll();
+ readOnly = true;
+ }
+}
+
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index abb2c5b773..3b4e57b2a8 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -221,6 +221,8 @@ private slots:
void ensureVisible();
void padding();
+ void QTBUG_51115_readOnlyResetsSelection();
+
private:
void simulateKey(QWindow *, int key);
@@ -6697,6 +6699,17 @@ void tst_qquicktextinput::padding()
delete root;
}
+void tst_qquicktextinput::QTBUG_51115_readOnlyResetsSelection()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("qtbug51115.qml"));
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QQuickTextInput *obj = qobject_cast<QQuickTextInput*>(view.rootObject());
+
+ QCOMPARE(obj->selectedText(), QString());
+}
+
QTEST_MAIN(tst_qquicktextinput)
#include "tst_qquicktextinput.moc"