aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qsgtextinput
diff options
context:
space:
mode:
authorRafael Brandao <rafael.lobo@openbossa.org>2011-09-29 10:53:15 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-29 03:00:38 +0200
commit40f63187a44fac0de25933484b84c659e0451f59 (patch)
tree05d8601611f3884d4ac597d09639f1365e99a5f6 /tests/auto/declarative/qsgtextinput
parent55b4b637779e1a6d88b969837aa106487e4c636e (diff)
Added triple click on TextInput to select text.
Once it gets a double click, it'll start to monitor any other extra click for a short duration. Once it is detected, the monitor stops watching and all text is selected. It only works when selectByMouse property is set, just like double click selecting current word. Also added a test case that simulates clicking at the same point and triggering the triple click, and another one that contemplates movement of mouse between the second and the third click. Also test timing between clicks. Task-number: QTBUG-21038 Change-Id: I139f7ece2107f5dbfcba1836afb27aaa9b24fc57 Merge-request: 6 Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com> Reviewed-on: http://codereview.qt-project.org/5761 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'tests/auto/declarative/qsgtextinput')
-rw-r--r--tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
index b522251bfd..394c68dcab 100644
--- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
+++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
@@ -110,6 +110,7 @@ private slots:
void dragMouseSelection();
void mouseSelectionMode_data();
void mouseSelectionMode();
+ void tripleClickSelectsAll();
void horizontalAlignment_data();
void horizontalAlignment();
@@ -2723,6 +2724,49 @@ void tst_qsgtextinput::cursorRectangleSize()
#endif
}
+void tst_qsgtextinput::tripleClickSelectsAll()
+{
+ QString qmlfile = SRCDIR "/data/positionAt.qml";
+ QSGView view(QUrl::fromLocalFile(qmlfile));
+ view.requestActivateWindow();
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QEXPECT_FAIL("", QTBUG_21489_MESSAGE, Continue);
+ QTRY_COMPARE(view.windowState(), Qt::WindowActive);
+
+ QSGTextInput* input = qobject_cast<QSGTextInput*>(view.rootObject());
+ QVERIFY(input);
+
+ QLatin1String hello("Hello world!");
+ input->setSelectByMouse(true);
+ input->setText(hello);
+
+ // Clicking on the same point inside TextInput three times in a row
+ // should trigger a triple click, thus selecting all the text.
+ QPoint pointInside = input->pos().toPoint() + QPoint(2,2);
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QCOMPARE(input->selectedText(), hello);
+
+ // Now it simulates user moving the mouse between the second and the third click.
+ // In this situation, we don't expect a triple click.
+ QPoint pointInsideButFar = QPoint(input->width(),input->height()) - QPoint(2,2);
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInsideButFar);
+ QGuiApplication::processEvents();
+ QVERIFY(input->selectedText().isEmpty());
+
+ // And now we press the third click too late, so no triple click event is triggered.
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QTest::qWait(QApplication::doubleClickInterval() + 1);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QVERIFY(input->selectedText().isEmpty());
+}
+
QTEST_MAIN(tst_qsgtextinput)
#include "tst_qsgtextinput.moc"