aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-07-25 12:55:57 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-25 06:08:56 +0200
commite826e578eaef3f05498124eb2057f41410696480 (patch)
treefe8fb10f2df30165950b0362c9eef4cab3aae076 /tests
parentd9368b7bab1a44c78a035081e4f2ee0eb1df7c33 (diff)
Notify when the TextInput cursorRectangle property changes within pre-edit
Apply 452e13b5407fa4c36f9a573c305d41f551762b93 to scene graph items. Task-number: QTBUG-19089 Change-Id: I4501bdc940cbac9ba2ef068b87ded83b1c86976f Reviewed-on: http://codereview.qt.nokia.com/2054 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgtextinput/data/inputMethodEvent.qml1
-rw-r--r--tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/declarative/qsgtextinput/data/inputMethodEvent.qml b/tests/auto/declarative/qsgtextinput/data/inputMethodEvent.qml
index f8446ab7b9..7aefdf28f4 100644
--- a/tests/auto/declarative/qsgtextinput/data/inputMethodEvent.qml
+++ b/tests/auto/declarative/qsgtextinput/data/inputMethodEvent.qml
@@ -2,4 +2,5 @@ import QtQuick 2.0
TextInput {
focus: true
+ autoScroll: false
}
diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
index 9d548bb5ca..c6c93c16e5 100644
--- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
+++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
@@ -2203,6 +2203,9 @@ void tst_qsgtextinput::preeditAutoScroll()
QSGTextInput *input = qobject_cast<QSGTextInput *>(view.rootObject());
QVERIFY(input);
+ QSignalSpy cursorRectangleSpy(input, SIGNAL(cursorRectangleChanged()));
+ int cursorRectangleChanges = 0;
+
QFontMetricsF fm(input->font());
input->setWidth(fm.width(input->text()));
@@ -2210,11 +2213,13 @@ void tst_qsgtextinput::preeditAutoScroll()
ic.sendPreeditText(preeditText.mid(0, 3), 1);
QVERIFY(input->positionAt(0) != 0);
QVERIFY(input->cursorRectangle().left() < input->boundingRect().width());
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
// test the text is scrolled back when the preedit is removed.
ic.sendEvent(QInputMethodEvent());
QCOMPARE(input->positionAt(0), 0);
QCOMPARE(input->positionAt(input->width()), 5);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
// some tolerance for different fonts.
#ifdef Q_OS_LINUX
@@ -2230,26 +2235,31 @@ void tst_qsgtextinput::preeditAutoScroll()
ic.sendPreeditText(preeditText, i + 1);
QVERIFY(input->cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input->positionToRectangle(0).x() < x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
x = input->positionToRectangle(0).x();
}
for (int i = 1; i >= 0; --i) {
ic.sendPreeditText(preeditText, i + 1);
QVERIFY(input->cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input->positionToRectangle(0).x() > x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
x = input->positionToRectangle(0).x();
}
// Test incrementing the preedit cursor doesn't cause further
// scrolling when right most text is visible.
ic.sendPreeditText(preeditText, preeditText.length() - 3);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
x = input->positionToRectangle(0).x();
for (int i = 2; i >= 0; --i) {
ic.sendPreeditText(preeditText, preeditText.length() - i);
QCOMPARE(input->positionToRectangle(0).x(), x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
}
for (int i = 1; i < 3; ++i) {
ic.sendPreeditText(preeditText, preeditText.length() - i);
QCOMPARE(input->positionToRectangle(0).x(), x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
}
// Test disabling auto scroll.